diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-14 17:01:22 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-14 17:01:22 +0100 |
commit | 14fa59eee9ba35ad462b5b17229a09164f5d716d (patch) | |
tree | 1223522b7cc30cf57ad8ec66e50c5081727fe3d4 /ctrack/register/forms.py | |
parent | bc4edc69407f20da32a48d534b3d725cc3818c1a (diff) |
about to nuke migrations
Diffstat (limited to '')
-rw-r--r-- | ctrack/register/forms.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/ctrack/register/forms.py b/ctrack/register/forms.py index d3e93ab..2afc1a1 100644 --- a/ctrack/register/forms.py +++ b/ctrack/register/forms.py @@ -16,13 +16,15 @@ from ctrack.register.models import ( ) -class AddMeetingForm(forms.ModelForm): +class CreateSimpleDateTimeEventForm(forms.ModelForm): class Meta: model = SingleDateTimeEvent fields = [ "type_descriptor", "short_description", "datetime", + "requested_response_date", + "response_received_date", "comments", "location", ] @@ -31,6 +33,17 @@ class AddMeetingForm(forms.ModelForm): self.user = kwargs.pop("user") super().__init__(*args, **kwargs) + def clean(self): + cleaned_data = super().clean() + date = cleaned_data.get("datetime") + if not date: + return cleaned_data + # WOOO - walrus operator + if requested := cleaned_data.get("requested_response_date"): + if requested < date.date(): + raise ValidationError("Requested response cannot be before date.") + return cleaned_data + def save(self, **kwargs): form = super().save(commit=False) form.user = self.user @@ -68,8 +81,8 @@ class CAFTwinDateEventForm(forms.ModelForm): caf = self.cleaned_data["related_caf"] existing_obj = ( CAFTwinDateEvent.objects.filter(start_date=data) - .filter(related_caf=caf) - .first() + .filter(related_caf=caf) + .first() ) if existing_obj: raise ValidationError( |