2.1.21 fix cargo_type choices
This commit is contained in:
@@ -35,12 +35,22 @@ class RouteForm(forms.ModelForm):
|
|||||||
self.fields['to_city'].required = True
|
self.fields['to_city'].required = True
|
||||||
self.fields['type_transport'].required = True
|
self.fields['type_transport'].required = True
|
||||||
|
|
||||||
|
data = None
|
||||||
|
if kwargs and 'data' in kwargs:
|
||||||
|
data= kwargs['data']
|
||||||
|
|
||||||
if owner_type == 'mover':
|
if owner_type == 'mover':
|
||||||
self.fields['departure_DT'].required = True
|
self.fields['departure_DT'].required = True
|
||||||
self.fields['type_transport'].choices = type_transport_choices[:-1]
|
self.fields['type_transport'].choices = type_transport_choices[:-1]
|
||||||
else:
|
else:
|
||||||
self.fields['type_transport'].choices = type_transport_choices
|
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):
|
def clean(self):
|
||||||
# print('check')
|
# print('check')
|
||||||
cleaned_data = super(RouteForm, self).clean()
|
cleaned_data = super(RouteForm, self).clean()
|
||||||
|
|||||||
Reference in New Issue
Block a user