Add ability to edit checkins, more validation

This commit is contained in:
2023-05-15 00:36:57 +01:00
parent fc8bb2dc4b
commit 97dac51a52
9 changed files with 122 additions and 57 deletions

View File

@@ -82,7 +82,8 @@ class Profile(AbstractUser):
return self.name
def current_event(self):
return EventCheckIn.objects.filter(person=self).latest('time') or None
q = EventCheckIn.objects.filter(person=self, end_time=None)
return q.latest('time') if q.exists() else None
class ContactableManager(models.Manager):
@@ -919,6 +920,10 @@ class EventCheckIn(models.Model):
vehicle = models.CharField(max_length=100, blank=True)
end_time = models.DateTimeField(null=True)
def clean(self):
if self.end_time < self.time:
raise ValidationError("May not check out before you've checked in. Please invent time travel and retry.")
def active(self):
return end_time is not None