0.12.1 fix form from and to place fields choices
This commit is contained in:
@@ -6,6 +6,47 @@ from django.core.exceptions import ValidationError
|
||||
from .models import *
|
||||
|
||||
|
||||
def routeForm_assign_choices_by_type_transport(form, type_transport):
|
||||
if type_transport == 'avia':
|
||||
transfer_location_choices = (
|
||||
('airport', _('В аэропорту')),
|
||||
('city', _('По городу')),
|
||||
('other', _('По договоренности'))
|
||||
)
|
||||
|
||||
cargo_type_choices = (
|
||||
('cargo', _('Груз')),
|
||||
('parcel', _('Бандероль')),
|
||||
('package', _('Посылка')),
|
||||
('letter', _('Письмо\Документ'))
|
||||
)
|
||||
|
||||
else:
|
||||
transfer_location_choices = (
|
||||
('city', _('По городу')),
|
||||
('other', _('По договоренности'))
|
||||
)
|
||||
|
||||
cargo_type_choices = (
|
||||
('passenger', _('Пассажир')),
|
||||
('cargo', _('Груз')),
|
||||
('parcel', _('Бандероль')),
|
||||
('package', _('Посылка')),
|
||||
('letter', _('Письмо\Документ'))
|
||||
)
|
||||
|
||||
form.fields['from_place'].choices = transfer_location_choices
|
||||
form.fields['to_place'].choices = transfer_location_choices
|
||||
form.fields['cargo_type'].choices = cargo_type_choices
|
||||
|
||||
form.base_fields['from_place'].choices = transfer_location_choices
|
||||
form.base_fields['to_place'].choices = transfer_location_choices
|
||||
form.base_fields['cargo_type'].choices = cargo_type_choices
|
||||
|
||||
return form
|
||||
|
||||
|
||||
|
||||
class RouteForm(forms.ModelForm):
|
||||
from_address_point_txt = forms.CharField(required=True)
|
||||
to_address_point_txt = forms.CharField(required=True)
|
||||
|
||||
Reference in New Issue
Block a user