2.1.10 split mover and customer forms
This commit is contained in:
@@ -22,6 +22,7 @@ def get_profile_new_route_page_html(request, data):
|
|||||||
'form': form
|
'form': form
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tpl = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
@@ -75,22 +76,18 @@ def get_profile_new_route_page_html(request, data):
|
|||||||
if 'type_transport' in data:
|
if 'type_transport' in data:
|
||||||
form = routeForm_assign_choices_by_type_transport(form, data['type_transport'])
|
form = routeForm_assign_choices_by_type_transport(form, data['type_transport'])
|
||||||
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
# if not form.is_valid():
|
|
||||||
# pass
|
|
||||||
|
|
||||||
if 'owner_type' in data:
|
if 'owner_type' in data:
|
||||||
form.initial['owner_type'] = data['owner_type']
|
form.initial['owner_type'] = data['owner_type']
|
||||||
|
|
||||||
|
if data['owner_type'] == 'mover':
|
||||||
|
tpl = 'v2/blocks/b_make_mover_order.html'
|
||||||
|
else:
|
||||||
|
tpl = 'v2/blocks/b_make_poster_order.html'
|
||||||
|
|
||||||
|
Dict.update({'owner_type': data['owner_type']})
|
||||||
|
|
||||||
|
|
||||||
if request.user and request.user.is_authenticated and request.user.user_profile and request.user.user_profile.phone:
|
if request.user and request.user.is_authenticated and request.user.user_profile and request.user.user_profile.phone:
|
||||||
form.initial.update({'phone': request.user.user_profile.phone})
|
form.initial.update({'phone': request.user.user_profile.phone})
|
||||||
|
|
||||||
@@ -99,15 +96,13 @@ def get_profile_new_route_page_html(request, data):
|
|||||||
'errors_off': errors_off
|
'errors_off': errors_off
|
||||||
}
|
}
|
||||||
|
|
||||||
if 'owner_type' in data:
|
|
||||||
Dict.update({'owner_type': data['owner_type']})
|
|
||||||
|
|
||||||
# print(form)
|
# print(form)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# form.errors.append({'__all__': f'Ошибка: {str(e)}'})
|
# form.errors.append({'__all__': f'Ошибка: {str(e)}'})
|
||||||
print(str(e))
|
print(str(e))
|
||||||
|
|
||||||
html = render_to_string('v2/blocks/b_make_poster_order.html', Dict, request=request)
|
html = render_to_string(tpl, Dict, request=request)
|
||||||
return html
|
return html
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
from uuid import uuid1
|
from uuid import uuid1
|
||||||
@@ -345,7 +346,6 @@ def get_my_routes_ajax(request):
|
|||||||
|
|
||||||
|
|
||||||
def create_or_change_route_ajax(request, route_id=None):
|
def create_or_change_route_ajax(request, route_id=None):
|
||||||
from ReferenceDataApp.models import Airport, City
|
|
||||||
|
|
||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
raise Http404
|
raise Http404
|
||||||
@@ -358,12 +358,24 @@ def create_or_change_route_ajax(request, route_id=None):
|
|||||||
Dict = {}
|
Dict = {}
|
||||||
route_old_Dict = None
|
route_old_Dict = None
|
||||||
|
|
||||||
|
owner_type = None
|
||||||
|
tpl_form_by_owner_type = 'v2/forms/f_make_poster_order.html'
|
||||||
|
tpl_block_by_owner_type = 'v2/blocks/b_make_poster_order.html'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
data = request.POST
|
data = request.POST
|
||||||
if not data:
|
if not data:
|
||||||
data = json.loads(request.body)
|
data = json.loads(request.body)
|
||||||
|
|
||||||
|
|
||||||
|
if 'owner_type' in data and data['owner_type']:
|
||||||
|
owner_type = data['owner_type']
|
||||||
|
|
||||||
|
if owner_type == 'mover':
|
||||||
|
tpl_form_by_owner_type = 'v2/forms/f_make_mover_order.html'
|
||||||
|
tpl_block_by_owner_type = 'v2/blocks/b_make_mover_order.html'
|
||||||
|
|
||||||
route = None
|
route = None
|
||||||
if route_id:
|
if route_id:
|
||||||
route = Route.objects.get(id=route_id)
|
route = Route.objects.get(id=route_id)
|
||||||
@@ -379,15 +391,15 @@ def create_or_change_route_ajax(request, route_id=None):
|
|||||||
form.initial = form.cleaned_data
|
form.initial = form.cleaned_data
|
||||||
Dict.update({
|
Dict.update({
|
||||||
'form': form,
|
'form': form,
|
||||||
'owner_type': data['owner_type'],
|
'owner_type': owner_type,
|
||||||
})
|
})
|
||||||
|
|
||||||
html = render_to_string('v2/forms/f_make_poster_order.html', Dict, request=request)
|
html = render_to_string(tpl_form_by_owner_type, Dict, request=request)
|
||||||
return JsonResponse({'html': html}, status=400)
|
return JsonResponse({'html': html}, status=400)
|
||||||
|
|
||||||
obj = form.save(commit=False)
|
obj = form.save(commit=False)
|
||||||
if 'owner_type' in data and data['owner_type']:
|
if owner_type:
|
||||||
obj.owner_type = data['owner_type']
|
obj.owner_type = owner_type
|
||||||
|
|
||||||
# if obj.from_address_point:
|
# if obj.from_address_point:
|
||||||
# obj.from_city = get_city_by_type_transport_and_address_point(obj.type_transport, obj.from_address_point)
|
# obj.from_city = get_city_by_type_transport_and_address_point(obj.type_transport, obj.from_address_point)
|
||||||
@@ -420,8 +432,7 @@ def create_or_change_route_ajax(request, route_id=None):
|
|||||||
if 'errors' in routes_Dict:
|
if 'errors' in routes_Dict:
|
||||||
form.errors.update(routes_Dict['errors'])
|
form.errors.update(routes_Dict['errors'])
|
||||||
Dict.update({'form': form})
|
Dict.update({'form': form})
|
||||||
html = render_to_string(
|
html = render_to_string(tpl_form_by_owner_type, Dict, request=request)
|
||||||
'v2/forms/f_make_poster_order.html', Dict, request=request)
|
|
||||||
return JsonResponse({'html': html}, status=400)
|
return JsonResponse({'html': html}, status=400)
|
||||||
|
|
||||||
html = render_to_string('blocks/profile/b_my_routes.html', routes_Dict, request=request)
|
html = render_to_string('blocks/profile/b_my_routes.html', routes_Dict, request=request)
|
||||||
@@ -444,5 +455,5 @@ def create_or_change_route_ajax(request, route_id=None):
|
|||||||
}
|
}
|
||||||
# Dict = {'form': errors_Dict}
|
# Dict = {'form': errors_Dict}
|
||||||
Dict.update({'form': errors_Dict})
|
Dict.update({'form': errors_Dict})
|
||||||
html = render_to_string('v2/blocks/b_make_poster_order.html', Dict, request=request)
|
html = render_to_string(tpl_block_by_owner_type, Dict, request=request)
|
||||||
return JsonResponse({'html': html}, status=400)
|
return JsonResponse({'html': html}, status=400)
|
||||||
Reference in New Issue
Block a user