2.1.11 split mover and customer forms
This commit is contained in:
@@ -86,18 +86,22 @@ class RouteForm(forms.ModelForm):
|
|||||||
# if error:
|
# if error:
|
||||||
# self.add_error('extra_phone', error)
|
# self.add_error('extra_phone', error)
|
||||||
|
|
||||||
if 'departure_DT' in cleaned_data and 'arrival_DT' in cleaned_data and cleaned_data['arrival_DT'] < cleaned_data['departure_DT']:
|
if (
|
||||||
|
'departure_DT' in cleaned_data and 'arrival_DT' in cleaned_data
|
||||||
|
and cleaned_data['arrival_DT'] and cleaned_data['departure_DT']
|
||||||
|
and cleaned_data['arrival_DT'] < cleaned_data['departure_DT']
|
||||||
|
):
|
||||||
self.add_error('arrival_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]:
|
# 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]
|
# cleaned_data['from_place'] = self.fields['from_place'].choices[0][0]
|
||||||
if 'from_place' in self.errors and self.errors['from_place'].data[0].code == 'invalid_choice':
|
# if 'from_place' in self.errors and self.errors['from_place'].data[0].code == 'invalid_choice':
|
||||||
del self.errors['from_place']
|
# del self.errors['from_place']
|
||||||
if 'to_place' in self.data and self.data['to_place'] not in [item[0] for item in self.fields['to_place'].choices]:
|
# if 'to_place' in self.data and self.data['to_place'] not in [item[0] for item in self.fields['to_place'].choices]:
|
||||||
cleaned_data['to_place'] = self.fields['to_place'].choices[0][0]
|
# cleaned_data['to_place'] = self.fields['to_place'].choices[0][0]
|
||||||
if 'to_place' in self.errors and self.errors['to_place'].data[0].code == 'invalid_choice':
|
# if 'to_place' in self.errors and self.errors['to_place'].data[0].code == 'invalid_choice':
|
||||||
del self.errors['to_place']
|
# del self.errors['to_place']
|
||||||
if 'cargo_type' in self.data and self.data['cargo_type'] not in [item[0] for item in self.fields['cargo_type'].choices]:
|
if 'cargo_type' in self.data and self.data['cargo_type'] not in [item[0] for item in self.fields['cargo_type'].choices]:
|
||||||
cleaned_data['cargo_type'] = self.fields['cargo_type'].choices[0][0]
|
cleaned_data['cargo_type'] = self.fields['cargo_type'].choices[0][0]
|
||||||
if 'cargo_type' in self.errors and self.errors['cargo_type'].data[0].code == 'invalid_choice':
|
if 'cargo_type' in self.errors and self.errors['cargo_type'].data[0].code == 'invalid_choice':
|
||||||
|
|||||||
Reference in New Issue
Block a user