0.8.36 check dates when route create

This commit is contained in:
SDE
2023-12-05 17:43:01 +03:00
parent 3ac85784a9
commit af800ac84c
2 changed files with 5 additions and 2 deletions

View File

@@ -23,6 +23,9 @@ class RouteForm(forms.ModelForm):
try:
if 'departure_DT' in cleaned_data and 'arrival_DT' in cleaned_data and cleaned_data['arrival_DT'] < cleaned_data['departure_DT']:
self.add_error('arrival_DT', _('Указана неверная дата прибытия'))
if 'from_place' in self.data and self.data['from_place'] not in [item[0] for item in self.fields['from_place'].choices]:
cleaned_data['from_place'] = self.fields['from_place'].choices[0][0]