diff --git a/config_dev.env.example b/config_dev.env.example index dc66fbe57..43bfdc00b 100644 --- a/config_dev.env.example +++ b/config_dev.env.example @@ -159,8 +159,8 @@ ECO_COUNTER_LOG_LEVEL= MOBILITY_DATA_LOG_LEVEL= # Bicycle networks APP, default INFO BICYCLE_NETWORK_LOG_LEVEL= -# Street maintenance, default INFO -STREET_MAINTENANCE_LOG_LEVEL= +# Maintenance +MAINTENANCE_LOG_LEVEL=INFO # Settings needed for enabling Turku area: #ADDITIONAL_INSTALLED_APPS=smbackend_turku,ptv diff --git a/street_maintenance/README.md b/maintenance/README.md similarity index 91% rename from street_maintenance/README.md rename to maintenance/README.md index adc27f18e..08478af70 100644 --- a/street_maintenance/README.md +++ b/maintenance/README.md @@ -1,8 +1,9 @@ -# Street Maintenance history +# Maintenance history -Django app for importing and serving street maintenance data. +Django app for importing, processing and serving maintenance data. -## Importer +## Street maintenance history +### Importer Name: import_street_maintenance_history diff --git a/street_maintenance/tests/__init__.py b/maintenance/__init__.py similarity index 100% rename from street_maintenance/tests/__init__.py rename to maintenance/__init__.py diff --git a/street_maintenance/admin.py b/maintenance/admin.py similarity index 60% rename from street_maintenance/admin.py rename to maintenance/admin.py index 19154fd8d..80ee9fce5 100644 --- a/street_maintenance/admin.py +++ b/maintenance/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from street_maintenance.models import MaintenanceUnit, MaintenanceWork +from maintenance.models import MaintenanceUnit, MaintenanceWork admin.site.register(MaintenanceWork) admin.site.register(MaintenanceUnit) diff --git a/street_maintenance/api/serializers.py b/maintenance/api/serializers.py similarity index 95% rename from street_maintenance/api/serializers.py rename to maintenance/api/serializers.py index 6ae513acd..df17c89a9 100644 --- a/street_maintenance/api/serializers.py +++ b/maintenance/api/serializers.py @@ -3,7 +3,7 @@ from drf_spectacular.utils import extend_schema_field from rest_framework import serializers -from street_maintenance.models import GeometryHistory, MaintenanceUnit, MaintenanceWork +from maintenance.models import GeometryHistory, MaintenanceUnit, MaintenanceWork class GeometryHistorySerializer(serializers.ModelSerializer): diff --git a/street_maintenance/api/urls.py b/maintenance/api/urls.py similarity index 78% rename from street_maintenance/api/urls.py rename to maintenance/api/urls.py index 473e6e3c9..9edfae900 100644 --- a/street_maintenance/api/urls.py +++ b/maintenance/api/urls.py @@ -3,7 +3,7 @@ from . import views -app_name = "street_maintenance" +app_name = "maintenance" router = routers.DefaultRouter() router.register("active_events", views.ActiveEventsViewSet, basename="active_events") @@ -20,6 +20,5 @@ ) urlpatterns = [ - # re_path("^street_maintenance/active_events", ) - path("", include(router.urls), name="street_maintenance"), + path("", include(router.urls), name="maintenance"), ] diff --git a/maintenance/api/urls_street_maintenance.py b/maintenance/api/urls_street_maintenance.py new file mode 100644 index 000000000..f84e10801 --- /dev/null +++ b/maintenance/api/urls_street_maintenance.py @@ -0,0 +1,28 @@ +""" +Keep backward compatibility to street_maintenance API. +""" + +from django.urls import include, path +from rest_framework import routers + +from . import views + +app_name = "street_maintenance" + +router = routers.DefaultRouter() +router.register("active_events", views.ActiveEventsViewSet, basename="active_events") + +router.register( + "maintenance_works", views.MaintenanceWorkViewSet, basename="maintenance_works" +) +router.register( + "maintenance_units", views.MaintenanceUnitViewSet, basename="maintenance_units" +) + +router.register( + "geometry_history", views.GeometryHitoryViewSet, basename="geometry_history" +) + +urlpatterns = [ + path("", include(router.urls), name="street_maintenance"), +] diff --git a/street_maintenance/api/views.py b/maintenance/api/views.py similarity index 96% rename from street_maintenance/api/views.py rename to maintenance/api/views.py index 87f6f9cef..ef5fc6437 100644 --- a/street_maintenance/api/views.py +++ b/maintenance/api/views.py @@ -8,18 +8,18 @@ from rest_framework.exceptions import ParseError from rest_framework.pagination import PageNumberPagination -from street_maintenance.api.serializers import ( +from maintenance.api.serializers import ( ActiveEventSerializer, GeometryHistorySerializer, MaintenanceUnitSerializer, MaintenanceWorkSerializer, ) -from street_maintenance.management.commands.constants import ( +from maintenance.management.commands.constants import ( EVENT_CHOICES, PROVIDERS, START_DATE_TIME_FORMAT, ) -from street_maintenance.models import GeometryHistory, MaintenanceUnit, MaintenanceWork +from maintenance.models import GeometryHistory, MaintenanceUnit, MaintenanceWork EXAMPLE_TIME_FORMAT = "YYYY-MM-DD HH:MM:SS" EXAMPLE_TIME = "2022-09-18 10:00:00" @@ -133,7 +133,7 @@ def list(self, request): list=extend_schema( description="MaintananceUnit objets are the entities that creates the MaintenanceWorks. Every MaintenanceWork " "has a relation to a MaintenanceUnit. The type of the MaintenanceUnit can vary depending on the provider. It " - "can be a machine or a event", + "can be a machine or an event.", ), ) class MaintenanceUnitViewSet(viewsets.ReadOnlyModelViewSet): diff --git a/maintenance/apps.py b/maintenance/apps.py new file mode 100644 index 000000000..c386a4051 --- /dev/null +++ b/maintenance/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class MaintenanceConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "maintenance" diff --git a/street_maintenance/management/commands/constants.py b/maintenance/management/commands/constants.py similarity index 100% rename from street_maintenance/management/commands/constants.py rename to maintenance/management/commands/constants.py diff --git a/street_maintenance/management/commands/delete_street_maintenance_history.py b/maintenance/management/commands/delete_street_maintenance_history.py similarity index 94% rename from street_maintenance/management/commands/delete_street_maintenance_history.py rename to maintenance/management/commands/delete_street_maintenance_history.py index ec91b0193..c946b6db5 100644 --- a/street_maintenance/management/commands/delete_street_maintenance_history.py +++ b/maintenance/management/commands/delete_street_maintenance_history.py @@ -2,11 +2,11 @@ from django.core.management import BaseCommand -from street_maintenance.models import GeometryHistory, MaintenanceUnit +from maintenance.models import GeometryHistory, MaintenanceUnit from .constants import PROVIDERS -logger = logging.getLogger("mobility_data") +logger = logging.getLogger("maintenance") # Add deprecated provider name 'AUTORI' PROVIDERS.append("AUTORI") diff --git a/street_maintenance/management/commands/import_street_maintenance_history.py b/maintenance/management/commands/import_street_maintenance_history.py similarity index 97% rename from street_maintenance/management/commands/import_street_maintenance_history.py rename to maintenance/management/commands/import_street_maintenance_history.py index 2512840f1..db936b3b3 100644 --- a/street_maintenance/management/commands/import_street_maintenance_history.py +++ b/maintenance/management/commands/import_street_maintenance_history.py @@ -3,7 +3,7 @@ from django.core.management import BaseCommand -from street_maintenance.models import MaintenanceUnit, MaintenanceWork +from maintenance.models import MaintenanceUnit, MaintenanceWork from .constants import ( FETCH_SIZE, @@ -23,7 +23,7 @@ precalculate_geometry_history, ) -logger = logging.getLogger("street_maintenance") +logger = logging.getLogger("maintenance") class Command(BaseCommand): diff --git a/street_maintenance/management/commands/utils.py b/maintenance/management/commands/utils.py similarity index 99% rename from street_maintenance/management/commands/utils.py rename to maintenance/management/commands/utils.py index 0a7adec3e..b07189b9d 100644 --- a/street_maintenance/management/commands/utils.py +++ b/maintenance/management/commands/utils.py @@ -11,7 +11,7 @@ from django.contrib.gis.geos import LineString, Point from munigeo.models import AdministrativeDivision, AdministrativeDivisionGeometry -from street_maintenance.models import ( +from maintenance.models import ( DEFAULT_SRID, GeometryHistory, MaintenanceUnit, @@ -34,7 +34,7 @@ YIT, ) -logger = logging.getLogger("street_maintenance") +logger = logging.getLogger("maintenance") # In seconds MAX_WORK_LENGTH = 60 VALID_LINESTRING_MAX_POINT_DISTANCE = 0.01 diff --git a/maintenance/migrations/0001_initial.py b/maintenance/migrations/0001_initial.py new file mode 100644 index 000000000..ba551a92f --- /dev/null +++ b/maintenance/migrations/0001_initial.py @@ -0,0 +1,156 @@ +# Generated by Django 4.2.15 on 2024-09-17 07:26 + +import django.contrib.gis.db.models.fields +import django.contrib.postgres.fields +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="GeometryHistory", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("timestamp", models.DateTimeField()), + ( + "geometry", + django.contrib.gis.db.models.fields.GeometryField( + null=True, srid=4326 + ), + ), + ( + "coordinates", + django.contrib.postgres.fields.ArrayField( + base_field=django.contrib.postgres.fields.ArrayField( + base_field=models.FloatField(), size=None + ), + default=list, + size=None, + ), + ), + ( + "events", + django.contrib.postgres.fields.ArrayField( + base_field=models.CharField(max_length=64), + default=list, + size=None, + ), + ), + ( + "provider", + models.CharField( + choices=[ + ("INFRAROAD", "Infraroad"), + ("YIT", "YIT"), + ("KUNTEC", "Kuntec"), + ("DESTIA", "Destia"), + ], + max_length=16, + null=True, + ), + ), + ], + options={ + "ordering": ["-timestamp"], + }, + ), + migrations.CreateModel( + name="MaintenanceUnit", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("unit_id", models.CharField(max_length=64, null=True)), + ( + "provider", + models.CharField( + choices=[ + ("INFRAROAD", "Infraroad"), + ("YIT", "YIT"), + ("KUNTEC", "Kuntec"), + ("DESTIA", "Destia"), + ], + max_length=16, + null=True, + ), + ), + ( + "names", + django.contrib.postgres.fields.ArrayField( + base_field=models.CharField(max_length=64), + default=list, + size=None, + ), + ), + ], + ), + migrations.CreateModel( + name="MaintenanceWork", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "geometry", + django.contrib.gis.db.models.fields.GeometryField( + null=True, srid=4326 + ), + ), + ( + "events", + django.contrib.postgres.fields.ArrayField( + base_field=models.CharField(max_length=64), + default=list, + size=None, + ), + ), + ( + "original_event_names", + django.contrib.postgres.fields.ArrayField( + base_field=models.CharField(max_length=64), + default=list, + size=None, + ), + ), + ("timestamp", models.DateTimeField()), + ( + "maintenance_unit", + models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="maintenance_work", + to="maintenance.maintenanceunit", + ), + ), + ], + options={ + "ordering": ["-timestamp"], + }, + ), + ] diff --git a/maintenance/migrations/__init__.py b/maintenance/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/street_maintenance/models.py b/maintenance/models.py similarity index 95% rename from street_maintenance/models.py rename to maintenance/models.py index 3591c3117..ec4f2fc1a 100644 --- a/street_maintenance/models.py +++ b/maintenance/models.py @@ -1,7 +1,7 @@ from django.contrib.gis.db import models from django.contrib.postgres.fields import ArrayField -from street_maintenance.management.commands.constants import PROVIDER_CHOICES +from maintenance.management.commands.constants import PROVIDER_CHOICES DEFAULT_SRID = 4326 diff --git a/street_maintenance/specificatio.swagger.yaml b/maintenance/specificatio.swagger.yaml similarity index 97% rename from street_maintenance/specificatio.swagger.yaml rename to maintenance/specificatio.swagger.yaml index c1064ebdc..229078bb9 100644 --- a/street_maintenance/specificatio.swagger.yaml +++ b/maintenance/specificatio.swagger.yaml @@ -1,9 +1,9 @@ swagger: "2.0" info: - description: "Street maintenance API that serves history data of maintenance works, active events and provides history as generated geometries." + description: "Maintenance API that serves history data of maintenance works, active events and provides history as generated geometries." version: "1.0.0" - title: "Street Maintenance History" + title: Maintenance History" schemes: - "https" diff --git a/street_maintenance/tasks.py b/maintenance/tasks.py similarity index 100% rename from street_maintenance/tasks.py rename to maintenance/tasks.py diff --git a/maintenance/tests/__init__.py b/maintenance/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/street_maintenance/tests/conftest.py b/maintenance/tests/conftest.py similarity index 81% rename from street_maintenance/tests/conftest.py rename to maintenance/tests/conftest.py index cd4b5fdc2..76ae687e5 100644 --- a/street_maintenance/tests/conftest.py +++ b/maintenance/tests/conftest.py @@ -10,14 +10,14 @@ ) from rest_framework.test import APIClient -from mobility_data.tests.conftest import TURKU_WKT -from street_maintenance.management.commands.constants import ( +from maintenance.management.commands.constants import ( AURAUS, INFRAROAD, KUNTEC, LIUKKAUDENTORJUNTA, ) -from street_maintenance.models import DEFAULT_SRID, GeometryHistory +from maintenance.models import DEFAULT_SRID, GeometryHistory +from mobility_data.tests.conftest import TURKU_WKT UTC_TIMEZONE = pytz.timezone("UTC") @@ -30,49 +30,44 @@ def api_client(): @pytest.mark.django_db @pytest.fixture def geometry_historys(): - geometry_historys = [] now = datetime.now(UTC_TIMEZONE) geometry = LineString((0, 0), (0, 50), (50, 50), (50, 0), (0, 0), sird=DEFAULT_SRID) - obj = GeometryHistory.objects.create( + GeometryHistory.objects.create( timestamp=now, geometry=geometry, coordinates=geometry.coords, provider=INFRAROAD, events=[AURAUS], ) - geometry_historys.append(obj) - obj = GeometryHistory.objects.create( + GeometryHistory.objects.create( timestamp=now - timedelta(days=1), geometry=geometry, coordinates=geometry.coords, provider=INFRAROAD, events=[AURAUS], ) - geometry_historys.append(obj) - obj = GeometryHistory.objects.create( + GeometryHistory.objects.create( timestamp=now - timedelta(days=2), geometry=geometry, coordinates=geometry.coords, provider=INFRAROAD, events=[LIUKKAUDENTORJUNTA], ) - geometry_historys.append(obj) - obj = GeometryHistory.objects.create( + GeometryHistory.objects.create( timestamp=now - timedelta(days=1), geometry=geometry, coordinates=geometry.coords, provider=KUNTEC, events=[AURAUS], ) - geometry_historys.append(obj) - obj = GeometryHistory.objects.create( + GeometryHistory.objects.create( timestamp=now - timedelta(days=2), geometry=geometry, coordinates=geometry.coords, provider=KUNTEC, events=[AURAUS, LIUKKAUDENTORJUNTA], ) - geometry_historys.append(obj) + return GeometryHistory.objects.all() @pytest.mark.django_db diff --git a/street_maintenance/tests/test_api.py b/maintenance/tests/test_api.py similarity index 79% rename from street_maintenance/tests/test_api.py rename to maintenance/tests/test_api.py index b56048572..02ab75b00 100644 --- a/street_maintenance/tests/test_api.py +++ b/maintenance/tests/test_api.py @@ -4,7 +4,7 @@ from django.utils import timezone from rest_framework.reverse import reverse -from street_maintenance.management.commands.constants import ( +from maintenance.management.commands.constants import ( AURAUS, INFRAROAD, KUNTEC, @@ -15,14 +15,14 @@ @pytest.mark.django_db def test_geometry_history_list(api_client, geometry_historys): - url = reverse("street_maintenance:geometry_history-list") + url = reverse("maintenance:geometry_history-list") response = api_client.get(url) assert response.json()["count"] == 5 @pytest.mark.django_db def test_geometry_history_list_provider_parameter(api_client, geometry_historys): - url = reverse("street_maintenance:geometry_history-list") + f"?provider={KUNTEC}" + url = reverse("maintenance:geometry_history-list") + f"?provider={KUNTEC}" response = api_client.get(url) # Fixture data contains 2 KUNTEC GeometryHistroy rows assert response.json()["count"] == 2 @@ -30,7 +30,7 @@ def test_geometry_history_list_provider_parameter(api_client, geometry_historys) @pytest.mark.django_db def test_geometry_history_list_event_parameter(api_client, geometry_historys): - url = reverse("street_maintenance:geometry_history-list") + f"?event={AURAUS}" + url = reverse("maintenance:geometry_history-list") + f"?event={AURAUS}" response = api_client.get(url) # 3 INFRAROAD AURAUS events and 1 KUNTEC assert response.json()["count"] == 4 @@ -41,7 +41,7 @@ def test_geometry_history_list_event_and_provider_parameter( api_client, geometry_historys ): url = ( - reverse("street_maintenance:geometry_history-list") + reverse("maintenance:geometry_history-list") + f"?provider={KUNTEC}&event={LIUKKAUDENTORJUNTA}" ) response = api_client.get(url) @@ -52,7 +52,7 @@ def test_geometry_history_list_event_and_provider_parameter( def test_geometry_history_list_start_date_time_parameter(api_client, geometry_historys): start_date_time = timezone.now() - timedelta(hours=1) url = ( - reverse("street_maintenance:geometry_history-list") + reverse("maintenance:geometry_history-list") + f"?start_date_time={start_date_time.strftime(START_DATE_TIME_FORMAT)}" ) response = api_client.get(url) @@ -62,7 +62,7 @@ def test_geometry_history_list_start_date_time_parameter(api_client, geometry_hi assert geometry_history["provider"] == INFRAROAD start_date_time = timezone.now() - timedelta(days=1, hours=2) url = ( - reverse("street_maintenance:geometry_history-list") + reverse("maintenance:geometry_history-list") + f"?start_date_time={start_date_time.strftime(START_DATE_TIME_FORMAT)}" ) response = api_client.get(url) diff --git a/street_maintenance/tests/test_importers.py b/maintenance/tests/test_importers.py similarity index 90% rename from street_maintenance/tests/test_importers.py rename to maintenance/tests/test_importers.py index 888c3f026..51dd96353 100644 --- a/street_maintenance/tests/test_importers.py +++ b/maintenance/tests/test_importers.py @@ -2,8 +2,8 @@ import pytest -from street_maintenance.management.commands.constants import DESTIA, INFRAROAD -from street_maintenance.models import MaintenanceUnit, MaintenanceWork +from maintenance.management.commands.constants import DESTIA, INFRAROAD +from maintenance.models import MaintenanceUnit, MaintenanceWork from .utils import ( get_fluentprogress_units_mock_data, @@ -18,15 +18,13 @@ @pytest.mark.django_db -@patch("street_maintenance.management.commands.utils.get_yit_vehicles") +@patch("maintenance.management.commands.utils.get_yit_vehicles") def test_yit_units( get_yit_vehicles_mock, administrative_division, administrative_division_geometry, ): - from street_maintenance.management.commands.utils import ( - create_yit_maintenance_units, - ) + from maintenance.management.commands.utils import create_yit_maintenance_units get_yit_vehicles_mock.return_value = get_yit_vehicles_mock_data(2) num_created_units, num_del_units = create_yit_maintenance_units("test_access_token") @@ -54,25 +52,25 @@ def test_yit_units( @pytest.mark.django_db @patch( - "street_maintenance.management.commands.utils.get_yit_vehicles", + "maintenance.management.commands.utils.get_yit_vehicles", return_value=get_yit_vehicles_mock_data(2), ) @patch( - "street_maintenance.management.commands.utils.get_yit_contract", + "maintenance.management.commands.utils.get_yit_contract", return_value=get_yit_contract_mock_data(), ) @patch( - "street_maintenance.management.commands.utils.get_yit_event_types", + "maintenance.management.commands.utils.get_yit_event_types", return_value=get_yit_event_types_mock_data(), ) -@patch("street_maintenance.management.commands.utils.get_yit_routes") +@patch("maintenance.management.commands.utils.get_yit_routes") def test_yit_works( get_yit_routes_mock, get_yit_vechiles_mock, administrative_division, administrative_division_geometry, ): - from street_maintenance.management.commands.utils import ( + from maintenance.management.commands.utils import ( create_yit_maintenance_units, create_yit_maintenance_works, ) @@ -109,11 +107,11 @@ def test_yit_works( @pytest.mark.django_db -@patch("street_maintenance.management.commands.utils.get_json_data") +@patch("maintenance.management.commands.utils.get_json_data") def test_kuntec( get_json_data_mock, administrative_division, administrative_division_geometry ): - from street_maintenance.management.commands.utils import ( + from maintenance.management.commands.utils import ( create_kuntec_maintenance_units, create_kuntec_maintenance_works, ) @@ -169,11 +167,11 @@ def test_kuntec( @pytest.mark.django_db -@patch("street_maintenance.management.commands.utils.get_json_data") +@patch("maintenance.management.commands.utils.get_json_data") def test_infraroad( get_json_data_mock, administrative_division, administrative_division_geometry ): - from street_maintenance.management.commands.utils import ( + from maintenance.management.commands.utils import ( create_maintenance_units, create_maintenance_works, ) @@ -228,11 +226,11 @@ def test_infraroad( @pytest.mark.django_db -@patch("street_maintenance.management.commands.utils.get_json_data") +@patch("maintenance.management.commands.utils.get_json_data") def test_destia( get_json_data_mock, administrative_division, administrative_division_geometry ): - from street_maintenance.management.commands.utils import ( + from maintenance.management.commands.utils import ( create_maintenance_units, create_maintenance_works, ) diff --git a/street_maintenance/tests/utils.py b/maintenance/tests/utils.py similarity index 99% rename from street_maintenance/tests/utils.py rename to maintenance/tests/utils.py index 078807e51..0306c8d79 100644 --- a/street_maintenance/tests/utils.py +++ b/maintenance/tests/utils.py @@ -1,10 +1,6 @@ from datetime import datetime -from street_maintenance.management.commands.constants import ( - DATE_FORMATS, - INFRAROAD, - YIT, -) +from maintenance.management.commands.constants import DATE_FORMATS, INFRAROAD, YIT def get_yit_vehicles_mock_data(num_elements): diff --git a/smbackend/settings.py b/smbackend/settings.py index 3fa06f3cb..64b3cd5fd 100644 --- a/smbackend/settings.py +++ b/smbackend/settings.py @@ -77,7 +77,7 @@ ECO_COUNTER_LOG_LEVEL=(str, "INFO"), MOBILITY_DATA_LOG_LEVEL=(str, "INFO"), BICYCLE_NETWORK_LOG_LEVEL=(str, "INFO"), - STREET_MAINTENANCE_LOG_LEVEL=(str, "INFO"), + MAINTENANCE_LOG_LEVEL=(str, "INFO"), ENVIRONMENT_DATA_LOG_LEVEL=(str, "INFO"), EXCEPTIONAL_SITUATIONS_LOG_LEVEL=(str, "INFO"), ) @@ -102,7 +102,7 @@ ECO_COUNTER_LOG_LEVEL = env("ECO_COUNTER_LOG_LEVEL") MOBILITY_DATA_LOG_LEVEL = env("MOBILITY_DATA_LOG_LEVEL") BICYCLE_NETWORK_LOG_LEVEL = env("BICYCLE_NETWORK_LOG_LEVEL") -STREET_MAINTENANCE_LOG_LEVEL = env("STREET_MAINTENANCE_LOG_LEVEL") +MAINTENANCE_LOG_LEVEL = env("MAINTENANCE_LOG_LEVEL") ENVIRONMENT_DATA_LOG_LEVEL = env("ENVIRONMENT_DATA_LOG_LEVEL") EXCEPTIONAL_SITUATIONS_LOG_LEVEL = env("EXCEPTIONAL_SITUATIONS_LOG_LEVEL") @@ -134,6 +134,7 @@ "bicycle_network.apps.BicycleNetworkConfig", "iot.apps.IotConfig", "street_maintenance.apps.StreetMaintenanceConfig", + "maintenance.apps.MaintenanceConfig", "environment_data.apps.EnvironmentDataConfig", "exceptional_situations.apps.ExceptionalSituationsConfig", ] @@ -331,9 +332,9 @@ def gettext(s): "handlers": ["console"], "level": BICYCLE_NETWORK_LOG_LEVEL, }, - "street_maintenance": { + "maintenance": { "handlers": ["console"], - "level": STREET_MAINTENANCE_LOG_LEVEL, + "level": MAINTENANCE_LOG_LEVEL, }, "environment_data": { "handlers": ["console"], @@ -349,9 +350,9 @@ def gettext(s): # Define the endpoints for API documentation with drf-spectacular. DOC_ENDPOINTS = [ - "/street_maintenance/geometry_history/", - "/street_maintenance/maintenance_works/", - "/street_maintenance/maintenance_units/", + "/maintenance/geometry_history/", + "/maintenance/maintenance_works/", + "/maintenance/maintenance_units/", "/environment_data/api/v1/stations/", "/environment_data/api/v1/parameters/", "/environment_data/api/v1/data/", diff --git a/smbackend/urls.py b/smbackend/urls.py index 94555aa30..a0a3b0aaf 100644 --- a/smbackend/urls.py +++ b/smbackend/urls.py @@ -11,8 +11,9 @@ import eco_counter.api.urls import environment_data.api.urls import exceptional_situations.api.urls +import maintenance.api.urls +import maintenance.api.urls_street_maintenance import mobility_data.api.urls -import street_maintenance.api.urls from iot.api import IoTViewSet from observations.api import views as observations_views from observations.views import obtain_auth_token @@ -77,9 +78,15 @@ include(exceptional_situations.api.urls), name="exceptional_situations", ), + re_path( + r"^maintenance/", + include(maintenance.api.urls), + name="maintenance", + ), + # Keep backward compatibility to street_maintenance API re_path( r"^street_maintenance/", - include(street_maintenance.api.urls), + include(maintenance.api.urls_street_maintenance), name="street_maintenance", ), re_path(r"", include(shortcutter_urls)), diff --git a/street_maintenance/migrations/0014_delete_geometryhistory_and_more.py b/street_maintenance/migrations/0014_delete_geometryhistory_and_more.py new file mode 100644 index 000000000..cde893e9e --- /dev/null +++ b/street_maintenance/migrations/0014_delete_geometryhistory_and_more.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.15 on 2024-09-18 07:48 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("street_maintenance", "0013_maintenancework_change_related_name"), + ] + + operations = [ + migrations.DeleteModel( + name="GeometryHistory", + ), + migrations.RemoveField( + model_name="maintenancework", + name="maintenance_unit", + ), + migrations.DeleteModel( + name="MaintenanceUnit", + ), + migrations.DeleteModel( + name="MaintenanceWork", + ), + ]