validate checkin & checkout

This commit is contained in:
Oliver Zander 2025-11-07 15:29:09 +01:00 committed by Tobias Herre
parent 9b1fb39d8c
commit 0bd7bb0672
1 changed files with 8 additions and 0 deletions

View File

@ -387,6 +387,14 @@ class Travel(Extern):
# use content type model to get the end date for the project foreign key
project_end_quartal = models.CharField(max_length=15, null=True, blank=True, verbose_name='Quartal Projekt Ende')
def clean(self):
if (self.checkin and self.checkout) and (self.checkout < self.checkin):
raise forms.ValidationError({
'checkout': [
forms.ValidationError('Das Datum der Abreise muss nach dem Datum der Anreise liegen.'),
],
})
@receiver(pre_save, sender=Travel, dispatch_uid='get_project_end')
def get_project_end(sender, instance, **kwargs):