From a40ae5d37d8f76619a24d9729c46ccf56d518e64 Mon Sep 17 00:00:00 2001 From: SDE Date: Tue, 14 Jan 2025 18:38:38 +0300 Subject: [PATCH] 2.1.15 change cargo_type and transport_type names --- RoutesApp/funcs.py | 2 +- RoutesApp/js_views.py | 5 ++-- ...e_cargo_type_alter_route_type_transport.py | 23 +++++++++++++++++++ .../migrations/0013_alter_route_cargo_type.py | 18 +++++++++++++++ RoutesApp/models.py | 12 +++++----- 5 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 RoutesApp/migrations/0012_alter_route_cargo_type_alter_route_type_transport.py create mode 100644 RoutesApp/migrations/0013_alter_route_cargo_type.py diff --git a/RoutesApp/funcs.py b/RoutesApp/funcs.py index 7034c36..14823ec 100644 --- a/RoutesApp/funcs.py +++ b/RoutesApp/funcs.py @@ -82,7 +82,7 @@ def get_profile_new_route_page_html(request, data): if data['owner_type'] == 'mover': tpl = 'v2/blocks/b_make_mover_order.html' - form.fields['type_transport'].choices = type_transport_choices[1:] + form.fields['type_transport'].choices = type_transport_choices[:-1] else: tpl = 'v2/blocks/b_make_poster_order.html' form.fields['type_transport'].choices = type_transport_choices diff --git a/RoutesApp/js_views.py b/RoutesApp/js_views.py index ff8e366..208a5b6 100644 --- a/RoutesApp/js_views.py +++ b/RoutesApp/js_views.py @@ -1,3 +1,4 @@ +import copy import json from copy import deepcopy @@ -357,9 +358,9 @@ def get_cargo_type_by_transport_type_ajax(request): if not data or not 'type_transport' in data: return JsonResponse({'html': 'недостаточно данных'}, status=400) - cargo_types = cargo_type_choices + cargo_types = copy.deepcopy(cargo_type_choices) if data['type_transport'] in ['avia']: - cargo_types = cargo_types[1:] + cargo_types = cargo_types[:2] + cargo_types[3:] return JsonResponse({'cargo_types': cargo_types}) diff --git a/RoutesApp/migrations/0012_alter_route_cargo_type_alter_route_type_transport.py b/RoutesApp/migrations/0012_alter_route_cargo_type_alter_route_type_transport.py new file mode 100644 index 0000000..daa7b94 --- /dev/null +++ b/RoutesApp/migrations/0012_alter_route_cargo_type_alter_route_type_transport.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.2 on 2025-01-14 18:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('RoutesApp', '0011_alter_route_from_address_point_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='route', + name='cargo_type', + field=models.CharField(choices=[('package', 'Посылка (до 30кг)'), ('letter', 'Письмо\\Документы'), ('passenger', 'Попутчик'), ('parcel', 'Бандероль (до 5кг)'), ('cargo', 'Груз (свыше 30 кг)')], default='parcel', verbose_name='Могу перевезти'), + ), + migrations.AlterField( + model_name='route', + name='type_transport', + field=models.CharField(blank=True, choices=[('road', 'Авто (любой наземный транспорт)'), ('avia', 'Авиа'), ('', 'Мне без разницы')], default='', verbose_name='Выберите способ перевозки'), + ), + ] diff --git a/RoutesApp/migrations/0013_alter_route_cargo_type.py b/RoutesApp/migrations/0013_alter_route_cargo_type.py new file mode 100644 index 0000000..6cff5fc --- /dev/null +++ b/RoutesApp/migrations/0013_alter_route_cargo_type.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.2 on 2025-01-14 18:30 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('RoutesApp', '0012_alter_route_cargo_type_alter_route_type_transport'), + ] + + operations = [ + migrations.AlterField( + model_name='route', + name='cargo_type', + field=models.CharField(choices=[('letter', 'Письмо\\Документы'), ('package', 'Посылка (до 30кг)'), ('passenger', 'Попутчик'), ('parcel', 'Бандероль (до 5кг)'), ('cargo', 'Груз (свыше 30 кг)')], default='parcel', verbose_name='Могу перевезти'), + ), + ] diff --git a/RoutesApp/models.py b/RoutesApp/models.py index e7a9f0f..431b2b2 100644 --- a/RoutesApp/models.py +++ b/RoutesApp/models.py @@ -5,9 +5,9 @@ from colorfield.fields import ColorField type_transport_choices = [ + ('road', _('Авто (любой наземный транспорт)')), + ('avia', _('Авиа')), ('', _('Мне без разницы')), - ('avia', _('Авиатранспорт')), - ('road', _('Наземный транспорт')) ] transfer_location_choices = ( @@ -17,11 +17,11 @@ transfer_location_choices = ( ) cargo_type_choices = ( - ('passenger', _('Пассажир')), - ('cargo', _('Груз (свыше 30 кг)')), - ('parcel', _('Бандероль (до 5кг)')), + ('letter', _('Письмо\Документы')), ('package', _('Посылка (до 30кг)')), - ('letter', _('Письмо\Документы')) + ('passenger', _('Попутчик')), + ('parcel', _('Бандероль (до 5кг)')), + ('cargo', _('Груз (свыше 30 кг)')), ) owner_type_choices = (