2.1.21 fix cargo_type choices

This commit is contained in:
SDE
2025-01-15 19:55:09 +03:00
parent 575ee074b1
commit 9116b9efe1

View File

@@ -35,12 +35,22 @@ class RouteForm(forms.ModelForm):
self.fields['to_city'].required = True
self.fields['type_transport'].required = True
data = None
if kwargs and 'data' in kwargs:
data= kwargs['data']
if owner_type == 'mover':
self.fields['departure_DT'].required = True
self.fields['type_transport'].choices = type_transport_choices[:-1]
else:
self.fields['type_transport'].choices = type_transport_choices
cargo_types = copy.deepcopy(cargo_type_choices)
if data and 'type_transport' in data and data['type_transport'] == 'avia':
cargo_types = cargo_types[:2] + cargo_types[3:]
self.fields['cargo_type'].choices = cargo_types
def clean(self):
# print('check')
cleaned_data = super(RouteForm, self).clean()