From 34ef5311adbd7459cbe95ac486ccc0b14b296267 Mon Sep 17 00:00:00 2001 From: Lymar Volodymyr Date: Wed, 5 Jun 2024 19:51:31 +0200 Subject: [PATCH 01/11] Refactor City model, fix tests, script --- clients/tests/conftest.py | 1 - logistics/admin.py | 8 +++--- logistics/constants.py | 11 -------- ...que_together_alter_city_region_and_more.py | 26 +++++++++++++++++++ logistics/models.py | 12 +++------ logistics/tests/conftest.py | 2 +- scripts/faker_script.py | 1 - 7 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 logistics/migrations/0002_alter_city_unique_together_alter_city_region_and_more.py diff --git a/clients/tests/conftest.py b/clients/tests/conftest.py index 8369409..01c4a27 100644 --- a/clients/tests/conftest.py +++ b/clients/tests/conftest.py @@ -18,7 +18,6 @@ def destination_city_object(faker): id=faker.pyint(), city=faker.city(), region=faker.pystr(), - federal_district=faker.pystr(), ) diff --git a/logistics/admin.py b/logistics/admin.py index f45cf6e..ed31354 100644 --- a/logistics/admin.py +++ b/logistics/admin.py @@ -5,12 +5,12 @@ @admin.register(City) class CityAdmin(admin.ModelAdmin): - list_display = ["city", "region", "federal_district"] - list_display_links = ["city", "region", "federal_district"] + list_display = ["city", "region"] + list_display_links = ["city", "region"] ordering = ["city"] list_per_page = 20 - search_fields = ["city", "region", "federal_district"] - list_filter = ["city", "region", "federal_district"] + search_fields = ["city", "region"] + list_filter = ["city", "region"] @admin.register(RailwayStation) diff --git a/logistics/constants.py b/logistics/constants.py index 7ae0d5e..34cb73b 100644 --- a/logistics/constants.py +++ b/logistics/constants.py @@ -22,7 +22,6 @@ ("Волгоград", "Новый Рогачик"), ] - FACTORY_BRANCH = [ ("Курск", "Московская ж/д"), ("Оскол", "Юго-Восточная ж/д"), @@ -59,13 +58,3 @@ ("ЗЖД", "Забайкальская ж/д"), ("ДВЖД", "Дальневосточная ж/д"), ] - -FED_DISCTRICT = [ - ("ЦФО", "Центральный федеральный округ"), - ("СЗФО", "Северо-Западный федеральный округ"), - ("ЮФО", "Южный федеральный округ"), - ("ПФО", "Приволжский федеральный округ"), - ("УФО", "Уральский федеральный округ"), - ("СФО", "Сибирский федеральный округ"), - ("ДВФО", "Дальневосточный федеральный округ"), -] diff --git a/logistics/migrations/0002_alter_city_unique_together_alter_city_region_and_more.py b/logistics/migrations/0002_alter_city_unique_together_alter_city_region_and_more.py new file mode 100644 index 0000000..f63ff44 --- /dev/null +++ b/logistics/migrations/0002_alter_city_unique_together_alter_city_region_and_more.py @@ -0,0 +1,26 @@ +# Generated by Django 5.0.6 on 2024-06-05 17:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('logistics', '0001_initial'), + ] + + operations = [ + migrations.AlterUniqueTogether( + name='city', + unique_together={('city', 'region')}, + ), + migrations.AlterField( + model_name='city', + name='region', + field=models.CharField(max_length=100, verbose_name='Регион'), + ), + migrations.RemoveField( + model_name='city', + name='federal_district', + ), + ] diff --git a/logistics/models.py b/logistics/models.py index 0b29822..0a68204 100644 --- a/logistics/models.py +++ b/logistics/models.py @@ -1,6 +1,6 @@ from django.db import models -from .constants import BRANCHES, FED_DISCTRICT +from .constants import BRANCHES class City(models.Model): @@ -12,20 +12,14 @@ class City(models.Model): region = models.CharField( max_length=100, blank=False, - verbose_name="Субъект федерации", - ) - federal_district = models.CharField( - max_length=100, - blank=False, - verbose_name="Федеральный округ", - choices=FED_DISCTRICT, + verbose_name="Регион", ) class Meta: verbose_name = "Населенный пункт" verbose_name_plural = "Населенные пункты" ordering = ["city"] - unique_together = ["city", "region", "federal_district"] + unique_together = ["city", "region"] def __str__(self) -> str: return f"{self.city}, {self.region}" diff --git a/logistics/tests/conftest.py b/logistics/tests/conftest.py index f0663b4..6f174c4 100644 --- a/logistics/tests/conftest.py +++ b/logistics/tests/conftest.py @@ -33,5 +33,5 @@ def tripsrailway_object(railwaystation_object, faker): @pytest.fixture def city_object(faker): return City.objects.create( - city=faker.pystr(), region=faker.pystr(), federal_district=faker.pystr() + city=faker.pystr(), region=faker.pystr() ) diff --git a/scripts/faker_script.py b/scripts/faker_script.py index 3cf85f1..66aa43c 100644 --- a/scripts/faker_script.py +++ b/scripts/faker_script.py @@ -78,7 +78,6 @@ def create_city(n): City.objects.create( city=fake.city(), region=fake.region(), - federal_district=choice(federal_districts), ) From 0b64847ef84441124b282f0c6fddcc63edbd7e01 Mon Sep 17 00:00:00 2001 From: Lymar Volodymyr Date: Wed, 5 Jun 2024 19:53:40 +0200 Subject: [PATCH 02/11] fix script --- scripts/faker_script.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/faker_script.py b/scripts/faker_script.py index 66aa43c..9f00ed2 100644 --- a/scripts/faker_script.py +++ b/scripts/faker_script.py @@ -64,16 +64,6 @@ def create_director_position(): # Создаем случайные названия городов def create_city(n): - federal_districts = [ - "Центральный федеральный округ", - "Северо-Западный федеральный округ", - "Южный федеральный округ", - "Северо-Кавказский федеральный округ", - "Приволжский федеральный округ", - "Уральский федеральный округ", - "Сибирский федеральный округ", - "Дальневосточный федеральный округ", - ] for _ in range(n): City.objects.create( city=fake.city(), From e49ade60b7181b4060b23f4926cf7b79fc8efae0 Mon Sep 17 00:00:00 2001 From: Lymar Volodymyr Date: Thu, 6 Jun 2024 20:59:08 +0200 Subject: [PATCH 03/11] added factory serializer --- goods/serializers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/goods/serializers.py b/goods/serializers.py index a1ed05b..a89ae3b 100644 --- a/goods/serializers.py +++ b/goods/serializers.py @@ -1,5 +1,6 @@ from rest_framework import serializers -from .models import Product + +from .models import Product, Factory class GoodsSerializer(serializers.ModelSerializer[Product]): @@ -10,3 +11,9 @@ class GoodsSerializer(serializers.ModelSerializer[Product]): class Meta: model = Product fields = "__all__" + + +class FactorySerializer(serializers.ModelSerializer[Factory]): + class Meta: + model = Factory + fields = "__all__" From 2aff96b59c35847cddab72da7bffc93813dc4626 Mon Sep 17 00:00:00 2001 From: Lymar Volodymyr Date: Thu, 6 Jun 2024 20:59:37 +0200 Subject: [PATCH 04/11] Added list factory url, view --- goods/urls.py | 7 +++++-- goods/views.py | 11 +++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/goods/urls.py b/goods/urls.py index aea1153..0f9f3a5 100644 --- a/goods/urls.py +++ b/goods/urls.py @@ -1,9 +1,12 @@ from django.urls import include, path from rest_framework import routers -from .views import GoodsViewSet +from .views import GoodsViewSet, FactoryListAPIView router = routers.SimpleRouter() router.register(r"goods", GoodsViewSet) -urlpatterns = [path("", include(router.urls))] +urlpatterns = [ + path("", include(router.urls)), + path("factories/", FactoryListAPIView.as_view(), name="factory-list") +] diff --git a/goods/views.py b/goods/views.py index 9e55029..cc1d6ff 100644 --- a/goods/views.py +++ b/goods/views.py @@ -1,9 +1,10 @@ from django.core.cache import cache +from rest_framework import generics from rest_framework import viewsets from rest_framework.permissions import IsAuthenticated -from .models import Product -from .serializers import GoodsSerializer +from .models import Product, Factory +from .serializers import GoodsSerializer, FactorySerializer class GoodsViewSet(viewsets.ModelViewSet[Product]): @@ -19,3 +20,9 @@ def get_queryset(self): goods = super().get_queryset() cache.set("goods_list", goods, 60 * 15) return goods + + +class FactoryListAPIView(generics.ListAPIView[Factory]): + queryset = Factory.objects.all() + serializer_class = FactorySerializer + permission_classes = (IsAuthenticated,) From 24310bc406e438c9c3ad09d1b3197bbb078b32c8 Mon Sep 17 00:00:00 2001 From: Lymar Volodymyr Date: Fri, 7 Jun 2024 19:45:24 +0200 Subject: [PATCH 05/11] Refactor: Move Factory model to logistics app and update ForeignKey references --- goods/admin.py | 37 +---------------- goods/migrations/0002_auto_20240607_2030.py | 15 +++++++ .../migrations/0003_alter_package_factory.py | 20 +++++++++ goods/models.py | 41 +------------------ goods/serializers.py | 8 +--- goods/urls.py | 3 +- goods/views.py | 11 +---- logistics/admin.py | 37 ++++++++++++++++- logistics/migrations/0003_factory.py | 32 +++++++++++++++ logistics/models.py | 37 +++++++++++++++++ logistics/serializers.py | 8 +++- logistics/tests/conftest.py | 4 +- logistics/urls.py | 6 ++- logistics/views.py | 10 ++++- makedoc/services.py | 4 +- scripts/faker_script.py | 4 +- 16 files changed, 173 insertions(+), 104 deletions(-) create mode 100644 goods/migrations/0002_auto_20240607_2030.py create mode 100644 goods/migrations/0003_alter_package_factory.py create mode 100644 logistics/migrations/0003_factory.py diff --git a/goods/admin.py b/goods/admin.py index 8962557..b3dc9a7 100644 --- a/goods/admin.py +++ b/goods/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from .models import Brand, Factory, Flour, Package, Product +from .models import Brand, Flour, Package, Product @admin.register(Product) @@ -28,41 +28,6 @@ class Meta: unique_together = [("flour_name", "brand", "package")] -@admin.register(Factory) -class FactoryAdmin(admin.ModelAdmin): - list_display = [ - "full_name", - "full_address", - "departure_city", - "departure_station_branch", - "departure_station_id", - "departure_station_name", - ] - list_display_links = [ - "full_name", - "full_address", - "departure_city", - "departure_station_branch", - "departure_station_id", - "departure_station_name", - ] - ordering = ["full_name"] - list_per_page = 10 - search_fields = [ - "full_name", - "full_address", - "departure_city", - "departure_station_branch", - "departure_station_id", - "departure_station_name", - ] - - class Meta: - verbose_name = "Предприятие" - verbose_name_plural = "Предприятия" - ordering = ["full_name"] - - @admin.register(Flour) class FlourAdmin(admin.ModelAdmin): list_display = ["flour_name"] diff --git a/goods/migrations/0002_auto_20240607_2030.py b/goods/migrations/0002_auto_20240607_2030.py new file mode 100644 index 0000000..318186a --- /dev/null +++ b/goods/migrations/0002_auto_20240607_2030.py @@ -0,0 +1,15 @@ +# Generated by Django 4.2 on 2024-06-07 17:30 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ('goods', '0001_initial'), + ] + + operations = [ + migrations.DeleteModel( + name='Factory', + ), + ] diff --git a/goods/migrations/0003_alter_package_factory.py b/goods/migrations/0003_alter_package_factory.py new file mode 100644 index 0000000..d6ecb8b --- /dev/null +++ b/goods/migrations/0003_alter_package_factory.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2 on 2024-06-07 17:35 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('logistics', '0003_factory'), + ('goods', '0002_auto_20240607_2030'), + ] + + operations = [ + migrations.AlterField( + model_name='package', + name='factory', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='logistics.factory'), + ), + ] diff --git a/goods/models.py b/goods/models.py index e649903..5dc0999 100644 --- a/goods/models.py +++ b/goods/models.py @@ -1,6 +1,6 @@ from django.db import models -from logistics.constants import BRANCHES +from logistics.models import Factory class Product(models.Model): @@ -49,7 +49,7 @@ def __str__(self) -> str: class Package(models.Model): package = models.IntegerField(verbose_name="Тара") - factory = models.ForeignKey("Factory", on_delete=models.PROTECT) + factory = models.ForeignKey(Factory, on_delete=models.PROTECT) pallet_weight = models.PositiveIntegerField(verbose_name="Вес на паллете") class Meta: @@ -60,40 +60,3 @@ class Meta: def __str__(self) -> str: return f"{self.package} кг, {self.factory}" - - -class Factory(models.Model): - full_name = models.CharField( - max_length=100, blank=False, verbose_name="Полное название предприятия" - ) - short_name = models.CharField( - max_length=100, blank=False, verbose_name="Краткое название предприятия" - ) - full_address = models.CharField(max_length=100, blank=False, verbose_name="Адрес предприятия") - departure_city = models.CharField( - max_length=100, - blank=False, - verbose_name="Город отправления", - ) - departure_station_branch = models.CharField( - max_length=100, blank=False, verbose_name="Ветка ж/д стации", choices=BRANCHES - ) - departure_station_id = models.PositiveIntegerField(verbose_name="Код ж/д стации") - departure_station_name = models.CharField( - max_length=100, blank=False, verbose_name="Ж/Д станция" - ) - - class Meta: - verbose_name = "Предприятие" - verbose_name_plural = "Предприятия" - ordering = ["-full_name"] - unique_together = [ - ( - "full_name", - "short_name", - "full_address", - ) - ] - - def __str__(self) -> str: - return self.full_name diff --git a/goods/serializers.py b/goods/serializers.py index a89ae3b..cecf80f 100644 --- a/goods/serializers.py +++ b/goods/serializers.py @@ -1,6 +1,6 @@ from rest_framework import serializers -from .models import Product, Factory +from .models import Product class GoodsSerializer(serializers.ModelSerializer[Product]): @@ -11,9 +11,3 @@ class GoodsSerializer(serializers.ModelSerializer[Product]): class Meta: model = Product fields = "__all__" - - -class FactorySerializer(serializers.ModelSerializer[Factory]): - class Meta: - model = Factory - fields = "__all__" diff --git a/goods/urls.py b/goods/urls.py index 0f9f3a5..5294d32 100644 --- a/goods/urls.py +++ b/goods/urls.py @@ -1,12 +1,11 @@ from django.urls import include, path from rest_framework import routers -from .views import GoodsViewSet, FactoryListAPIView +from .views import GoodsViewSet router = routers.SimpleRouter() router.register(r"goods", GoodsViewSet) urlpatterns = [ path("", include(router.urls)), - path("factories/", FactoryListAPIView.as_view(), name="factory-list") ] diff --git a/goods/views.py b/goods/views.py index cc1d6ff..9e55029 100644 --- a/goods/views.py +++ b/goods/views.py @@ -1,10 +1,9 @@ from django.core.cache import cache -from rest_framework import generics from rest_framework import viewsets from rest_framework.permissions import IsAuthenticated -from .models import Product, Factory -from .serializers import GoodsSerializer, FactorySerializer +from .models import Product +from .serializers import GoodsSerializer class GoodsViewSet(viewsets.ModelViewSet[Product]): @@ -20,9 +19,3 @@ def get_queryset(self): goods = super().get_queryset() cache.set("goods_list", goods, 60 * 15) return goods - - -class FactoryListAPIView(generics.ListAPIView[Factory]): - queryset = Factory.objects.all() - serializer_class = FactorySerializer - permission_classes = (IsAuthenticated,) diff --git a/logistics/admin.py b/logistics/admin.py index ed31354..05d0b94 100644 --- a/logistics/admin.py +++ b/logistics/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from .models import City, RailwayStation, TripAuto, TripRailway +from .models import City, RailwayStation, TripAuto, TripRailway, Factory @admin.register(City) @@ -47,3 +47,38 @@ class RwAdmin(admin.ModelAdmin): list_per_page = 20 search_fields = ["departure_station_name", "destination_station_name"] list_filter = ["departure_station_name", "destination_station_name"] + + +@admin.register(Factory) +class FactoryAdmin(admin.ModelAdmin): + list_display = [ + "full_name", + "full_address", + "departure_city", + "departure_station_branch", + "departure_station_id", + "departure_station_name", + ] + list_display_links = [ + "full_name", + "full_address", + "departure_city", + "departure_station_branch", + "departure_station_id", + "departure_station_name", + ] + ordering = ["full_name"] + list_per_page = 10 + search_fields = [ + "full_name", + "full_address", + "departure_city", + "departure_station_branch", + "departure_station_id", + "departure_station_name", + ] + + class Meta: + verbose_name = "Предприятие" + verbose_name_plural = "Предприятия" + ordering = ["full_name"] diff --git a/logistics/migrations/0003_factory.py b/logistics/migrations/0003_factory.py new file mode 100644 index 0000000..0766b5b --- /dev/null +++ b/logistics/migrations/0003_factory.py @@ -0,0 +1,32 @@ +# Generated by Django 4.2 on 2024-06-07 17:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('logistics', '0002_alter_city_unique_together_alter_city_region_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='Factory', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('full_name', models.CharField(max_length=100, verbose_name='Полное название предприятия')), + ('short_name', models.CharField(max_length=100, verbose_name='Краткое название предприятия')), + ('full_address', models.CharField(max_length=100, verbose_name='Адрес предприятия')), + ('departure_city', models.CharField(max_length=100, verbose_name='Город отправления')), + ('departure_station_branch', models.CharField(choices=[('ОЖД', 'Октябрьская ж/д'), ('КаЖД', 'Калининградская ж/д'), ('МЖД', 'Московская ж/д'), ('ГЖД', 'Горьковская ж/д'), ('СеЖД', 'Северная ж/д'), ('СКЖД', 'Северо-Кавказская ж/д'), ('ЮВЖД', 'Юго-Восточная ж/д'), ('ПЖД', 'Приволжская ж/д'), ('КуЖД', 'Куйбышевская ж/д'), ('СвЖД', 'Свердловская ж/д'), ('ЮУЖД', 'Южно-Уральская ж/д'), ('ЗСЖД', 'Западно-Сибирская ж/д'), ('КЖД', 'Красноярская ж/д'), ('ВСЖД', 'Восточно-Сибирская ж/д'), ('ЗЖД', 'Забайкальская ж/д'), ('ДВЖД', 'Дальневосточная ж/д')], max_length=100, verbose_name='Ветка ж/д стации')), + ('departure_station_id', models.PositiveIntegerField(verbose_name='Код ж/д стации')), + ('departure_station_name', models.CharField(max_length=100, verbose_name='Ж/Д станция')), + ], + options={ + 'verbose_name': 'Предприятие', + 'verbose_name_plural': 'Предприятия', + 'ordering': ['-full_name'], + 'unique_together': {('full_name', 'short_name', 'full_address')}, + }, + ), + ] diff --git a/logistics/models.py b/logistics/models.py index 0a68204..a41b929 100644 --- a/logistics/models.py +++ b/logistics/models.py @@ -102,3 +102,40 @@ class Meta: def __str__(self) -> str: return f"{self.departure_station_name} - {self.destination_station_name}: {self.cost_per_tonn_rw} руб./тн" # noqa 501 + + +class Factory(models.Model): + full_name = models.CharField( + max_length=100, blank=False, verbose_name="Полное название предприятия" + ) + short_name = models.CharField( + max_length=100, blank=False, verbose_name="Краткое название предприятия" + ) + full_address = models.CharField(max_length=100, blank=False, verbose_name="Адрес предприятия") + departure_city = models.CharField( + max_length=100, + blank=False, + verbose_name="Город отправления", + ) + departure_station_branch = models.CharField( + max_length=100, blank=False, verbose_name="Ветка ж/д стации", choices=BRANCHES + ) + departure_station_id = models.PositiveIntegerField(verbose_name="Код ж/д стации") + departure_station_name = models.CharField( + max_length=100, blank=False, verbose_name="Ж/Д станция" + ) + + class Meta: + verbose_name = "Предприятие" + verbose_name_plural = "Предприятия" + ordering = ["-full_name"] + unique_together = [ + ( + "full_name", + "short_name", + "full_address", + ) + ] + + def __str__(self) -> str: + return self.full_name diff --git a/logistics/serializers.py b/logistics/serializers.py index f2f30ee..aa215e3 100644 --- a/logistics/serializers.py +++ b/logistics/serializers.py @@ -1,6 +1,6 @@ from rest_framework import serializers -from .models import City, RailwayStation, TripAuto, TripRailway +from .models import City, RailwayStation, TripAuto, TripRailway, Factory class CitySerializer(serializers.ModelSerializer[City]): @@ -31,3 +31,9 @@ class TripRailwaySerializer(serializers.ModelSerializer[TripRailway]): class Meta: model = TripRailway fields = "__all__" + + +class FactorySerializer(serializers.ModelSerializer[Factory]): + class Meta: + model = Factory + fields = "__all__" diff --git a/logistics/tests/conftest.py b/logistics/tests/conftest.py index 6f174c4..97d45bc 100644 --- a/logistics/tests/conftest.py +++ b/logistics/tests/conftest.py @@ -32,6 +32,4 @@ def tripsrailway_object(railwaystation_object, faker): @pytest.fixture def city_object(faker): - return City.objects.create( - city=faker.pystr(), region=faker.pystr() - ) + return City.objects.create(city=faker.pystr(), region=faker.pystr()) diff --git a/logistics/urls.py b/logistics/urls.py index 830fc15..b9588bb 100644 --- a/logistics/urls.py +++ b/logistics/urls.py @@ -6,6 +6,7 @@ RailwayStationViewSet, TripAutoViewSet, TripRailwayViewSet, + FactoryListAPIView, ) router = routers.SimpleRouter() @@ -14,4 +15,7 @@ router.register(r"stations", RailwayStationViewSet) router.register(r"rwtrip", TripRailwayViewSet) -urlpatterns = [path("", include(router.urls))] +urlpatterns = [ + path("", include(router.urls)), + path("factories/", FactoryListAPIView.as_view(), name="factory-list"), +] diff --git a/logistics/views.py b/logistics/views.py index bcf6e2b..11aa907 100644 --- a/logistics/views.py +++ b/logistics/views.py @@ -1,12 +1,14 @@ +from rest_framework import generics from rest_framework import viewsets from rest_framework.permissions import IsAuthenticated -from .models import City, RailwayStation, TripAuto, TripRailway +from .models import City, RailwayStation, TripAuto, TripRailway, Factory from .serializers import ( CitySerializer, RailwayStationSerializer, TripAutoSerializer, TripRailwaySerializer, + FactorySerializer, ) @@ -32,3 +34,9 @@ class TripRailwayViewSet(viewsets.ModelViewSet[TripRailway]): queryset = TripRailway.objects.all() serializer_class = TripRailwaySerializer permission_classes = (IsAuthenticated,) + + +class FactoryListAPIView(generics.ListAPIView[Factory]): + queryset = Factory.objects.all() + serializer_class = FactorySerializer + permission_classes = (IsAuthenticated,) diff --git a/makedoc/services.py b/makedoc/services.py index 4d79f3a..b5fc7d0 100644 --- a/makedoc/services.py +++ b/makedoc/services.py @@ -7,8 +7,8 @@ from openpyxl.styles import Alignment, Border, Font, Side from clients.models import Client -from goods.models import Factory, Product -from logistics.models import City, RailwayStation +from goods.models import Product +from logistics.models import City, RailwayStation, Factory from users.models import CustomUser morph = pymorphy3.MorphAnalyzer() diff --git a/scripts/faker_script.py b/scripts/faker_script.py index 9f00ed2..780fff5 100644 --- a/scripts/faker_script.py +++ b/scripts/faker_script.py @@ -3,8 +3,8 @@ from faker import Faker from clients.models import Client, DirectorPosition -from goods.models import Brand, Factory, Flour, Package, Product -from logistics.models import City, RailwayStation, TripAuto, TripRailway +from goods.models import Brand, Flour, Package, Product +from logistics.models import City, RailwayStation, TripAuto, TripRailway, Factory from users.models import CustomUser, Department, Position fake = Faker("ru_RU") From 10776c51639a91941410932b37d49be28548e5eb Mon Sep 17 00:00:00 2001 From: Lymar Volodymyr Date: Fri, 7 Jun 2024 20:24:36 +0200 Subject: [PATCH 06/11] Added caching for factories list --- logistics/views.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/logistics/views.py b/logistics/views.py index 11aa907..478934b 100644 --- a/logistics/views.py +++ b/logistics/views.py @@ -1,3 +1,4 @@ +from django.core.cache import cache from rest_framework import generics from rest_framework import viewsets from rest_framework.permissions import IsAuthenticated @@ -39,4 +40,14 @@ class TripRailwayViewSet(viewsets.ModelViewSet[TripRailway]): class FactoryListAPIView(generics.ListAPIView[Factory]): queryset = Factory.objects.all() serializer_class = FactorySerializer - permission_classes = (IsAuthenticated,) + + # permission_classes = (IsAuthenticated,) + + def get_queryset(self): + cached_factories = cache.get("factories_list") + if cached_factories: + return cached_factories + else: + factories = super().get_queryset() + cache.set("factories_list", factories, 60 * 30) + return factories From 6d79bbb8971f4ddd35d4765321e701bddedc8595 Mon Sep 17 00:00:00 2001 From: Lymar Volodymyr Date: Fri, 7 Jun 2024 20:32:54 +0200 Subject: [PATCH 07/11] fix views --- logistics/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/logistics/views.py b/logistics/views.py index 478934b..4fb2298 100644 --- a/logistics/views.py +++ b/logistics/views.py @@ -40,8 +40,7 @@ class TripRailwayViewSet(viewsets.ModelViewSet[TripRailway]): class FactoryListAPIView(generics.ListAPIView[Factory]): queryset = Factory.objects.all() serializer_class = FactorySerializer - - # permission_classes = (IsAuthenticated,) + permission_classes = (IsAuthenticated,) def get_queryset(self): cached_factories = cache.get("factories_list") From 57630facd1dd0a69dec46f4ee922129301f11b9f Mon Sep 17 00:00:00 2001 From: Lymar Volodymyr Date: Fri, 7 Jun 2024 22:27:14 +0200 Subject: [PATCH 08/11] Fix display client list, rw-station str method --- clients/serializers.py | 4 ++++ logistics/models.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clients/serializers.py b/clients/serializers.py index a56f89c..d47ea28 100644 --- a/clients/serializers.py +++ b/clients/serializers.py @@ -10,6 +10,10 @@ class Meta: class ClientSerializer(serializers.ModelSerializer[Client]): + director_position: serializers.CharField = serializers.CharField() + destination_city: serializers.CharField = serializers.CharField() + railway_station: serializers.CharField = serializers.CharField() + # Устанавливает текущего авторизованого пользователя в поле user user = serializers.HiddenField(default=serializers.CurrentUserDefault()) diff --git a/logistics/models.py b/logistics/models.py index a41b929..b49911d 100644 --- a/logistics/models.py +++ b/logistics/models.py @@ -74,7 +74,7 @@ class Meta: unique_together = ["station_name", "station_id"] def __str__(self) -> str: - return f"{self.station_name}, {self.station_branch}" + return f"{self.station_name}, {self.station_branch}, {self.station_id}" # Данные по логистике жд From 0004e4241f72cd70ae8fb4b56a78553a1b5fa581 Mon Sep 17 00:00:00 2001 From: Lymar Volodymyr Date: Fri, 7 Jun 2024 23:24:57 +0200 Subject: [PATCH 09/11] fix tests --- clients/serializers.py | 2 +- clients/tests/conftest.py | 37 ++++++++--------------- clients/tests/test_serializers_clients.py | 18 +++++------ logistics/tests/test_models_logistics.py | 2 +- 4 files changed, 22 insertions(+), 37 deletions(-) diff --git a/clients/serializers.py b/clients/serializers.py index d47ea28..461b37e 100644 --- a/clients/serializers.py +++ b/clients/serializers.py @@ -10,7 +10,7 @@ class Meta: class ClientSerializer(serializers.ModelSerializer[Client]): - director_position: serializers.CharField = serializers.CharField() + director_position = DirectorPositionSerializer() destination_city: serializers.CharField = serializers.CharField() railway_station: serializers.CharField = serializers.CharField() diff --git a/clients/tests/conftest.py b/clients/tests/conftest.py index 01c4a27..11765c4 100644 --- a/clients/tests/conftest.py +++ b/clients/tests/conftest.py @@ -9,56 +9,45 @@ @pytest.fixture def director_position_object(faker): - return DirectorPosition.objects.create(id=faker.pyint(), director_position=faker.pystr()) + return DirectorPosition.objects.create(director_position=faker.word()) @pytest.fixture def destination_city_object(faker): - return City.objects.create( - id=faker.pyint(), - city=faker.city(), - region=faker.pystr(), - ) + return City.objects.create(city=faker.city(), region=faker.word()) @pytest.fixture def railway_station_object(faker): - return RailwayStation.objects.create( - id=faker.pyint(), - station_name=faker.pystr(), - station_id=faker.pyint(), - station_branch=faker.pystr(), - ) + return RailwayStation.objects.create(station_name=faker.word(), station_branch=faker.word(), + station_id=faker.random_int()) @pytest.fixture -def clients_object( - director_position_object, destination_city_object, railway_station_object, user, faker -): +def clients_object(director_position_object, destination_city_object, railway_station_object, user, + faker): return Client.objects.create( - id=faker.pyint(), client_name=faker.company(), - contract_number=faker.pystr(), + contract_number=faker.word(), contract_date=faker.date(), director_position=director_position_object, director_name=faker.last_name(), destination_city=destination_city_object, railway_station=railway_station_object, receiver_name=faker.company(), - receiver_id=faker.pyint(), - receiver_okpo=faker.pyint(), + receiver_id=faker.random_int(), + receiver_okpo=faker.random_int(), receiver_adress=faker.address(), - special_marks=faker.pystr(), - last_application_number=faker.pystr(), + special_marks=faker.text(), + last_application_number=faker.word(), user=user, ) @pytest.fixture def user(faker): - return CustomUser.objects.create_user( - email=faker.email(), full_name=faker.name(), password=faker.password() - ) + return CustomUser.objects.create_user(email=faker.email(), full_name=faker.name(), + password=faker.password()) @pytest.fixture diff --git a/clients/tests/test_serializers_clients.py b/clients/tests/test_serializers_clients.py index cad6f8e..80d08b9 100644 --- a/clients/tests/test_serializers_clients.py +++ b/clients/tests/test_serializers_clients.py @@ -41,7 +41,7 @@ def test__client_serializer__create_object_valid_director_position( clients_object, ): serializer_data = ClientSerializer(clients_object).data - assert serializer_data["director_position"] == director_position_object.id + assert serializer_data["director_position"]["id"] == director_position_object.id @pytest.mark.django_db @@ -53,21 +53,17 @@ def test__client_serializer__create_object_valid_director_name( @pytest.mark.django_db -def test__client_serializer__create_object_valid_destination_city( - clients_object, - destination_city_object, -): +def test__client_serializer__create_object_valid_destination_city(clients_object, + destination_city_object): serializer_data = ClientSerializer(clients_object).data - assert serializer_data["destination_city"] == destination_city_object.id + assert serializer_data["destination_city"] == str(destination_city_object) @pytest.mark.django_db -def test__client_serializer__create_object_valid_railway_station( - clients_object, - railway_station_object, -): +def test__client_serializer__create_object_valid_railway_station(clients_object, + railway_station_object): serializer_data = ClientSerializer(clients_object).data - assert serializer_data["railway_station"] == railway_station_object.id + assert serializer_data["railway_station"] == str(railway_station_object) @pytest.mark.django_db diff --git a/logistics/tests/test_models_logistics.py b/logistics/tests/test_models_logistics.py index b013453..313a487 100644 --- a/logistics/tests/test_models_logistics.py +++ b/logistics/tests/test_models_logistics.py @@ -13,7 +13,7 @@ def test__tripsauto__return_valid_str(tripsauto_object): def test__railway_station__return_valid_str(railwaystation_object): assert ( str(railwaystation_object) - == f"{railwaystation_object.station_name}, {railwaystation_object.station_branch}" + == f"{railwaystation_object.station_name}, {railwaystation_object.station_branch}, {railwaystation_object.station_id}" ) From 56644feb3c964ea425b9f88c95910de48414adbb Mon Sep 17 00:00:00 2001 From: Lymar Volodymyr Date: Sat, 8 Jun 2024 10:32:18 +0200 Subject: [PATCH 10/11] Refactored URL structure --- clients/tests/conftest.py | 15 +++++++++------ clients/tests/test_serializers_clients.py | 10 ++++++---- goods/urls.py | 2 +- logistics/urls.py | 4 ++-- makedoc/serializers.py | 6 ++++-- makedoc/views.py | 5 +++-- melnichanka/urls.py | 6 +++--- 7 files changed, 28 insertions(+), 20 deletions(-) diff --git a/clients/tests/conftest.py b/clients/tests/conftest.py index 11765c4..64d198c 100644 --- a/clients/tests/conftest.py +++ b/clients/tests/conftest.py @@ -19,13 +19,15 @@ def destination_city_object(faker): @pytest.fixture def railway_station_object(faker): - return RailwayStation.objects.create(station_name=faker.word(), station_branch=faker.word(), - station_id=faker.random_int()) + return RailwayStation.objects.create( + station_name=faker.word(), station_branch=faker.word(), station_id=faker.random_int() + ) @pytest.fixture -def clients_object(director_position_object, destination_city_object, railway_station_object, user, - faker): +def clients_object( + director_position_object, destination_city_object, railway_station_object, user, faker +): return Client.objects.create( client_name=faker.company(), contract_number=faker.word(), @@ -46,8 +48,9 @@ def clients_object(director_position_object, destination_city_object, railway_st @pytest.fixture def user(faker): - return CustomUser.objects.create_user(email=faker.email(), full_name=faker.name(), - password=faker.password()) + return CustomUser.objects.create_user( + email=faker.email(), full_name=faker.name(), password=faker.password() + ) @pytest.fixture diff --git a/clients/tests/test_serializers_clients.py b/clients/tests/test_serializers_clients.py index 80d08b9..2181d4c 100644 --- a/clients/tests/test_serializers_clients.py +++ b/clients/tests/test_serializers_clients.py @@ -53,15 +53,17 @@ def test__client_serializer__create_object_valid_director_name( @pytest.mark.django_db -def test__client_serializer__create_object_valid_destination_city(clients_object, - destination_city_object): +def test__client_serializer__create_object_valid_destination_city( + clients_object, destination_city_object +): serializer_data = ClientSerializer(clients_object).data assert serializer_data["destination_city"] == str(destination_city_object) @pytest.mark.django_db -def test__client_serializer__create_object_valid_railway_station(clients_object, - railway_station_object): +def test__client_serializer__create_object_valid_railway_station( + clients_object, railway_station_object +): serializer_data = ClientSerializer(clients_object).data assert serializer_data["railway_station"] == str(railway_station_object) diff --git a/goods/urls.py b/goods/urls.py index 5294d32..484bff4 100644 --- a/goods/urls.py +++ b/goods/urls.py @@ -4,7 +4,7 @@ from .views import GoodsViewSet router = routers.SimpleRouter() -router.register(r"goods", GoodsViewSet) +router.register(r"", GoodsViewSet) urlpatterns = [ path("", include(router.urls)), diff --git a/logistics/urls.py b/logistics/urls.py index b9588bb..4b3691a 100644 --- a/logistics/urls.py +++ b/logistics/urls.py @@ -11,9 +11,9 @@ router = routers.SimpleRouter() router.register(r"city", CityViewSet) -router.register(r"autotrip", TripAutoViewSet) +router.register(r"auto", TripAutoViewSet) router.register(r"stations", RailwayStationViewSet) -router.register(r"rwtrip", TripRailwayViewSet) +router.register(r"rw", TripRailwayViewSet) urlpatterns = [ path("", include(router.urls)), diff --git a/makedoc/serializers.py b/makedoc/serializers.py index f6d53ae..a904bfc 100644 --- a/makedoc/serializers.py +++ b/makedoc/serializers.py @@ -1,13 +1,15 @@ +from typing import Any + from rest_framework import serializers -class OrderItemSerializer(serializers.Serializer): # type: ignore +class OrderItemSerializer(serializers.Serializer[Any]): product_id = serializers.IntegerField() quantity = serializers.IntegerField() discount = serializers.IntegerField(required=False, default=0) -class DataDocSerializer(serializers.Serializer): # type: ignore +class DataDocSerializer(serializers.Serializer[Any]): client_id = serializers.IntegerField() items = serializers.ListField(child=OrderItemSerializer()) factory_id = serializers.IntegerField() diff --git a/makedoc/views.py b/makedoc/views.py index aef42e6..4938e85 100644 --- a/makedoc/views.py +++ b/makedoc/views.py @@ -1,10 +1,11 @@ +from typing import Any + from django.http import HttpResponse from rest_framework import generics, status from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from makedoc.services import Documents - from .serializers import DataDocSerializer @@ -23,7 +24,7 @@ def create_docs(request): return HttpResponse("Документы сохранены") -class DataDocView(generics.GenericAPIView): # type: ignore +class DataDocView(generics.GenericAPIView[Any]): serializer_class = DataDocSerializer permission_classes = (IsAuthenticated,) diff --git a/melnichanka/urls.py b/melnichanka/urls.py index fa7f8bd..d94d887 100644 --- a/melnichanka/urls.py +++ b/melnichanka/urls.py @@ -33,9 +33,9 @@ [ path("users/", include("users.urls")), path("clients/", include("clients.urls")), - path("", include("logistics.urls")), - path("", include("goods.urls")), - path("", include("makedoc.urls")), + path("logistics/", include("logistics.urls")), + path("goods/", include("goods.urls")), + path("doc/", include("makedoc.urls")), ] ), ), From a532c4a14a555154b991f51e7b2f9ab25537d21c Mon Sep 17 00:00:00 2001 From: Lymar Volodymyr Date: Sat, 8 Jun 2024 10:44:00 +0200 Subject: [PATCH 11/11] Update docs schema --- docs/schema.json | 479 ++++++++++++++++++++++++++--------------------- 1 file changed, 270 insertions(+), 209 deletions(-) diff --git a/docs/schema.json b/docs/schema.json index 2a19d5f..4f17d75 100644 --- a/docs/schema.json +++ b/docs/schema.json @@ -5,9 +5,9 @@ info: description: ' Melnichanka is a web application designed to generate a package of documents required for shipment' paths: - /api/v1/autotrip/: + /api/v1/clients/: get: - operationId: v1_autotrip_list + operationId: v1_clients_list tags: - v1 security: @@ -19,23 +19,23 @@ paths: schema: type: array items: - $ref: '#/components/schemas/TripAuto' + $ref: '#/components/schemas/Client' description: '' post: - operationId: v1_autotrip_create + operationId: v1_clients_create tags: - v1 requestBody: content: application/json: schema: - $ref: '#/components/schemas/TripAuto' + $ref: '#/components/schemas/Client' application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/TripAuto' + $ref: '#/components/schemas/Client' multipart/form-data: schema: - $ref: '#/components/schemas/TripAuto' + $ref: '#/components/schemas/Client' required: true security: - jwtAuth: [] @@ -44,17 +44,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TripAuto' + $ref: '#/components/schemas/Client' description: '' - /api/v1/autotrip/{id}/: + /api/v1/clients/{id}/: get: - operationId: v1_autotrip_retrieve + operationId: v1_clients_retrieve parameters: - in: path name: id schema: type: integer - description: A unique integer value identifying this Перевозки авто. required: true tags: - v1 @@ -65,16 +64,15 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TripAuto' + $ref: '#/components/schemas/Client' description: '' put: - operationId: v1_autotrip_update + operationId: v1_clients_update parameters: - in: path name: id schema: type: integer - description: A unique integer value identifying this Перевозки авто. required: true tags: - v1 @@ -82,13 +80,13 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TripAuto' + $ref: '#/components/schemas/Client' application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/TripAuto' + $ref: '#/components/schemas/Client' multipart/form-data: schema: - $ref: '#/components/schemas/TripAuto' + $ref: '#/components/schemas/Client' required: true security: - jwtAuth: [] @@ -97,16 +95,15 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TripAuto' + $ref: '#/components/schemas/Client' description: '' patch: - operationId: v1_autotrip_partial_update + operationId: v1_clients_partial_update parameters: - in: path name: id schema: type: integer - description: A unique integer value identifying this Перевозки авто. required: true tags: - v1 @@ -114,13 +111,13 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/PatchedTripAuto' + $ref: '#/components/schemas/PatchedClient' application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/PatchedTripAuto' + $ref: '#/components/schemas/PatchedClient' multipart/form-data: schema: - $ref: '#/components/schemas/PatchedTripAuto' + $ref: '#/components/schemas/PatchedClient' security: - jwtAuth: [] responses: @@ -128,16 +125,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TripAuto' + $ref: '#/components/schemas/Client' description: '' + /api/v1/clients/delete/{id}/: delete: - operationId: v1_autotrip_destroy + operationId: v1_clients_delete_destroy parameters: - in: path name: id schema: type: integer - description: A unique integer value identifying this Перевозки авто. required: true tags: - v1 @@ -146,9 +143,9 @@ paths: responses: '204': description: No response body - /api/v1/city/: + /api/v1/clients/directorposition/: get: - operationId: v1_city_list + operationId: v1_clients_directorposition_list tags: - v1 security: @@ -160,23 +157,65 @@ paths: schema: type: array items: - $ref: '#/components/schemas/City' + $ref: '#/components/schemas/DirectorPosition' description: '' + /api/v1/doc/data/: post: - operationId: v1_city_create + operationId: v1_doc_data_create tags: - v1 requestBody: content: application/json: schema: - $ref: '#/components/schemas/City' + $ref: '#/components/schemas/DataDoc' application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/City' + $ref: '#/components/schemas/DataDoc' multipart/form-data: schema: - $ref: '#/components/schemas/City' + $ref: '#/components/schemas/DataDoc' + required: true + security: + - jwtAuth: [] + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DataDoc' + description: '' + /api/v1/goods/: + get: + operationId: v1_goods_list + tags: + - v1 + security: + - jwtAuth: [] + responses: + '200': + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Goods' + description: '' + post: + operationId: v1_goods_create + tags: + - v1 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Goods' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/Goods' + multipart/form-data: + schema: + $ref: '#/components/schemas/Goods' required: true security: - jwtAuth: [] @@ -185,17 +224,17 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/City' + $ref: '#/components/schemas/Goods' description: '' - /api/v1/city/{id}/: + /api/v1/goods/{id}/: get: - operationId: v1_city_retrieve + operationId: v1_goods_retrieve parameters: - in: path name: id schema: type: integer - description: A unique integer value identifying this Населенный пункт. + description: A unique integer value identifying this Товар. required: true tags: - v1 @@ -206,16 +245,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/City' + $ref: '#/components/schemas/Goods' description: '' put: - operationId: v1_city_update + operationId: v1_goods_update parameters: - in: path name: id schema: type: integer - description: A unique integer value identifying this Населенный пункт. + description: A unique integer value identifying this Товар. required: true tags: - v1 @@ -223,13 +262,13 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/City' + $ref: '#/components/schemas/Goods' application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/City' + $ref: '#/components/schemas/Goods' multipart/form-data: schema: - $ref: '#/components/schemas/City' + $ref: '#/components/schemas/Goods' required: true security: - jwtAuth: [] @@ -238,16 +277,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/City' + $ref: '#/components/schemas/Goods' description: '' patch: - operationId: v1_city_partial_update + operationId: v1_goods_partial_update parameters: - in: path name: id schema: type: integer - description: A unique integer value identifying this Населенный пункт. + description: A unique integer value identifying this Товар. required: true tags: - v1 @@ -255,13 +294,13 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/PatchedCity' + $ref: '#/components/schemas/PatchedGoods' application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/PatchedCity' + $ref: '#/components/schemas/PatchedGoods' multipart/form-data: schema: - $ref: '#/components/schemas/PatchedCity' + $ref: '#/components/schemas/PatchedGoods' security: - jwtAuth: [] responses: @@ -269,16 +308,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/City' + $ref: '#/components/schemas/Goods' description: '' delete: - operationId: v1_city_destroy + operationId: v1_goods_destroy parameters: - in: path name: id schema: type: integer - description: A unique integer value identifying this Населенный пункт. + description: A unique integer value identifying this Товар. required: true tags: - v1 @@ -287,9 +326,9 @@ paths: responses: '204': description: No response body - /api/v1/clients/: + /api/v1/logistics/auto/: get: - operationId: v1_clients_list + operationId: v1_logistics_auto_list tags: - v1 security: @@ -301,23 +340,23 @@ paths: schema: type: array items: - $ref: '#/components/schemas/Client' + $ref: '#/components/schemas/TripAuto' description: '' post: - operationId: v1_clients_create + operationId: v1_logistics_auto_create tags: - v1 requestBody: content: application/json: schema: - $ref: '#/components/schemas/Client' + $ref: '#/components/schemas/TripAuto' application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/Client' + $ref: '#/components/schemas/TripAuto' multipart/form-data: schema: - $ref: '#/components/schemas/Client' + $ref: '#/components/schemas/TripAuto' required: true security: - jwtAuth: [] @@ -326,16 +365,17 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Client' + $ref: '#/components/schemas/TripAuto' description: '' - /api/v1/clients/{id}/: + /api/v1/logistics/auto/{id}/: get: - operationId: v1_clients_retrieve + operationId: v1_logistics_auto_retrieve parameters: - in: path name: id schema: type: integer + description: A unique integer value identifying this Перевозки авто. required: true tags: - v1 @@ -346,15 +386,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Client' + $ref: '#/components/schemas/TripAuto' description: '' put: - operationId: v1_clients_update + operationId: v1_logistics_auto_update parameters: - in: path name: id schema: type: integer + description: A unique integer value identifying this Перевозки авто. required: true tags: - v1 @@ -362,13 +403,13 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Client' + $ref: '#/components/schemas/TripAuto' application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/Client' + $ref: '#/components/schemas/TripAuto' multipart/form-data: schema: - $ref: '#/components/schemas/Client' + $ref: '#/components/schemas/TripAuto' required: true security: - jwtAuth: [] @@ -377,15 +418,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Client' + $ref: '#/components/schemas/TripAuto' description: '' patch: - operationId: v1_clients_partial_update + operationId: v1_logistics_auto_partial_update parameters: - in: path name: id schema: type: integer + description: A unique integer value identifying this Перевозки авто. required: true tags: - v1 @@ -393,13 +435,13 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/PatchedClient' + $ref: '#/components/schemas/PatchedTripAuto' application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/PatchedClient' + $ref: '#/components/schemas/PatchedTripAuto' multipart/form-data: schema: - $ref: '#/components/schemas/PatchedClient' + $ref: '#/components/schemas/PatchedTripAuto' security: - jwtAuth: [] responses: @@ -407,16 +449,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Client' + $ref: '#/components/schemas/TripAuto' description: '' - /api/v1/clients/delete/{id}/: delete: - operationId: v1_clients_delete_destroy + operationId: v1_logistics_auto_destroy parameters: - in: path name: id schema: type: integer + description: A unique integer value identifying this Перевозки авто. required: true tags: - v1 @@ -425,9 +467,9 @@ paths: responses: '204': description: No response body - /api/v1/clients/directorposition/: + /api/v1/logistics/city/: get: - operationId: v1_clients_directorposition_list + operationId: v1_logistics_city_list tags: - v1 security: @@ -439,66 +481,23 @@ paths: schema: type: array items: - $ref: '#/components/schemas/DirectorPosition' - description: '' - /api/v1/data/: - post: - operationId: v1_data_create - tags: - - v1 - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/DataDoc' - application/x-www-form-urlencoded: - schema: - $ref: '#/components/schemas/DataDoc' - multipart/form-data: - schema: - $ref: '#/components/schemas/DataDoc' - required: true - security: - - jwtAuth: [] - - {} - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/DataDoc' - description: '' - /api/v1/goods/: - get: - operationId: v1_goods_list - tags: - - v1 - security: - - jwtAuth: [] - responses: - '200': - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Goods' + $ref: '#/components/schemas/City' description: '' post: - operationId: v1_goods_create + operationId: v1_logistics_city_create tags: - v1 requestBody: content: application/json: schema: - $ref: '#/components/schemas/Goods' + $ref: '#/components/schemas/City' application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/Goods' + $ref: '#/components/schemas/City' multipart/form-data: schema: - $ref: '#/components/schemas/Goods' + $ref: '#/components/schemas/City' required: true security: - jwtAuth: [] @@ -507,17 +506,17 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Goods' + $ref: '#/components/schemas/City' description: '' - /api/v1/goods/{id}/: + /api/v1/logistics/city/{id}/: get: - operationId: v1_goods_retrieve + operationId: v1_logistics_city_retrieve parameters: - in: path name: id schema: type: integer - description: A unique integer value identifying this Товар. + description: A unique integer value identifying this Населенный пункт. required: true tags: - v1 @@ -528,16 +527,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Goods' + $ref: '#/components/schemas/City' description: '' put: - operationId: v1_goods_update + operationId: v1_logistics_city_update parameters: - in: path name: id schema: type: integer - description: A unique integer value identifying this Товар. + description: A unique integer value identifying this Населенный пункт. required: true tags: - v1 @@ -545,13 +544,13 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Goods' + $ref: '#/components/schemas/City' application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/Goods' + $ref: '#/components/schemas/City' multipart/form-data: schema: - $ref: '#/components/schemas/Goods' + $ref: '#/components/schemas/City' required: true security: - jwtAuth: [] @@ -560,16 +559,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Goods' + $ref: '#/components/schemas/City' description: '' patch: - operationId: v1_goods_partial_update + operationId: v1_logistics_city_partial_update parameters: - in: path name: id schema: type: integer - description: A unique integer value identifying this Товар. + description: A unique integer value identifying this Населенный пункт. required: true tags: - v1 @@ -577,13 +576,13 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/PatchedGoods' + $ref: '#/components/schemas/PatchedCity' application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/PatchedGoods' + $ref: '#/components/schemas/PatchedCity' multipart/form-data: schema: - $ref: '#/components/schemas/PatchedGoods' + $ref: '#/components/schemas/PatchedCity' security: - jwtAuth: [] responses: @@ -591,16 +590,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Goods' + $ref: '#/components/schemas/City' description: '' delete: - operationId: v1_goods_destroy + operationId: v1_logistics_city_destroy parameters: - in: path name: id schema: type: integer - description: A unique integer value identifying this Товар. + description: A unique integer value identifying this Населенный пункт. required: true tags: - v1 @@ -609,9 +608,25 @@ paths: responses: '204': description: No response body - /api/v1/rwtrip/: + /api/v1/logistics/factories/: + get: + operationId: v1_logistics_factories_list + tags: + - v1 + security: + - jwtAuth: [] + responses: + '200': + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Factory' + description: '' + /api/v1/logistics/rw/: get: - operationId: v1_rwtrip_list + operationId: v1_logistics_rw_list tags: - v1 security: @@ -626,7 +641,7 @@ paths: $ref: '#/components/schemas/TripRailway' description: '' post: - operationId: v1_rwtrip_create + operationId: v1_logistics_rw_create tags: - v1 requestBody: @@ -650,9 +665,9 @@ paths: schema: $ref: '#/components/schemas/TripRailway' description: '' - /api/v1/rwtrip/{id}/: + /api/v1/logistics/rw/{id}/: get: - operationId: v1_rwtrip_retrieve + operationId: v1_logistics_rw_retrieve parameters: - in: path name: id @@ -672,7 +687,7 @@ paths: $ref: '#/components/schemas/TripRailway' description: '' put: - operationId: v1_rwtrip_update + operationId: v1_logistics_rw_update parameters: - in: path name: id @@ -704,7 +719,7 @@ paths: $ref: '#/components/schemas/TripRailway' description: '' patch: - operationId: v1_rwtrip_partial_update + operationId: v1_logistics_rw_partial_update parameters: - in: path name: id @@ -735,7 +750,7 @@ paths: $ref: '#/components/schemas/TripRailway' description: '' delete: - operationId: v1_rwtrip_destroy + operationId: v1_logistics_rw_destroy parameters: - in: path name: id @@ -750,9 +765,9 @@ paths: responses: '204': description: No response body - /api/v1/stations/: + /api/v1/logistics/stations/: get: - operationId: v1_stations_list + operationId: v1_logistics_stations_list tags: - v1 security: @@ -767,7 +782,7 @@ paths: $ref: '#/components/schemas/RailwayStation' description: '' post: - operationId: v1_stations_create + operationId: v1_logistics_stations_create tags: - v1 requestBody: @@ -791,9 +806,9 @@ paths: schema: $ref: '#/components/schemas/RailwayStation' description: '' - /api/v1/stations/{id}/: + /api/v1/logistics/stations/{id}/: get: - operationId: v1_stations_retrieve + operationId: v1_logistics_stations_retrieve parameters: - in: path name: id @@ -813,7 +828,7 @@ paths: $ref: '#/components/schemas/RailwayStation' description: '' put: - operationId: v1_stations_update + operationId: v1_logistics_stations_update parameters: - in: path name: id @@ -845,7 +860,7 @@ paths: $ref: '#/components/schemas/RailwayStation' description: '' patch: - operationId: v1_stations_partial_update + operationId: v1_logistics_stations_partial_update parameters: - in: path name: id @@ -876,7 +891,7 @@ paths: $ref: '#/components/schemas/RailwayStation' description: '' delete: - operationId: v1_stations_destroy + operationId: v1_logistics_stations_destroy parameters: - in: path name: id @@ -1251,15 +1266,10 @@ components: maxLength: 100 region: type: string - title: Субъект федерации + title: Регион maxLength: 100 - federal_district: - allOf: - - $ref: '#/components/schemas/FederalDistrictEnum' - title: Федеральный округ required: - city - - federal_district - id - region Client: @@ -1268,6 +1278,12 @@ components: id: type: integer readOnly: true + director_position: + $ref: '#/components/schemas/DirectorPosition' + destination_city: + type: string + railway_station: + type: string client_name: type: string title: Наименование организации @@ -1312,16 +1328,6 @@ components: type: string title: Номер приложения maxLength: 50 - director_position: - type: integer - title: Должность директора - destination_city: - type: integer - title: Город доставки - railway_station: - type: integer - nullable: true - title: ЖД станция required: - client_name - contract_date @@ -1330,6 +1336,7 @@ components: - director_name - director_position - id + - railway_station CustomUser: type: object properties: @@ -1405,6 +1412,42 @@ components: required: - department - id + DepartureStationBranchEnum: + enum: + - ОЖД + - КаЖД + - МЖД + - ГЖД + - СеЖД + - СКЖД + - ЮВЖД + - ПЖД + - КуЖД + - СвЖД + - ЮУЖД + - ЗСЖД + - КЖД + - ВСЖД + - ЗЖД + - ДВЖД + type: string + description: |- + * `ОЖД` - Октябрьская ж/д + * `КаЖД` - Калининградская ж/д + * `МЖД` - Московская ж/д + * `ГЖД` - Горьковская ж/д + * `СеЖД` - Северная ж/д + * `СКЖД` - Северо-Кавказская ж/д + * `ЮВЖД` - Юго-Восточная ж/д + * `ПЖД` - Приволжская ж/д + * `КуЖД` - Куйбышевская ж/д + * `СвЖД` - Свердловская ж/д + * `ЮУЖД` - Южно-Уральская ж/д + * `ЗСЖД` - Западно-Сибирская ж/д + * `КЖД` - Красноярская ж/д + * `ВСЖД` - Восточно-Сибирская ж/д + * `ЗЖД` - Забайкальская ж/д + * `ДВЖД` - Дальневосточная ж/д DirectorPosition: type: object properties: @@ -1425,24 +1468,50 @@ components: format: email required: - email - FederalDistrictEnum: - enum: - - ЦФО - - СЗФО - - ЮФО - - ПФО - - УФО - - СФО - - ДВФО - type: string - description: |- - * `ЦФО` - Центральный федеральный округ - * `СЗФО` - Северо-Западный федеральный округ - * `ЮФО` - Южный федеральный округ - * `ПФО` - Приволжский федеральный округ - * `УФО` - Уральский федеральный округ - * `СФО` - Сибирский федеральный округ - * `ДВФО` - Дальневосточный федеральный округ + Factory: + type: object + properties: + id: + type: integer + readOnly: true + full_name: + type: string + title: Полное название предприятия + maxLength: 100 + short_name: + type: string + title: Краткое название предприятия + maxLength: 100 + full_address: + type: string + title: Адрес предприятия + maxLength: 100 + departure_city: + type: string + title: Город отправления + maxLength: 100 + departure_station_branch: + allOf: + - $ref: '#/components/schemas/DepartureStationBranchEnum' + title: Ветка ж/д стации + departure_station_id: + type: integer + maximum: 2147483647 + minimum: 0 + title: Код ж/д стации + departure_station_name: + type: string + title: Ж/Д станция + maxLength: 100 + required: + - departure_city + - departure_station_branch + - departure_station_id + - departure_station_name + - full_address + - full_name + - id + - short_name Goods: type: object properties: @@ -1509,18 +1578,20 @@ components: maxLength: 100 region: type: string - title: Субъект федерации + title: Регион maxLength: 100 - federal_district: - allOf: - - $ref: '#/components/schemas/FederalDistrictEnum' - title: Федеральный округ PatchedClient: type: object properties: id: type: integer readOnly: true + director_position: + $ref: '#/components/schemas/DirectorPosition' + destination_city: + type: string + railway_station: + type: string client_name: type: string title: Наименование организации @@ -1565,16 +1636,6 @@ components: type: string title: Номер приложения maxLength: 50 - director_position: - type: integer - title: Должность директора - destination_city: - type: integer - title: Город доставки - railway_station: - type: integer - nullable: true - title: ЖД станция PatchedGoods: type: object properties: