change type_transport routines
This commit is contained in:
SDE
2023-07-31 16:22:27 +03:00
parent 968f9e5ab2
commit df9acda9a3
2 changed files with 88 additions and 6 deletions

View File

@@ -27,17 +27,77 @@ def new_route_view_ajax(request):
data = request.POST
form = CreateRouteForm(data)
if not form.is_valid():
pass
if form.cleaned_data['type_transport'] == 'avia':
pass
if 'type_transport' in data:
if data['type_transport'] == 'avia':
transfer_location_choices = (
('airport', _('В аэропорту')),
('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 = CreateRouteForm(data)
#
# if not form.is_valid():
# pass
else:
transfer_location_choices = (
('city', _('По городу')),
('other', _('По договоренности'))
)
cargo_type_choices = (
('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
form = CreateRouteForm(data)
if not form.is_valid():
pass
Dict = {
'form': form
}
# print(form)
except Exception as e:
form.errors.apend({'__all__': f'Ошибка: {str(e)}'})
form.errors.append({'__all__': f'Ошибка: {str(e)}'})
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request)
return JsonResponse({'html': html}, status=200)