mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-23 08:22:15 +00:00
Add ability to edit checkins, more validation
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user