0.12.1 fix form from and to place fields choices
This commit is contained in:
@@ -7,12 +7,19 @@ from datetime import datetime
|
||||
elements_on_page = 25
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def get_profile_new_route_page_html(request, data):
|
||||
|
||||
form = RouteForm()
|
||||
Dict = {
|
||||
'form': form
|
||||
}
|
||||
|
||||
|
||||
try:
|
||||
|
||||
errors_off = True
|
||||
@@ -27,48 +34,51 @@ def get_profile_new_route_page_html(request, data):
|
||||
if 'to_address_point_txt' in data:
|
||||
del data['to_address_point_txt']
|
||||
|
||||
|
||||
# if data['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 = RouteForm(data)
|
||||
if not form.is_valid():
|
||||
pass
|
||||
form = RouteForm(initial=form.cleaned_data)
|
||||
|
||||
if 'type_transport' in data:
|
||||
if data['type_transport'] == 'avia':
|
||||
transfer_location_choices = (
|
||||
('airport', _('В аэропорту')),
|
||||
('city', _('По городу')),
|
||||
('other', _('По договоренности'))
|
||||
)
|
||||
form = routeForm_assign_choices_by_type_transport(form, data['type_transport'])
|
||||
|
||||
cargo_type_choices = (
|
||||
('cargo', _('Груз')),
|
||||
('parcel', _('Бандероль')),
|
||||
('package', _('Посылка')),
|
||||
('letter', _('Письмо\Документ'))
|
||||
)
|
||||
|
||||
|
||||
else:
|
||||
transfer_location_choices = (
|
||||
('city', _('По городу')),
|
||||
('other', _('По договоренности'))
|
||||
)
|
||||
|
||||
cargo_type_choices = (
|
||||
('passenger', _('Пассажир')),
|
||||
('cargo', _('Груз')),
|
||||
('parcel', _('Бандероль')),
|
||||
('package', _('Посылка')),
|
||||
('letter', _('Письмо\Документ'))
|
||||
)
|
||||
|
||||
form = RouteForm(data)
|
||||
if not form.is_valid():
|
||||
pass
|
||||
form = RouteForm(initial=form.cleaned_data)
|
||||
|
||||
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
|
||||
# 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
|
||||
|
||||
# form = CreateRouteForm(initial=data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user