2.1.16 change cargo_type and transport_type names
This commit is contained in:
@@ -4,46 +4,9 @@ from django.contrib.auth.forms import AuthenticationForm
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from .models import *
|
from .models import *
|
||||||
|
import copy
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,19 @@ from django.db.models import F, Q
|
|||||||
elements_on_page = 25
|
elements_on_page = 25
|
||||||
|
|
||||||
|
|
||||||
|
def get_cargo_types_by_type_transport(type_transport, form=None):
|
||||||
|
cargo_types = copy.deepcopy(cargo_type_choices)
|
||||||
|
if type_transport in ['avia']:
|
||||||
|
cargo_types = cargo_types[:2] + cargo_types[3:]
|
||||||
|
|
||||||
|
if not form:
|
||||||
|
return cargo_types
|
||||||
|
|
||||||
|
form.fields['cargo_type'].choices = cargo_types
|
||||||
|
|
||||||
|
form.base_fields['cargo_type'].choices = cargo_types
|
||||||
|
|
||||||
|
return form
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -28,53 +39,13 @@ def get_profile_new_route_page_html(request, data):
|
|||||||
|
|
||||||
errors_off = True
|
errors_off = True
|
||||||
|
|
||||||
# if 'from_address_point' in data:
|
|
||||||
# del data['from_address_point']
|
|
||||||
# if 'from_address_point_txt' in data:
|
|
||||||
# del data['from_address_point_txt']
|
|
||||||
#
|
|
||||||
# if 'to_address_point' in data:
|
|
||||||
# del data['to_address_point']
|
|
||||||
# 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)
|
form = RouteForm(data)
|
||||||
if not form.is_valid():
|
if not form.is_valid():
|
||||||
pass
|
pass
|
||||||
form = RouteForm(initial=form.cleaned_data)
|
form = RouteForm(initial=form.cleaned_data)
|
||||||
|
|
||||||
if 'type_transport' in data:
|
if 'type_transport' in data:
|
||||||
form = routeForm_assign_choices_by_type_transport(form, data['type_transport'])
|
form = get_cargo_types_by_type_transport(data['type_transport'], form)
|
||||||
|
|
||||||
|
|
||||||
if 'owner_type' in data:
|
if 'owner_type' in data:
|
||||||
|
|||||||
@@ -174,7 +174,8 @@ def edit_route_ajax(request):
|
|||||||
route = Route.objects.get(id=data['route_id'])
|
route = Route.objects.get(id=data['route_id'])
|
||||||
|
|
||||||
form = RouteForm(instance=route)
|
form = RouteForm(instance=route)
|
||||||
form = routeForm_assign_choices_by_type_transport(form, route.type_transport)
|
form = get_cargo_types_by_type_transport(route.type_transport, form)
|
||||||
|
# routeForm_assign_choices_by_type_transport(form, route.type_transport)
|
||||||
|
|
||||||
route_address_points_Dict = route.get_address_points()
|
route_address_points_Dict = route.get_address_points()
|
||||||
form.initial.update({
|
form.initial.update({
|
||||||
@@ -358,9 +359,7 @@ def get_cargo_type_by_transport_type_ajax(request):
|
|||||||
if not data or not 'type_transport' in data:
|
if not data or not 'type_transport' in data:
|
||||||
return JsonResponse({'html': 'недостаточно данных'}, status=400)
|
return JsonResponse({'html': 'недостаточно данных'}, status=400)
|
||||||
|
|
||||||
cargo_types = copy.deepcopy(cargo_type_choices)
|
cargo_types = get_cargo_types_by_type_transport(data['type_transport'])
|
||||||
if data['type_transport'] in ['avia']:
|
|
||||||
cargo_types = cargo_types[:2] + cargo_types[3:]
|
|
||||||
|
|
||||||
return JsonResponse({'cargo_types': cargo_types})
|
return JsonResponse({'cargo_types': cargo_types})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user