From 0b41b20bb75720c33a8bc9c183e1e4d30c62c150 Mon Sep 17 00:00:00 2001 From: David Paul Graham <43794491+dpgraham4401@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:17:01 -0400 Subject: [PATCH] Flatten django app dir (#751) * move wasteline app * move root confest to server dir * move org app * move profile app * move handler app * move manifest app * move rcrasite app * rename site app to orgsite app * move core app * move orgsite app --- .idea/scopes/server.xml | 2 +- server/apps/conftest.py | 377 ------------------ .../apps/manifest/migrations/0001_initial.py | 88 ---- .../apps/rcrasite/migrations/0001_initial.py | 86 ---- server/apps/site/migrations/0001_initial.py | 49 --- ...ions_sitegroupobjectpermission_and_more.py | 47 --- ...egroupobjectpermission_options_and_more.py | 21 - server/conftest.py | 376 +++++++++++++++++ server/{apps => }/core/__init__.py | 0 server/{apps => }/core/admin.py | 4 +- server/{apps => }/core/apps.py | 2 +- server/{apps => }/core/exceptions.py | 2 +- server/{apps => }/core/management/__init__.py | 0 .../core/management/commands/__init__.py | 0 .../core/management/commands/celery_beat.py | 2 +- .../core/management/commands/celery_worker.py | 0 .../core/migrations/0001_initial.py | 0 .../core/migrations/0002_permission.py | 0 .../{apps => }/core/migrations/0003_role.py | 0 .../0004_grouppermission_userpermission.py | 0 ..._permissions_delete_permission_and_more.py | 0 server/{apps => }/core/migrations/__init__.py | 0 server/{apps => }/core/models.py | 0 server/{apps => }/core/serializers.py | 2 +- server/{apps => }/core/services/__init__.py | 0 .../core/services/rcrainfo_service.py | 6 +- .../{apps => }/core/services/task_service.py | 4 +- server/{apps => }/core/signals.py | 4 +- server/{apps => }/core/tasks.py | 0 server/{apps => }/core/tests/__init__.py | 0 server/{apps => }/core/tests/conftest.py | 2 +- .../{apps => }/core/tests/test_exceptions.py | 2 +- .../core/tests/test_rcrainfo_service.py | 6 +- server/{apps => }/core/tests/test_tasks.py | 4 +- server/{apps => }/core/tests/test_views.py | 6 +- server/{apps => }/core/urls.py | 0 server/{apps => }/core/views.py | 2 +- server/{apps => }/handler/__init__.py | 0 server/{apps => }/handler/admin.py | 2 +- server/{apps => }/handler/apps.py | 2 +- .../handler/migrations/0001_initial.py | 5 +- .../handler/migrations/0002_initial.py | 0 .../0003_alter_papersignature_options.py | 0 .../{apps => }/handler/migrations/__init__.py | 0 server/{apps => }/handler/models/__init__.py | 0 server/{apps => }/handler/models/contact.py | 0 server/{apps => }/handler/models/handler.py | 2 +- server/{apps => }/handler/models/signature.py | 0 .../handler/serializers/__init__.py | 0 .../handler/serializers/base_serializer.py | 0 .../handler/serializers/handler_serializer.py | 4 +- .../handler/serializers/signatures.py | 4 +- server/{apps => }/handler/tests/__init__.py | 0 server/{apps => }/handler/tests/conftest.py | 6 +- .../handler/tests/test_handler_models.py | 2 +- .../handler/tests/test_handler_serializer.py | 4 +- .../handler/tests/test_handler_services.py | 6 +- .../handler/tests/test_signature_models.py | 2 +- .../tests/test_signature_serializer.py | 4 +- server/haztrak/settings/base.py | 26 +- server/haztrak/urls.py | 14 +- server/{apps => }/manifest/__init__.py | 0 server/{apps => }/manifest/admin.py | 6 +- server/{apps => }/manifest/apps.py | 2 +- server/manifest/migrations/0001_initial.py | 322 +++++++++++++++ .../manifest/migrations/__init__.py | 0 server/{apps => }/manifest/models.py | 6 +- server/{apps => }/manifest/serializers.py | 8 +- .../{apps => }/manifest/services/__init__.py | 0 .../{apps => }/manifest/services/emanifest.py | 14 +- .../manifest/services/emanifest_search.py | 2 +- .../{apps => }/manifest/services/manifest.py | 8 +- server/{apps => }/manifest/tasks.py | 16 +- server/{apps => }/manifest/tests/__init__.py | 0 server/{apps => }/manifest/tests/conftest.py | 6 +- .../manifest/tests/test_emanifest_service.py | 4 +- .../manifest/tests/test_manifest_services.py | 6 +- .../{apps => }/manifest/tests/test_models.py | 8 +- .../manifest/tests/test_search_emanifest.py | 4 +- .../manifest/tests/test_serializers.py | 6 +- .../{apps => }/manifest/tests/test_views.py | 8 +- server/{apps => }/manifest/urls.py | 2 +- server/{apps => }/manifest/views.py | 10 +- server/{apps => }/org/__init__.py | 0 server/{apps => }/org/admin.py | 4 +- server/{apps => }/org/apps.py | 2 +- .../{apps => }/org/migrations/0001_initial.py | 0 ...korg_org_rename_trakorgaccess_orgaccess.py | 13 +- ...bjectpermission_orguserobjectpermission.py | 0 server/{apps => }/org/migrations/__init__.py | 0 server/{apps => }/org/models.py | 3 +- server/{apps => }/org/serializers.py | 2 +- server/{apps => }/org/services.py | 2 +- server/{apps => }/org/tests/__init__.py | 0 server/{apps => }/org/tests/test_models.py | 2 +- .../{apps => }/org/tests/test_serializers.py | 2 +- server/{apps => }/org/tests/test_services.py | 2 +- server/{apps => }/org/tests/test_views.py | 6 +- server/{apps => }/org/urls.py | 2 +- server/{apps => }/org/views.py | 6 +- server/{apps/profile => orgsite}/__init__.py | 0 server/{apps/site => orgsite}/admin.py | 2 +- server/{apps/site => orgsite}/apps.py | 2 +- server/orgsite/migrations/0001_initial.py | 105 +++++ ...ions_sitegroupobjectpermission_and_more.py | 90 +++++ ...egroupobjectpermission_options_and_more.py | 20 + .../0004_alter_siteaccess_site_and_more.py | 29 ++ .../migrations/__init__.py | 0 server/{apps/site => orgsite}/models.py | 0 server/{apps/site => orgsite}/serializers.py | 6 +- server/{apps/site => orgsite}/services.py | 6 +- .../profile => orgsite}/tests/__init__.py | 0 .../{apps/site => orgsite}/tests/conftest.py | 6 +- .../site => orgsite}/tests/test_models.py | 2 +- .../site => orgsite}/tests/test_services.py | 14 +- .../site => orgsite}/tests/test_views.py | 2 +- server/{apps/site => orgsite}/urls.py | 0 server/{apps/site => orgsite}/views.py | 6 +- server/{apps/rcrasite => profile}/__init__.py | 0 server/{apps => }/profile/admin.py | 0 server/{apps => }/profile/apps.py | 2 +- .../profile/migrations/0001_initial.py | 0 .../0002_rename_trakprofile_profile.py | 0 .../migrations/__init__.py | 0 server/{apps => }/profile/models.py | 0 .../profile/serializers/__init__.py | 0 .../{apps => }/profile/serializers/profile.py | 7 +- .../profile/serializers/rcrainfo_profile.py | 4 +- .../profile/serializers/rcrasite_access.py | 4 +- server/{apps => }/profile/services.py | 14 +- .../rcrasite => profile}/tests/__init__.py | 0 server/{apps => }/profile/tests/conftest.py | 4 +- .../{apps => }/profile/tests/test_models.py | 4 +- .../profile/tests/test_serializers.py | 8 +- .../{apps => }/profile/tests/test_services.py | 4 +- server/{apps => }/profile/tests/test_views.py | 4 +- server/{apps => }/profile/urls.py | 0 server/{apps => }/profile/views.py | 9 +- server/{apps/site => rcrasite}/__init__.py | 0 server/{apps => }/rcrasite/admin.py | 4 +- server/{apps => }/rcrasite/apps.py | 2 +- server/rcrasite/migrations/0001_initial.py | 268 +++++++++++++ .../site => rcrasite}/migrations/__init__.py | 0 server/{apps => }/rcrasite/models/__init__.py | 0 server/{apps => }/rcrasite/models/contact.py | 0 server/{apps => }/rcrasite/models/rcrasite.py | 2 +- .../rcrasite/serializers/__init__.py | 0 .../serializers/address_serializer.py | 2 +- .../rcrasite/serializers/base_serializer.py | 0 .../serializers/contact_serializer.py | 2 +- .../rcrasite/serializers/site_serializer.py | 4 +- .../{apps => }/rcrasite/services/__init__.py | 0 .../{apps => }/rcrasite/services/rcra_site.py | 6 +- .../rcrasite/services/rcra_site_search.py | 2 +- server/{apps => }/rcrasite/tasks/__init__.py | 0 .../rcrasite/tasks/profile_tasks.py | 3 +- .../{apps => }/rcrasite/tasks/site_tasks.py | 2 +- .../{apps/site => rcrasite}/tests/__init__.py | 0 .../{apps => }/rcrasite/tests/test_models.py | 2 +- .../rcrasite/tests/test_serializers.py | 2 +- .../rcrasite/tests/test_site_search.py | 4 +- .../{apps => }/rcrasite/tests/test_views.py | 6 +- server/{apps => }/rcrasite/urls.py | 2 +- server/{apps => }/rcrasite/views.py | 6 +- server/{apps => }/wasteline/__init__.py | 0 server/{apps => }/wasteline/admin.py | 2 +- server/{apps => }/wasteline/apps.py | 2 +- .../wasteline/migrations/0001_initial.py | 0 .../migrations/0002_state_waste_codes.py | 2 +- .../migrations/0003_federal_waste_codes.py | 2 +- .../migrations/0004_dot_id_numbers.py | 2 +- .../migrations/0005_dot_packing_groups.py | 2 +- .../migrations/0006_dot_shipping_names.py | 2 +- .../wasteline/migrations/__init__.py | 0 server/{apps => }/wasteline/models.py | 0 server/{apps => }/wasteline/serializers.py | 2 +- server/{apps => }/wasteline/services.py | 2 +- server/{apps => }/wasteline/tasks.py | 2 +- server/{apps => }/wasteline/tests/__init__.py | 0 server/{apps => }/wasteline/tests/conftest.py | 4 +- .../wasteline/tests/test_waste_views.py | 4 +- .../wasteline/tests/test_wl_models.py | 2 +- .../wasteline/tests/test_wl_serializer.py | 2 +- server/{apps => }/wasteline/urls.py | 2 +- server/{apps => }/wasteline/views.py | 6 +- 185 files changed, 1457 insertions(+), 917 deletions(-) delete mode 100644 server/apps/manifest/migrations/0001_initial.py delete mode 100644 server/apps/rcrasite/migrations/0001_initial.py delete mode 100644 server/apps/site/migrations/0001_initial.py delete mode 100644 server/apps/site/migrations/0002_alter_siteaccess_options_sitegroupobjectpermission_and_more.py delete mode 100644 server/apps/site/migrations/0003_alter_sitegroupobjectpermission_options_and_more.py rename server/{apps => }/core/__init__.py (100%) rename server/{apps => }/core/admin.py (96%) rename server/{apps => }/core/apps.py (87%) rename server/{apps => }/core/exceptions.py (97%) rename server/{apps => }/core/management/__init__.py (100%) rename server/{apps => }/core/management/commands/__init__.py (100%) rename server/{apps => }/core/management/commands/celery_beat.py (97%) rename server/{apps => }/core/management/commands/celery_worker.py (100%) rename server/{apps => }/core/migrations/0001_initial.py (100%) rename server/{apps => }/core/migrations/0002_permission.py (100%) rename server/{apps => }/core/migrations/0003_role.py (100%) rename server/{apps => }/core/migrations/0004_grouppermission_userpermission.py (100%) rename server/{apps => }/core/migrations/0005_remove_role_permissions_delete_permission_and_more.py (100%) rename server/{apps => }/core/migrations/__init__.py (100%) rename server/{apps => }/core/models.py (100%) rename server/{apps => }/core/serializers.py (98%) rename server/{apps => }/core/services/__init__.py (100%) rename server/{apps => }/core/services/rcrainfo_service.py (97%) rename server/{apps => }/core/services/task_service.py (97%) rename server/{apps => }/core/signals.py (89%) rename server/{apps => }/core/tasks.py (100%) rename server/{apps => }/core/tests/__init__.py (100%) rename server/{apps => }/core/tests/conftest.py (96%) rename server/{apps => }/core/tests/test_exceptions.py (86%) rename server/{apps => }/core/tests/test_rcrainfo_service.py (96%) rename server/{apps => }/core/tests/test_tasks.py (96%) rename server/{apps => }/core/tests/test_views.py (89%) rename server/{apps => }/core/urls.py (100%) rename server/{apps => }/core/views.py (95%) rename server/{apps => }/handler/__init__.py (100%) rename server/{apps => }/handler/admin.py (97%) rename server/{apps => }/handler/apps.py (82%) rename server/{apps => }/handler/migrations/0001_initial.py (98%) rename server/{apps => }/handler/migrations/0002_initial.py (100%) rename server/{apps => }/handler/migrations/0003_alter_papersignature_options.py (100%) rename server/{apps => }/handler/migrations/__init__.py (100%) rename server/{apps => }/handler/models/__init__.py (100%) rename server/{apps => }/handler/models/contact.py (100%) rename server/{apps => }/handler/models/handler.py (99%) rename server/{apps => }/handler/models/signature.py (100%) rename server/{apps => }/handler/serializers/__init__.py (100%) rename server/{apps => }/handler/serializers/base_serializer.py (100%) rename server/{apps => }/handler/serializers/handler_serializer.py (96%) rename server/{apps => }/handler/serializers/signatures.py (97%) rename server/{apps => }/handler/tests/__init__.py (100%) rename server/{apps => }/handler/tests/conftest.py (96%) rename server/{apps => }/handler/tests/test_handler_models.py (97%) rename server/{apps => }/handler/tests/test_handler_serializer.py (94%) rename server/{apps => }/handler/tests/test_handler_services.py (92%) rename server/{apps => }/handler/tests/test_signature_models.py (93%) rename server/{apps => }/handler/tests/test_signature_serializer.py (92%) rename server/{apps => }/manifest/__init__.py (100%) rename server/{apps => }/manifest/admin.py (89%) rename server/{apps => }/manifest/apps.py (82%) create mode 100644 server/manifest/migrations/0001_initial.py rename server/{apps => }/manifest/migrations/__init__.py (100%) rename server/{apps => }/manifest/models.py (98%) rename server/{apps => }/manifest/serializers.py (98%) rename server/{apps => }/manifest/services/__init__.py (100%) rename server/{apps => }/manifest/services/emanifest.py (94%) rename server/{apps => }/manifest/services/emanifest_search.py (99%) rename server/{apps => }/manifest/services/manifest.py (89%) rename server/{apps => }/manifest/tasks.py (89%) rename server/{apps => }/manifest/tests/__init__.py (100%) rename server/{apps => }/manifest/tests/conftest.py (96%) rename server/{apps => }/manifest/tests/test_emanifest_service.py (92%) rename server/{apps => }/manifest/tests/test_manifest_services.py (96%) rename server/{apps => }/manifest/tests/test_models.py (95%) rename server/{apps => }/manifest/tests/test_search_emanifest.py (97%) rename server/{apps => }/manifest/tests/test_serializers.py (90%) rename server/{apps => }/manifest/tests/test_views.py (90%) rename server/{apps => }/manifest/urls.py (96%) rename server/{apps => }/manifest/views.py (94%) rename server/{apps => }/org/__init__.py (100%) rename server/{apps => }/org/admin.py (92%) rename server/{apps => }/org/apps.py (84%) rename server/{apps => }/org/migrations/0001_initial.py (100%) rename server/{apps => }/org/migrations/0002_rename_trakorg_org_rename_trakorgaccess_orgaccess.py (64%) rename server/{apps => }/org/migrations/0003_orggroupobjectpermission_orguserobjectpermission.py (100%) rename server/{apps => }/org/migrations/__init__.py (100%) rename server/{apps => }/org/models.py (98%) rename server/{apps => }/org/serializers.py (94%) rename server/{apps => }/org/services.py (96%) rename server/{apps => }/org/tests/__init__.py (100%) rename server/{apps => }/org/tests/test_models.py (98%) rename server/{apps => }/org/tests/test_serializers.py (95%) rename server/{apps => }/org/tests/test_services.py (92%) rename server/{apps => }/org/tests/test_views.py (89%) rename server/{apps => }/org/urls.py (76%) rename server/{apps => }/org/views.py (85%) rename server/{apps/profile => orgsite}/__init__.py (100%) rename server/{apps/site => orgsite}/admin.py (93%) rename server/{apps/site => orgsite}/apps.py (84%) create mode 100644 server/orgsite/migrations/0001_initial.py create mode 100644 server/orgsite/migrations/0002_alter_siteaccess_options_sitegroupobjectpermission_and_more.py create mode 100644 server/orgsite/migrations/0003_alter_sitegroupobjectpermission_options_and_more.py create mode 100644 server/orgsite/migrations/0004_alter_siteaccess_site_and_more.py rename server/{apps/profile => orgsite}/migrations/__init__.py (100%) rename server/{apps/site => orgsite}/models.py (100%) rename server/{apps/site => orgsite}/serializers.py (79%) rename server/{apps/site => orgsite}/services.py (93%) rename server/{apps/profile => orgsite}/tests/__init__.py (100%) rename server/{apps/site => orgsite}/tests/conftest.py (82%) rename server/{apps/site => orgsite}/tests/test_models.py (99%) rename server/{apps/site => orgsite}/tests/test_services.py (80%) rename server/{apps/site => orgsite}/tests/test_views.py (98%) rename server/{apps/site => orgsite}/urls.py (100%) rename server/{apps/site => orgsite}/views.py (92%) rename server/{apps/rcrasite => profile}/__init__.py (100%) rename server/{apps => }/profile/admin.py (100%) rename server/{apps => }/profile/apps.py (82%) rename server/{apps => }/profile/migrations/0001_initial.py (100%) rename server/{apps => }/profile/migrations/0002_rename_trakprofile_profile.py (100%) rename server/{apps/rcrasite => profile}/migrations/__init__.py (100%) rename server/{apps => }/profile/models.py (100%) rename server/{apps => }/profile/serializers/__init__.py (100%) rename server/{apps => }/profile/serializers/profile.py (80%) rename server/{apps => }/profile/serializers/rcrainfo_profile.py (96%) rename server/{apps => }/profile/serializers/rcrasite_access.py (98%) rename server/{apps => }/profile/services.py (92%) rename server/{apps/rcrasite => profile}/tests/__init__.py (100%) rename server/{apps => }/profile/tests/conftest.py (91%) rename server/{apps => }/profile/tests/test_models.py (97%) rename server/{apps => }/profile/tests/test_serializers.py (97%) rename server/{apps => }/profile/tests/test_services.py (95%) rename server/{apps => }/profile/tests/test_views.py (98%) rename server/{apps => }/profile/urls.py (100%) rename server/{apps => }/profile/views.py (89%) rename server/{apps/site => rcrasite}/__init__.py (100%) rename server/{apps => }/rcrasite/admin.py (85%) rename server/{apps => }/rcrasite/apps.py (82%) create mode 100644 server/rcrasite/migrations/0001_initial.py rename server/{apps/site => rcrasite}/migrations/__init__.py (100%) rename server/{apps => }/rcrasite/models/__init__.py (100%) rename server/{apps => }/rcrasite/models/contact.py (100%) rename server/{apps => }/rcrasite/models/rcrasite.py (98%) rename server/{apps => }/rcrasite/serializers/__init__.py (100%) rename server/{apps => }/rcrasite/serializers/address_serializer.py (95%) rename server/{apps => }/rcrasite/serializers/base_serializer.py (100%) rename server/{apps => }/rcrasite/serializers/contact_serializer.py (97%) rename server/{apps => }/rcrasite/serializers/site_serializer.py (94%) rename server/{apps => }/rcrasite/services/__init__.py (100%) rename server/{apps => }/rcrasite/services/rcra_site.py (95%) rename server/{apps => }/rcrasite/services/rcra_site_search.py (98%) rename server/{apps => }/rcrasite/tasks/__init__.py (100%) rename server/{apps => }/rcrasite/tasks/profile_tasks.py (93%) rename server/{apps => }/rcrasite/tasks/site_tasks.py (91%) rename server/{apps/site => rcrasite}/tests/__init__.py (100%) rename server/{apps => }/rcrasite/tests/test_models.py (96%) rename server/{apps => }/rcrasite/tests/test_serializers.py (94%) rename server/{apps => }/rcrasite/tests/test_site_search.py (96%) rename server/{apps => }/rcrasite/tests/test_views.py (95%) rename server/{apps => }/rcrasite/urls.py (82%) rename server/{apps => }/rcrasite/views.py (95%) rename server/{apps => }/wasteline/__init__.py (100%) rename server/{apps => }/wasteline/admin.py (93%) rename server/{apps => }/wasteline/apps.py (81%) rename server/{apps => }/wasteline/migrations/0001_initial.py (100%) rename server/{apps => }/wasteline/migrations/0002_state_waste_codes.py (99%) rename server/{apps => }/wasteline/migrations/0003_federal_waste_codes.py (99%) rename server/{apps => }/wasteline/migrations/0004_dot_id_numbers.py (99%) rename server/{apps => }/wasteline/migrations/0005_dot_packing_groups.py (98%) rename server/{apps => }/wasteline/migrations/0006_dot_shipping_names.py (99%) rename server/{apps => }/wasteline/migrations/__init__.py (100%) rename server/{apps => }/wasteline/models.py (100%) rename server/{apps => }/wasteline/serializers.py (97%) rename server/{apps => }/wasteline/services.py (95%) rename server/{apps => }/wasteline/tasks.py (92%) rename server/{apps => }/wasteline/tests/__init__.py (100%) rename server/{apps => }/wasteline/tests/conftest.py (94%) rename server/{apps => }/wasteline/tests/test_waste_views.py (98%) rename server/{apps => }/wasteline/tests/test_wl_models.py (97%) rename server/{apps => }/wasteline/tests/test_wl_serializer.py (84%) rename server/{apps => }/wasteline/urls.py (94%) rename server/{apps => }/wasteline/views.py (96%) diff --git a/.idea/scopes/server.xml b/.idea/scopes/server.xml index 734f5dfc2..b6e990c5d 100644 --- a/.idea/scopes/server.xml +++ b/.idea/scopes/server.xml @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/server/apps/conftest.py b/server/apps/conftest.py index df75b78a2..e69de29bb 100644 --- a/server/apps/conftest.py +++ b/server/apps/conftest.py @@ -1,377 +0,0 @@ -import datetime -import json -import os -import random -import string -from enum import Enum -from typing import Dict, Literal, Optional - -import pytest -import pytest_mock -import responses -from django.contrib.auth.models import User -from django.db import IntegrityError -from faker import Faker -from faker.providers import BaseProvider -from rest_framework.test import APIClient - -from apps.core.models import ( - TrakUser, -) -from apps.org.models import Org, OrgAccess -from apps.profile.models import Profile, RcrainfoProfile -from apps.rcrasite.models import ( - Address, - Contact, - RcraPhone, - RcraSite, -) -from apps.site.models import Site, SiteAccess - - -class SiteIDProvider(BaseProvider): - PREFIXES = ["VAT", "VAD", "TXD", "TXR", "TND", "TNR", "LAD", "LAR", "CAD", "CAR", "MAD", "MAR"] - NUMBERS = ["".join(random.choices(string.digits, k=9)) for _ in range(100)] - - def site_id(self): - return f"{self.random_element(self.PREFIXES)}{self.random_element(self.NUMBERS)}" - - -@pytest.fixture -def haztrak_json(): - """Fixture with JSON data""" - json_dir = os.path.dirname(os.path.abspath(__file__)) + "/../fixtures/json" - - def read_file(path: str) -> Dict: - with open(path) as f: - return json.load(f) - - class Json(Enum): - CONTACT = read_file(f"{json_dir}/contact/good_contact.json") - PHONE = read_file(f"{json_dir}/contact/phone.json") - WASTELINE_1 = read_file(f"{json_dir}/test_wasteline1.json") - MANIFEST = read_file(f"{json_dir}/test_manifest_100033134ELC.json") - SITE_PERMISSION = read_file(f"{json_dir}/site_permission.json") - EPA_PERMISSION = read_file(f"{json_dir}/epa_permission.json") - HANDLER = read_file(f"{json_dir}/test_handler.json") - PAPER_MANIFEST_HANDLER = read_file(f"{json_dir}/paper_manifest_handler.json") - E_SIGNATURE = read_file(f"{json_dir}/test_e_signature.json") - - return Json - - -@pytest.fixture -def user_factory(db, faker): - """Abstract factory for Django's User model""" - - def create_user( - username: Optional[str] = None, - first_name: Optional[str] = None, - last_name: Optional[str] = None, - email: Optional[str] = None, - password: Optional[str] = None, - ) -> TrakUser: - return TrakUser.objects.create_user( - username=username or faker.user_name(), - first_name=first_name or faker.first_name(), - last_name=last_name or faker.last_name(), - email=email or faker.email(), - password=password or faker.password(), - ) - - return create_user - - -@pytest.fixture -def rcrainfo_profile_factory(db, user_factory, faker: Faker): - """Abstract factory for Haztrak RcrainfoProfile model""" - - def create_profile( - rcra_api_id: Optional[str] = str(faker.uuid4()), - rcra_api_key: Optional[str] = faker.pystr(min_chars=15), - rcra_username: Optional[str] = faker.pystr(min_chars=12), - ) -> RcrainfoProfile: - return RcrainfoProfile.objects.create( - rcra_api_id=rcra_api_id, - rcra_api_key=rcra_api_key, - rcra_username=rcra_username, - ) - - return create_profile - - -@pytest.fixture -def profile_factory(db, user_factory, rcrainfo_profile_factory, org_factory): - """Abstract factory for Haztrak RcrainfoProfile model""" - - def create_profile( - user: Optional[User] = None, - rcrainfo_profile: Optional[RcrainfoProfile] = rcrainfo_profile_factory(), - ) -> Profile: - return Profile.objects.create( - user=user or user_factory(), - rcrainfo_profile=rcrainfo_profile, - ) - - return create_profile - - -@pytest.fixture -def address_factory(db, faker: Faker): - """Abstract factory for Haztrak Address model""" - - def create_address( - address1: Optional[str] = None, - street_number: Optional[str] = None, - country: Optional[str] = "US", - city: Optional[str] = None, - ) -> Address: - return Address.objects.create( - address1=address1 or faker.street_name(), - street_number=street_number or faker.building_number(), - country=country, - city=city or faker.city(), - ) - - return create_address - - -@pytest.fixture -def rcra_phone_factory(db, faker: Faker): - """Abstract factory for Haztrak ManifestPhone model""" - - def create_site_phone( - number: Optional[str] = "202-505-5500", - extension: Optional[str] = "1234", - ) -> RcraPhone: - return RcraPhone.objects.create( - number=number, - extension=extension, - ) - - return create_site_phone - - -@pytest.fixture -def contact_factory(db, rcra_phone_factory, faker: Faker): - """Abstract factory for Haztrak Contact model""" - - def create_contact( - first_name: Optional[str] = None, - middle_initial: Optional[str] = None, - last_name: Optional[str] = None, - email: Optional[str] = None, - phone: Optional[RcraPhone] = None, - ) -> Contact: - contact = Contact.objects.create( - first_name=first_name or faker.first_name(), - middle_initial=middle_initial or faker.pystr(max_chars=1), - last_name=last_name or faker.last_name(), - email=email or faker.email(), - phone=phone or rcra_phone_factory(), - ) - return contact - - return create_contact - - -@pytest.fixture -def rcra_site_factory(db, address_factory, contact_factory): - """Abstract factory for Haztrak RcraSite model""" - - def create_rcra_site( - epa_id: Optional[str] = None, - name: Optional[str] = None, - site_type: Optional[Literal["Generator", "Transporter", "Tsdf"]] = "Generator", - site_address: Optional[Address] = None, - mail_address: Optional[Address] = None, - ) -> RcraSite: - fake = Faker() - fake.add_provider(SiteIDProvider) - while True: - try: - return RcraSite.objects.create( - epa_id=epa_id or fake.site_id(), - name=name or fake.name(), - site_type=site_type, - site_address=site_address or address_factory(), - mail_address=mail_address or address_factory(), - contact=contact_factory(), - ) - except IntegrityError: - return RcraSite.objects.create( - epa_id=fake.site_id(), - name=name or fake.name(), - site_type=site_type, - site_address=site_address or address_factory(), - mail_address=mail_address or address_factory(), - contact=contact_factory(), - ) - - return create_rcra_site - - -@pytest.fixture -def validated_data_factory(): - def _create_data_dict(*, instance, serializer) -> Dict: - data = serializer(instance).data - new_serializer = serializer(data=data) - new_serializer.is_valid(raise_exception=True) - return new_serializer.validated_data - - return _create_data_dict - - -@pytest.fixture -def org_factory(db, rcrainfo_profile_factory, user_factory, faker): - """Abstract factory for Haztrak Org model""" - - def create_org( - org_id: Optional[str] = None, - name: Optional[str] = None, - admin: Optional[TrakUser] = None, - ) -> Org: - return Org.objects.create( - id=org_id or faker.uuid4(), - name=name or faker.company(), - admin=admin or user_factory(), - ) - - return create_org - - -@pytest.fixture -def site_factory(db, rcra_site_factory, org_factory, faker): - """Abstract factory for Haztrak Site model""" - - def create_site( - rcra_site: Optional[RcraSite] = None, - name: Optional[str] = None, - org: Optional[Org] = None, - last_rcrainfo_manifest_sync: Optional[datetime.datetime] = None, - ) -> Site: - return Site.objects.create( - rcra_site=rcra_site or rcra_site_factory(), - name=name or faker.name(), - org=org or org_factory(), - last_rcrainfo_manifest_sync=last_rcrainfo_manifest_sync - or datetime.datetime.now(datetime.UTC), - ) - - return create_site - - -@pytest.fixture -def api_client_factory(db, user_factory): - """Abstract factory for DRF APIClient testing class""" - - def create_client( - user: Optional[User] = None, - ) -> APIClient: - client = APIClient() - client.force_authenticate( - user=user or user_factory(), - ) - return client - - return create_client - - -@pytest.fixture -def mock_responses(): - """ - fixture for mocking external http request responses - see Responses docs - https://github.com/getsentry/responses#responses-as-a-pytest-fixture - """ - with responses.RequestsMock() as mock_responses: - yield mock_responses - - -@pytest.fixture() -def mock_emanifest_auth_response(request, mock_responses): - api_id, api_key = request.param - mock_responses.get( - f"https://rcrainfopreprod.epa.gov/rcrainfo/rest/api/v1/auth/{api_id}/{api_key}", - body='{"token": "mocK_token", "expiration": "2021-01-01T00:00:00.000000Z"}', - ) - - -@pytest.fixture -def mocker(mocker: pytest_mock.MockerFixture): - """ - wrapper fixture pytest-mock's mocker fixture for easy type annotations - https://github.com/pytest-dev/pytest-mock - """ - return mocker - - -@pytest.fixture -def site_access_factory(db, faker, site_factory, profile_factory): - """Abstract factory for Haztrak RcraSitePermissions model""" - - def create_permission( - site: Optional[Site] = None, - user: Optional[TrakUser] = None, - emanifest: Optional[Literal["viewer", "signer", "editor"]] = "viewer", - ) -> SiteAccess: - """Returns testuser1 RcraSitePermissions model to site_generator""" - return SiteAccess.objects.create( - site=site or site_factory(), - user=user or user_factory(), - emanifest=emanifest, - ) - - return create_permission - - -@pytest.fixture -def user_with_org_factory( - db, - user_factory, - org_factory, - rcrainfo_profile_factory, - profile_factory, - org_access_factory, -): - """Fixture for creating a user with an org that has set up RCRAInfo integration""" - - def create_fixtures( - user: Optional[User] = None, - org: Optional[Org] = None, - admin_rcrainfo_profile: Optional[RcrainfoProfile] = None, - is_rcrainfo_enabled: Optional[bool] = True, - ): - if is_rcrainfo_enabled: - rcra_profile_data = { - "rcra_api_id": "mock_api_id", - "rcra_api_key": "mock_api_key", - "rcra_username": "mock_username", - } - else: - rcra_profile_data = {"rcra_api_id": None, "rcra_api_key": None, "rcra_username": None} - user = user or user_factory() - admin = user_factory(username="admin") - admin_rcrainfo_profile or rcrainfo_profile_factory(**rcra_profile_data) - org = org or org_factory(admin=admin) - org_access_factory(org=org, user=user) - profile_factory(user=user) - return user, org - - return create_fixtures - - -@pytest.fixture -def org_access_factory(db, user_factory, org_factory): - """Abstract factory for creating a model that represents a user's access to an organization""" - - def create_permission( - org: Optional[Org] = None, - user: Optional[TrakUser] = None, - ) -> OrgAccess: - return OrgAccess.objects.create( - org=org or org_factory(), - user=user or user_factory(), - ) - - return create_permission diff --git a/server/apps/manifest/migrations/0001_initial.py b/server/apps/manifest/migrations/0001_initial.py deleted file mode 100644 index 05193bc0c..000000000 --- a/server/apps/manifest/migrations/0001_initial.py +++ /dev/null @@ -1,88 +0,0 @@ -# Generated by Django 4.2.10 on 2024-02-21 22:17 - -import apps.manifest.models -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('handler', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='AdditionalInfo', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('original_mtn', models.JSONField(blank=True, help_text='Original manifest tracking number of rejected manifestRegex expression validation: [0-9]{9}[A-Z]{3}', null=True, validators=[apps.manifest.models.validate_mtn])), - ('new_destination', models.CharField(blank=True, choices=[('GEN', 'Generator'), ('TSD', 'Tsdf')], help_text='Destination of the new manifest created during rejection or residue.', max_length=255, null=True)), - ('consent_number', models.CharField(blank=True, max_length=12, null=True)), - ('comments', models.JSONField(blank=True, null=True)), - ('handling_instructions', models.CharField(blank=True, help_text='Special Handling Instructions', max_length=4000, null=True)), - ], - options={ - 'verbose_name': 'Additional Info', - 'verbose_name_plural': 'Additional Info', - }, - ), - migrations.CreateModel( - name='PortOfEntry', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('state', models.CharField(blank=True, choices=[('AK', 'Alaska'), ('AL', 'Alabama'), ('AP', 'Armed Forces Pacific'), ('AR', 'Arkansas'), ('AZ', 'Arizona'), ('CA', 'California'), ('CO', 'Colorado'), ('CT', 'Connecticut'), ('DC', 'Washington DC'), ('DE', 'Delaware'), ('FL', 'Florida'), ('GA', 'Georgia'), ('GU', 'Guam'), ('HI', 'Hawaii'), ('IA', 'Iowa'), ('ID', 'Idaho'), ('IL', 'Illinois'), ('IN', 'Indiana'), ('KS', 'Kansas'), ('KY', 'Kentucky'), ('LA', 'Louisiana'), ('MA', 'Massachusetts'), ('MD', 'Maryland'), ('ME', 'Maine'), ('MI', 'Michigan'), ('MN', 'Minnesota'), ('MO', 'Missouri'), ('MS', 'Mississippi'), ('MT', 'Montana'), ('NC', 'North Carolina'), ('ND', 'North Dakota'), ('NE', 'Nebraska'), ('NH', 'New Hampshire'), ('NJ', 'New Jersey'), ('NM', 'New Mexico'), ('NV', 'Nevada'), ('NY', 'New York'), ('OH', 'Ohio'), ('OK', 'Oklahoma'), ('OR', 'Oregon'), ('PA', 'Pennsylvania'), ('PR', 'Puerto Rico'), ('RI', 'Rhode Island'), ('SC', 'South Carolina'), ('SD', 'South Dakota'), ('TN', 'Tennessee'), ('TX', 'Texas'), ('UT', 'Utah'), ('VA', 'Virginia'), ('VI', 'Virgin Islands'), ('VT', 'Vermont'), ('WA', 'Washington'), ('WI', 'Wisconsin'), ('WV', 'West Virginia'), ('WY', 'Wyoming'), ('XA', 'REGION 01 PURVIEW'), ('XB', 'REGION 02 PURVIEW'), ('XC', 'REGION 03 PURVIEW'), ('XD', 'REGION 04 PURVIEW'), ('XE', 'REGION 05 PURVIEW'), ('XF', 'REGION 06 PURVIEW'), ('XG', 'REGION 07 PURVIEW'), ('XH', 'REGION 08 PURVIEW'), ('XI', 'REGION 09 PURVIEW'), ('XJ', 'REGION 10 PURVIEW')], max_length=2, null=True)), - ('city_port', models.CharField(blank=True, max_length=100, null=True)), - ], - options={ - 'verbose_name': 'Port of Entry', - 'verbose_name_plural': 'Ports of Entry', - }, - ), - migrations.CreateModel( - name='Manifest', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created_date', models.DateTimeField(auto_now=True, null=True)), - ('update_date', models.DateTimeField(auto_now=True)), - ('mtn', models.CharField(default=apps.manifest.models.draft_mtn, max_length=30, unique=True, validators=[apps.manifest.models.validate_mtn], verbose_name='manifest Tracking Number')), - ('status', models.CharField(choices=[('NotAssigned', 'Not Assigned'), ('Pending', 'Pending'), ('Scheduled', 'Scheduled'), ('InTransit', 'In Transit'), ('ReadyForSignature', 'Ready for Signature'), ('Signed', 'Signed'), ('Corrected', 'Corrected'), ('UnderCorrection', 'Under Correction'), ('MtnValidationFailed', 'MTN Validation Failed')], default='NotAssigned', max_length=25)), - ('submission_type', models.CharField(choices=[('FullElectronic', 'Full Electronic'), ('DataImage5Copy', 'Data + Image'), ('Hybrid', 'Hybrid'), ('Image', 'Image')], default='FullElectronic', max_length=25)), - ('signature_status', models.BooleanField(blank=True, null=True)), - ('origin_type', models.CharField(choices=[('Web', 'Web'), ('Service', 'Service'), ('Mail', 'Mail')], default='Service', max_length=25)), - ('shipped_date', models.DateTimeField(blank=True, null=True)), - ('potential_ship_date', models.DateTimeField(blank=True, null=True, verbose_name='potential ship date')), - ('received_date', models.DateTimeField(blank=True, null=True)), - ('certified_date', models.DateTimeField(blank=True, null=True)), - ('certified_by', models.JSONField(blank=True, null=True)), - ('broker', models.JSONField(blank=True, null=True)), - ('rejection', models.BooleanField(blank=True, null=True)), - ('rejection_info', models.JSONField(blank=True, null=True, verbose_name='Rejection Information')), - ('discrepancy', models.BooleanField(blank=True, default=False)), - ('residue', models.BooleanField(blank=True, default=False)), - ('residue_new_mtn', models.JSONField(blank=True, default=list, verbose_name='residue new MTN')), - ('import_flag', models.BooleanField(blank=True, default=False, verbose_name='import')), - ('import_info', models.JSONField(blank=True, null=True, verbose_name='import information')), - ('contains_residue_or_rejection', models.BooleanField(blank=True, null=True, verbose_name='contains previous rejection or residue waste')), - ('printed_document', models.JSONField(blank=True, null=True)), - ('form_document', models.JSONField(blank=True, null=True)), - ('correction_info', models.JSONField(blank=True, null=True)), - ('ppc_status', models.JSONField(blank=True, null=True, verbose_name='PPC info')), - ('locked', models.BooleanField(blank=True, null=True)), - ('lock_reason', models.CharField(blank=True, choices=[('ACS', 'AsyncSign'), ('ECB', 'EpaChangeBiller'), ('EPC', 'EpaCorrection')], max_length=25, null=True)), - ('transfer_requested', models.BooleanField(blank=True, null=True)), - ('transfer_status', models.CharField(blank=True, max_length=200, null=True)), - ('original_sub_type', models.CharField(blank=True, choices=[('FullElectronic', 'Full Electronic'), ('DataImage5Copy', 'Data + Image'), ('Hybrid', 'Hybrid'), ('Image', 'Image')], max_length=25, null=True, verbose_name='original submission type')), - ('transfer_count', models.IntegerField(blank=True, null=True)), - ('next_transfer_time', models.DateTimeField(blank=True, null=True, verbose_name='next transfer time')), - ('additional_info', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='manifest.additionalinfo')), - ('generator', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='generator', to='handler.handler')), - ('tsdf', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='designated_facility', to='handler.handler', verbose_name='designated facility')), - ], - options={ - 'ordering': ['update_date', 'mtn'], - }, - ), - ] diff --git a/server/apps/rcrasite/migrations/0001_initial.py b/server/apps/rcrasite/migrations/0001_initial.py deleted file mode 100644 index 1f43f66b7..000000000 --- a/server/apps/rcrasite/migrations/0001_initial.py +++ /dev/null @@ -1,86 +0,0 @@ -# Generated by Django 4.2.10 on 2024-02-21 22:17 - -import apps.rcrasite.models.contact -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='Address', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('street_number', models.CharField(blank=True, max_length=12, null=True)), - ('address1', models.CharField(max_length=50, verbose_name='address 1')), - ('address2', models.CharField(blank=True, default=None, max_length=50, null=True, verbose_name='address 2')), - ('city', models.CharField(blank=True, max_length=25, null=True)), - ('state', models.CharField(blank=True, choices=[('AK', 'Alaska'), ('AL', 'Alabama'), ('AP', 'Armed Forces Pacific'), ('AR', 'Arkansas'), ('AZ', 'Arizona'), ('CA', 'California'), ('CO', 'Colorado'), ('CT', 'Connecticut'), ('DC', 'Washington DC'), ('DE', 'Delaware'), ('FL', 'Florida'), ('GA', 'Georgia'), ('GU', 'Guam'), ('HI', 'Hawaii'), ('IA', 'Iowa'), ('ID', 'Idaho'), ('IL', 'Illinois'), ('IN', 'Indiana'), ('KS', 'Kansas'), ('KY', 'Kentucky'), ('LA', 'Louisiana'), ('MA', 'Massachusetts'), ('MD', 'Maryland'), ('ME', 'Maine'), ('MI', 'Michigan'), ('MN', 'Minnesota'), ('MO', 'Missouri'), ('MS', 'Mississippi'), ('MT', 'Montana'), ('NC', 'North Carolina'), ('ND', 'North Dakota'), ('NE', 'Nebraska'), ('NH', 'New Hampshire'), ('NJ', 'New Jersey'), ('NM', 'New Mexico'), ('NV', 'Nevada'), ('NY', 'New York'), ('OH', 'Ohio'), ('OK', 'Oklahoma'), ('OR', 'Oregon'), ('PA', 'Pennsylvania'), ('PR', 'Puerto Rico'), ('RI', 'Rhode Island'), ('SC', 'South Carolina'), ('SD', 'South Dakota'), ('TN', 'Tennessee'), ('TX', 'Texas'), ('UT', 'Utah'), ('VA', 'Virginia'), ('VI', 'Virgin Islands'), ('VT', 'Vermont'), ('WA', 'Washington'), ('WI', 'Wisconsin'), ('WV', 'West Virginia'), ('WY', 'Wyoming'), ('XA', 'REGION 01 PURVIEW'), ('XB', 'REGION 02 PURVIEW'), ('XC', 'REGION 03 PURVIEW'), ('XD', 'REGION 04 PURVIEW'), ('XE', 'REGION 05 PURVIEW'), ('XF', 'REGION 06 PURVIEW'), ('XG', 'REGION 07 PURVIEW'), ('XH', 'REGION 08 PURVIEW'), ('XI', 'REGION 09 PURVIEW'), ('XJ', 'REGION 10 PURVIEW')], max_length=3, null=True)), - ('country', models.CharField(blank=True, choices=[('US', 'United States'), ('MX', 'Mexico'), ('CA', 'Canada')], max_length=3, null=True)), - ('zip', models.CharField(blank=True, max_length=5, null=True)), - ], - options={ - 'ordering': ['address1'], - }, - ), - migrations.CreateModel( - name='Contact', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('first_name', models.CharField(blank=True, max_length=38, null=True)), - ('middle_initial', models.CharField(blank=True, max_length=1, null=True)), - ('last_name', models.CharField(blank=True, max_length=38, null=True)), - ('email', models.EmailField(blank=True, max_length=254, null=True)), - ('company_name', models.CharField(blank=True, max_length=80, null=True)), - ], - options={ - 'ordering': ['first_name'], - }, - ), - migrations.CreateModel( - name='RcraPhone', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('number', apps.rcrasite.models.contact.RcraPhoneNumber(max_length=12)), - ('extension', models.CharField(blank=True, max_length=6, null=True)), - ], - options={ - 'ordering': ['number'], - }, - ), - migrations.CreateModel( - name='RcraSite', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('site_type', models.CharField(blank=True, choices=[('Generator', 'Generator'), ('Transporter', 'Transporter'), ('Tsdf', 'Tsdf'), ('Broker', 'Broker')], max_length=20, null=True)), - ('epa_id', models.CharField(max_length=25, unique=True, verbose_name='EPA ID number')), - ('name', models.CharField(max_length=200)), - ('modified', models.BooleanField(blank=True, null=True)), - ('registered', models.BooleanField(blank=True, null=True)), - ('gis_primary', models.BooleanField(blank=True, default=False, null=True, verbose_name='GIS primary')), - ('can_esign', models.BooleanField(blank=True, null=True, verbose_name='can electronically sign')), - ('limited_esign', models.BooleanField(blank=True, null=True, verbose_name='limited electronic signing ability')), - ('registered_emanifest_user', models.BooleanField(blank=True, default=False, null=True, verbose_name='has registered e-manifest user')), - ('contact', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rcrasite.contact', verbose_name='contact information')), - ('emergency_phone', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='rcrasite.rcraphone')), - ('mail_address', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mail_address', to='rcrasite.address')), - ('site_address', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='site_address', to='rcrasite.address')), - ], - options={ - 'verbose_name': 'RCRAInfo Site', - 'verbose_name_plural': 'RCRAInfo Sites', - 'ordering': ['epa_id'], - }, - ), - migrations.AddField( - model_name='contact', - name='phone', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='rcrasite.rcraphone'), - ), - ] diff --git a/server/apps/site/migrations/0001_initial.py b/server/apps/site/migrations/0001_initial.py deleted file mode 100644 index 3771f0ba1..000000000 --- a/server/apps/site/migrations/0001_initial.py +++ /dev/null @@ -1,49 +0,0 @@ -# Generated by Django 5.0.4 on 2024-05-11 23:37 - -import django.core.validators -import django.db.models.deletion -from django.conf import settings -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('org', '0001_initial'), - ('rcrasite', '0001_initial'), - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='Site', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=200, validators=[django.core.validators.MinLengthValidator(2, 'site aliases must be longer than 2 characters')], verbose_name='site alias')), - ('last_rcrainfo_manifest_sync', models.DateTimeField(blank=True, null=True, verbose_name='last RCRAInfo manifest sync date')), - ('org', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='org.trakorg')), - ('rcra_site', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='rcrasite.rcrasite', verbose_name='rcra_site')), - ], - options={ - 'verbose_name': 'Haztrak Site', - 'verbose_name_plural': 'Haztrak Sites', - 'ordering': ['rcra_site__epa_id'], - }, - ), - migrations.CreateModel( - name='SiteAccess', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('emanifest', models.CharField(choices=[('viewer', 'view'), ('editor', 'edit'), ('signer', 'sign')], default='view', max_length=6)), - ('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='site.site')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='site_permissions', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'verbose_name': 'New Site Permission', - 'verbose_name_plural': 'New Site Permissions', - 'ordering': ['user'], - }, - ), - ] diff --git a/server/apps/site/migrations/0002_alter_siteaccess_options_sitegroupobjectpermission_and_more.py b/server/apps/site/migrations/0002_alter_siteaccess_options_sitegroupobjectpermission_and_more.py deleted file mode 100644 index 000941b3e..000000000 --- a/server/apps/site/migrations/0002_alter_siteaccess_options_sitegroupobjectpermission_and_more.py +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by Django 5.0.6 on 2024-07-22 19:25 - -import django.db.models.deletion -from django.conf import settings -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('auth', '0012_alter_user_first_name_max_length'), - ('site', '0001_initial'), - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.AlterModelOptions( - name='siteaccess', - options={'ordering': ['user'], 'verbose_name': 'Site Permission', 'verbose_name_plural': 'Site Permissions'}, - ), - migrations.CreateModel( - name='SiteGroupObjectPermission', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('content_object', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='site.site')), - ('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.group')), - ('permission', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.permission')), - ], - options={ - 'abstract': False, - 'unique_together': {('group', 'permission', 'content_object')}, - }, - ), - migrations.CreateModel( - name='SiteUserObjectPermission', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('content_object', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='site.site')), - ('permission', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.permission')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - options={ - 'abstract': False, - 'unique_together': {('user', 'permission', 'content_object')}, - }, - ), - ] diff --git a/server/apps/site/migrations/0003_alter_sitegroupobjectpermission_options_and_more.py b/server/apps/site/migrations/0003_alter_sitegroupobjectpermission_options_and_more.py deleted file mode 100644 index fd0d940b9..000000000 --- a/server/apps/site/migrations/0003_alter_sitegroupobjectpermission_options_and_more.py +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by Django 5.0.7 on 2024-07-22 20:17 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('site', '0002_alter_siteaccess_options_sitegroupobjectpermission_and_more'), - ] - - operations = [ - migrations.AlterModelOptions( - name='sitegroupobjectpermission', - options={'verbose_name': 'Site Role', 'verbose_name_plural': 'Site Roles'}, - ), - migrations.AlterModelOptions( - name='siteuserobjectpermission', - options={'verbose_name': 'Site Permission', 'verbose_name_plural': 'Site Permissions'}, - ), - ] diff --git a/server/conftest.py b/server/conftest.py index 08affc7ec..e1683b9a1 100644 --- a/server/conftest.py +++ b/server/conftest.py @@ -1,4 +1,380 @@ +import datetime +import json +import os +import random +import string +from enum import Enum +from profile.models import Profile, RcrainfoProfile +from typing import Dict, Literal, Optional + import pytest +import pytest_mock +import responses +from django.contrib.auth.models import User +from django.db import IntegrityError +from faker import Faker +from faker.providers import BaseProvider +from rest_framework.test import APIClient + +from core.models import ( + TrakUser, +) +from org.models import Org, OrgAccess +from orgsite.models import Site, SiteAccess +from rcrasite.models import ( + Address, + Contact, + RcraPhone, + RcraSite, +) + + +class SiteIDProvider(BaseProvider): + PREFIXES = ["VAT", "VAD", "TXD", "TXR", "TND", "TNR", "LAD", "LAR", "CAD", "CAR", "MAD", "MAR"] + NUMBERS = ["".join(random.choices(string.digits, k=9)) for _ in range(100)] + + def site_id(self): + return f"{self.random_element(self.PREFIXES)}{self.random_element(self.NUMBERS)}" + + +@pytest.fixture +def haztrak_json(): + """Fixture with JSON data""" + json_dir = os.path.dirname(os.path.abspath(__file__)) + "/fixtures/json" + + def read_file(path: str) -> Dict: + with open(path) as f: + return json.load(f) + + class Json(Enum): + CONTACT = read_file(f"{json_dir}/contact/good_contact.json") + PHONE = read_file(f"{json_dir}/contact/phone.json") + WASTELINE_1 = read_file(f"{json_dir}/test_wasteline1.json") + MANIFEST = read_file(f"{json_dir}/test_manifest_100033134ELC.json") + SITE_PERMISSION = read_file(f"{json_dir}/site_permission.json") + EPA_PERMISSION = read_file(f"{json_dir}/epa_permission.json") + HANDLER = read_file(f"{json_dir}/test_handler.json") + PAPER_MANIFEST_HANDLER = read_file(f"{json_dir}/paper_manifest_handler.json") + E_SIGNATURE = read_file(f"{json_dir}/test_e_signature.json") + + return Json + + +@pytest.fixture +def user_factory(db, faker): + """Abstract factory for Django's User model""" + + def create_user( + username: Optional[str] = None, + first_name: Optional[str] = None, + last_name: Optional[str] = None, + email: Optional[str] = None, + password: Optional[str] = None, + ) -> TrakUser: + return TrakUser.objects.create_user( + username=username or faker.user_name(), + first_name=first_name or faker.first_name(), + last_name=last_name or faker.last_name(), + email=email or faker.email(), + password=password or faker.password(), + ) + + return create_user + + +@pytest.fixture +def rcrainfo_profile_factory(db, user_factory, faker: Faker): + """Abstract factory for Haztrak RcrainfoProfile model""" + + def create_profile( + rcra_api_id: Optional[str] = str(faker.uuid4()), + rcra_api_key: Optional[str] = faker.pystr(min_chars=15), + rcra_username: Optional[str] = faker.pystr(min_chars=12), + ) -> RcrainfoProfile: + return RcrainfoProfile.objects.create( + rcra_api_id=rcra_api_id, + rcra_api_key=rcra_api_key, + rcra_username=rcra_username, + ) + + return create_profile + + +@pytest.fixture +def profile_factory(db, user_factory, rcrainfo_profile_factory, org_factory): + """Abstract factory for Haztrak RcrainfoProfile model""" + + def create_profile( + user: Optional[User] = None, + rcrainfo_profile: Optional[RcrainfoProfile] = rcrainfo_profile_factory(), + ) -> Profile: + return Profile.objects.create( + user=user or user_factory(), + rcrainfo_profile=rcrainfo_profile, + ) + + return create_profile + + +@pytest.fixture +def address_factory(db, faker: Faker): + """Abstract factory for Haztrak Address model""" + + def create_address( + address1: Optional[str] = None, + street_number: Optional[str] = None, + country: Optional[str] = "US", + city: Optional[str] = None, + ) -> Address: + return Address.objects.create( + address1=address1 or faker.street_name(), + street_number=street_number or faker.building_number(), + country=country, + city=city or faker.city(), + ) + + return create_address + + +@pytest.fixture +def rcra_phone_factory(db, faker: Faker): + """Abstract factory for Haztrak ManifestPhone model""" + + def create_site_phone( + number: Optional[str] = "202-505-5500", + extension: Optional[str] = "1234", + ) -> RcraPhone: + return RcraPhone.objects.create( + number=number, + extension=extension, + ) + + return create_site_phone + + +@pytest.fixture +def contact_factory(db, rcra_phone_factory, faker: Faker): + """Abstract factory for Haztrak Contact model""" + + def create_contact( + first_name: Optional[str] = None, + middle_initial: Optional[str] = None, + last_name: Optional[str] = None, + email: Optional[str] = None, + phone: Optional[RcraPhone] = None, + ) -> Contact: + contact = Contact.objects.create( + first_name=first_name or faker.first_name(), + middle_initial=middle_initial or faker.pystr(max_chars=1), + last_name=last_name or faker.last_name(), + email=email or faker.email(), + phone=phone or rcra_phone_factory(), + ) + return contact + + return create_contact + + +@pytest.fixture +def rcra_site_factory(db, address_factory, contact_factory): + """Abstract factory for Haztrak RcraSite model""" + + def create_rcra_site( + epa_id: Optional[str] = None, + name: Optional[str] = None, + site_type: Optional[Literal["Generator", "Transporter", "Tsdf"]] = "Generator", + site_address: Optional[Address] = None, + mail_address: Optional[Address] = None, + ) -> RcraSite: + fake = Faker() + fake.add_provider(SiteIDProvider) + while True: + try: + return RcraSite.objects.create( + epa_id=epa_id or fake.site_id(), + name=name or fake.name(), + site_type=site_type, + site_address=site_address or address_factory(), + mail_address=mail_address or address_factory(), + contact=contact_factory(), + ) + except IntegrityError: + return RcraSite.objects.create( + epa_id=fake.site_id(), + name=name or fake.name(), + site_type=site_type, + site_address=site_address or address_factory(), + mail_address=mail_address or address_factory(), + contact=contact_factory(), + ) + + return create_rcra_site + + +@pytest.fixture +def validated_data_factory(): + def _create_data_dict(*, instance, serializer) -> Dict: + data = serializer(instance).data + new_serializer = serializer(data=data) + new_serializer.is_valid(raise_exception=True) + return new_serializer.validated_data + + return _create_data_dict + + +@pytest.fixture +def org_factory(db, rcrainfo_profile_factory, user_factory, faker): + """Abstract factory for Haztrak Org model""" + + def create_org( + org_id: Optional[str] = None, + name: Optional[str] = None, + admin: Optional[TrakUser] = None, + ) -> Org: + return Org.objects.create( + id=org_id or faker.uuid4(), + name=name or faker.company(), + admin=admin or user_factory(), + ) + + return create_org + + +@pytest.fixture +def site_factory(db, rcra_site_factory, org_factory, faker): + """Abstract factory for Haztrak Site model""" + + def create_site( + rcra_site: Optional[RcraSite] = None, + name: Optional[str] = None, + org: Optional[Org] = None, + last_rcrainfo_manifest_sync: Optional[datetime.datetime] = None, + ) -> Site: + return Site.objects.create( + rcra_site=rcra_site or rcra_site_factory(), + name=name or faker.name(), + org=org or org_factory(), + last_rcrainfo_manifest_sync=last_rcrainfo_manifest_sync + or datetime.datetime.now(datetime.UTC), + ) + + return create_site + + +@pytest.fixture +def api_client_factory(db, user_factory): + """Abstract factory for DRF APIClient testing class""" + + def create_client( + user: Optional[User] = None, + ) -> APIClient: + client = APIClient() + client.force_authenticate( + user=user or user_factory(), + ) + return client + + return create_client + + +@pytest.fixture +def mock_responses(): + """ + fixture for mocking external http request responses + see Responses docs + https://github.com/getsentry/responses#responses-as-a-pytest-fixture + """ + with responses.RequestsMock() as mock_responses: + yield mock_responses + + +@pytest.fixture() +def mock_emanifest_auth_response(request, mock_responses): + api_id, api_key = request.param + mock_responses.get( + f"https://rcrainfopreprod.epa.gov/rcrainfo/rest/api/v1/auth/{api_id}/{api_key}", + body='{"token": "mocK_token", "expiration": "2021-01-01T00:00:00.000000Z"}', + ) + + +@pytest.fixture +def mocker(mocker: pytest_mock.MockerFixture): + """ + wrapper fixture pytest-mock's mocker fixture for easy type annotations + https://github.com/pytest-dev/pytest-mock + """ + return mocker + + +@pytest.fixture +def site_access_factory(db, faker, site_factory, profile_factory): + """Abstract factory for Haztrak RcraSitePermissions model""" + + def create_permission( + site: Optional[Site] = None, + user: Optional[TrakUser] = None, + emanifest: Optional[Literal["viewer", "signer", "editor"]] = "viewer", + ) -> SiteAccess: + """Returns testuser1 RcraSitePermissions model to site_generator""" + return SiteAccess.objects.create( + site=site or site_factory(), + user=user or user_factory(), + emanifest=emanifest, + ) + + return create_permission + + +@pytest.fixture +def user_with_org_factory( + db, + user_factory, + org_factory, + rcrainfo_profile_factory, + profile_factory, + org_access_factory, +): + """Fixture for creating a user with an org that has set up RCRAInfo integration""" + + def create_fixtures( + user: Optional[User] = None, + org: Optional[Org] = None, + admin_rcrainfo_profile: Optional[RcrainfoProfile] = None, + is_rcrainfo_enabled: Optional[bool] = True, + ): + if is_rcrainfo_enabled: + rcra_profile_data = { + "rcra_api_id": "mock_api_id", + "rcra_api_key": "mock_api_key", + "rcra_username": "mock_username", + } + else: + rcra_profile_data = {"rcra_api_id": None, "rcra_api_key": None, "rcra_username": None} + user = user or user_factory() + admin = user_factory(username="admin") + admin_rcrainfo_profile or rcrainfo_profile_factory(**rcra_profile_data) + org = org or org_factory(admin=admin) + org_access_factory(org=org, user=user) + profile_factory(user=user) + return user, org + + return create_fixtures + + +@pytest.fixture +def org_access_factory(db, user_factory, org_factory): + """Abstract factory for creating a model that represents a user's access to an organization""" + + def create_permission( + org: Optional[Org] = None, + user: Optional[TrakUser] = None, + ) -> OrgAccess: + return OrgAccess.objects.create( + org=org or org_factory(), + user=user or user_factory(), + ) + + return create_permission @pytest.fixture(autouse=True) diff --git a/server/apps/core/__init__.py b/server/core/__init__.py similarity index 100% rename from server/apps/core/__init__.py rename to server/core/__init__.py diff --git a/server/apps/core/admin.py b/server/core/admin.py similarity index 96% rename from server/apps/core/admin.py rename to server/core/admin.py index 2f4a1b7a3..d769d5524 100644 --- a/server/apps/core/admin.py +++ b/server/core/admin.py @@ -1,10 +1,10 @@ +from profile.models import Profile, RcrainfoProfile, RcrainfoSiteAccess + from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.urls import reverse from django.utils.html import format_html, urlencode -from apps.profile.models import Profile, RcrainfoProfile, RcrainfoSiteAccess - from .models import GroupPermission, TrakUser, UserPermission diff --git a/server/apps/core/apps.py b/server/core/apps.py similarity index 87% rename from server/apps/core/apps.py rename to server/core/apps.py index d93b15d61..b0246f7df 100644 --- a/server/apps/core/apps.py +++ b/server/core/apps.py @@ -3,7 +3,7 @@ class CoreConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" - name = "apps.core" + name = "core" def ready(self): pass diff --git a/server/apps/core/exceptions.py b/server/core/exceptions.py similarity index 97% rename from server/apps/core/exceptions.py rename to server/core/exceptions.py index 5ff5af00c..f4e6cbe5c 100644 --- a/server/apps/core/exceptions.py +++ b/server/core/exceptions.py @@ -6,7 +6,7 @@ from rest_framework.serializers import as_serializer_error from rest_framework.views import exception_handler -from apps.site.services import SiteServiceError +from orgsite.services import SiteServiceError class InternalServer500(APIException): diff --git a/server/apps/core/management/__init__.py b/server/core/management/__init__.py similarity index 100% rename from server/apps/core/management/__init__.py rename to server/core/management/__init__.py diff --git a/server/apps/core/management/commands/__init__.py b/server/core/management/commands/__init__.py similarity index 100% rename from server/apps/core/management/commands/__init__.py rename to server/core/management/commands/__init__.py diff --git a/server/apps/core/management/commands/celery_beat.py b/server/core/management/commands/celery_beat.py similarity index 97% rename from server/apps/core/management/commands/celery_beat.py rename to server/core/management/commands/celery_beat.py index b3bd65cf6..651909eb8 100644 --- a/server/apps/core/management/commands/celery_beat.py +++ b/server/core/management/commands/celery_beat.py @@ -8,7 +8,7 @@ from django.utils import autoreload from django_celery_beat.models import CrontabSchedule, IntervalSchedule, PeriodicTask -from apps.wasteline.tasks import pull_federal_codes +from wasteline.tasks import pull_federal_codes CELERY_LOG_LEVEL = os.getenv("CELERY_LOG_LEVEL", "INFO") logger = logging.getLogger(__name__) diff --git a/server/apps/core/management/commands/celery_worker.py b/server/core/management/commands/celery_worker.py similarity index 100% rename from server/apps/core/management/commands/celery_worker.py rename to server/core/management/commands/celery_worker.py diff --git a/server/apps/core/migrations/0001_initial.py b/server/core/migrations/0001_initial.py similarity index 100% rename from server/apps/core/migrations/0001_initial.py rename to server/core/migrations/0001_initial.py diff --git a/server/apps/core/migrations/0002_permission.py b/server/core/migrations/0002_permission.py similarity index 100% rename from server/apps/core/migrations/0002_permission.py rename to server/core/migrations/0002_permission.py diff --git a/server/apps/core/migrations/0003_role.py b/server/core/migrations/0003_role.py similarity index 100% rename from server/apps/core/migrations/0003_role.py rename to server/core/migrations/0003_role.py diff --git a/server/apps/core/migrations/0004_grouppermission_userpermission.py b/server/core/migrations/0004_grouppermission_userpermission.py similarity index 100% rename from server/apps/core/migrations/0004_grouppermission_userpermission.py rename to server/core/migrations/0004_grouppermission_userpermission.py diff --git a/server/apps/core/migrations/0005_remove_role_permissions_delete_permission_and_more.py b/server/core/migrations/0005_remove_role_permissions_delete_permission_and_more.py similarity index 100% rename from server/apps/core/migrations/0005_remove_role_permissions_delete_permission_and_more.py rename to server/core/migrations/0005_remove_role_permissions_delete_permission_and_more.py diff --git a/server/apps/core/migrations/__init__.py b/server/core/migrations/__init__.py similarity index 100% rename from server/apps/core/migrations/__init__.py rename to server/core/migrations/__init__.py diff --git a/server/apps/core/models.py b/server/core/models.py similarity index 100% rename from server/apps/core/models.py rename to server/core/models.py diff --git a/server/apps/core/serializers.py b/server/core/serializers.py similarity index 98% rename from server/apps/core/serializers.py rename to server/core/serializers.py index 885211b2f..b26426781 100644 --- a/server/apps/core/serializers.py +++ b/server/core/serializers.py @@ -4,7 +4,7 @@ from rest_framework import serializers from rest_framework.serializers import ModelSerializer -from apps.core.models import ( +from core.models import ( TrakUser, ) diff --git a/server/apps/core/services/__init__.py b/server/core/services/__init__.py similarity index 100% rename from server/apps/core/services/__init__.py rename to server/core/services/__init__.py diff --git a/server/apps/core/services/rcrainfo_service.py b/server/core/services/rcrainfo_service.py similarity index 97% rename from server/apps/core/services/rcrainfo_service.py rename to server/core/services/rcrainfo_service.py index 7ec4242a4..4d6b35004 100644 --- a/server/apps/core/services/rcrainfo_service.py +++ b/server/core/services/rcrainfo_service.py @@ -1,13 +1,13 @@ import logging +from profile.models import RcrainfoProfile from typing import Literal, Optional import emanifest from django.db import IntegrityError from emanifest import RcrainfoClient, RcrainfoResponse -from apps.org.models import Org -from apps.profile.models import RcrainfoProfile -from apps.wasteline.models import WasteCode +from org.models import Org +from wasteline.models import WasteCode logger = logging.getLogger(__name__) diff --git a/server/apps/core/services/task_service.py b/server/core/services/task_service.py similarity index 97% rename from server/apps/core/services/task_service.py rename to server/core/services/task_service.py index e481bac17..c7967645f 100644 --- a/server/apps/core/services/task_service.py +++ b/server/core/services/task_service.py @@ -7,8 +7,8 @@ from rest_framework.exceptions import ValidationError from rest_framework.utils.serializer_helpers import ReturnDict -from apps.core.serializers import TaskStatusSerializer # type: ignore -from apps.core.tasks import example_task # type: ignore +from core.serializers import TaskStatusSerializer # type: ignore +from core.tasks import example_task # type: ignore logger = logging.getLogger(__name__) diff --git a/server/apps/core/signals.py b/server/core/signals.py similarity index 89% rename from server/apps/core/signals.py rename to server/core/signals.py index 428ad9c8f..b959df907 100644 --- a/server/apps/core/signals.py +++ b/server/core/signals.py @@ -1,9 +1,9 @@ +from profile.models import RcrainfoProfile + from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver -from apps.profile.models import RcrainfoProfile - @receiver(post_save, sender=User) def create_profile(sender, instance, created, **kwargs): diff --git a/server/apps/core/tasks.py b/server/core/tasks.py similarity index 100% rename from server/apps/core/tasks.py rename to server/core/tasks.py diff --git a/server/apps/core/tests/__init__.py b/server/core/tests/__init__.py similarity index 100% rename from server/apps/core/tests/__init__.py rename to server/core/tests/__init__.py diff --git a/server/apps/core/tests/conftest.py b/server/core/tests/conftest.py similarity index 96% rename from server/apps/core/tests/conftest.py rename to server/core/tests/conftest.py index ab40962dd..e5a7b04cf 100644 --- a/server/apps/core/tests/conftest.py +++ b/server/core/tests/conftest.py @@ -4,7 +4,7 @@ import pytest from faker import Faker -from apps.rcrasite.models import RcraSiteType +from rcrasite.models import RcraSiteType @pytest.fixture diff --git a/server/apps/core/tests/test_exceptions.py b/server/core/tests/test_exceptions.py similarity index 86% rename from server/apps/core/tests/test_exceptions.py rename to server/core/tests/test_exceptions.py index 2494b5b54..407e4204d 100644 --- a/server/apps/core/tests/test_exceptions.py +++ b/server/core/tests/test_exceptions.py @@ -1,7 +1,7 @@ from django.http import Http404 from rest_framework import status -from apps.core.exceptions import haztrak_exception_handler +from core.exceptions import haztrak_exception_handler class TestTrakExceptionHandler: diff --git a/server/apps/core/tests/test_rcrainfo_service.py b/server/core/tests/test_rcrainfo_service.py similarity index 96% rename from server/apps/core/tests/test_rcrainfo_service.py rename to server/core/tests/test_rcrainfo_service.py index 24c370e0c..8fc2cc53a 100644 --- a/server/apps/core/tests/test_rcrainfo_service.py +++ b/server/core/tests/test_rcrainfo_service.py @@ -4,9 +4,9 @@ from responses import matchers from rest_framework import status -from apps.core.services import RcraClient, get_rcra_client -from apps.handler.models import QuickerSign -from apps.handler.serializers import QuickerSignSerializer +from core.services import RcraClient, get_rcra_client +from handler.models import QuickerSign +from handler.serializers import QuickerSignSerializer class TestRcrainfoService: diff --git a/server/apps/core/tests/test_tasks.py b/server/core/tests/test_tasks.py similarity index 96% rename from server/apps/core/tests/test_tasks.py rename to server/core/tests/test_tasks.py index 43092b2a8..d6e7d2ee3 100644 --- a/server/apps/core/tests/test_tasks.py +++ b/server/core/tests/test_tasks.py @@ -5,8 +5,8 @@ from rest_framework.response import Response from rest_framework.test import APIRequestFactory, force_authenticate -from apps.core.services.task_service import TaskService -from apps.core.views import TaskStatusView +from core.services.task_service import TaskService +from core.views import TaskStatusView class TestTaskStatusView: diff --git a/server/apps/core/tests/test_views.py b/server/core/tests/test_views.py similarity index 89% rename from server/apps/core/tests/test_views.py rename to server/core/tests/test_views.py index 1ac0e3db4..4342e38fa 100644 --- a/server/apps/core/tests/test_views.py +++ b/server/core/tests/test_views.py @@ -6,7 +6,7 @@ from rest_framework.reverse import reverse from rest_framework.test import APIRequestFactory, force_authenticate -from apps.core.views import LaunchExampleTaskView, TaskStatusView +from core.views import LaunchExampleTaskView, TaskStatusView class TestUserViews: @@ -34,7 +34,7 @@ def factory(self): return APIRequestFactory() def test_successful_launch(self, factory): - with mock.patch("apps.core.views.launch_example_task") as mock_task: + with mock.patch("core.views.launch_example_task") as mock_task: request = factory.get(reverse("core:task:example")) mock_task.return_value = "123" response = LaunchExampleTaskView.as_view()(request) @@ -52,7 +52,7 @@ def test_successful_get_status(self, factory, user_factory): task_id = "123" request = factory.get(reverse("core:task:status", args=[task_id])) force_authenticate(request, user) - with mock.patch("apps.core.views.get_task_status") as mock_task: + with mock.patch("core.views.get_task_status") as mock_task: mock_task.return_value = { "status": "PENDING", "name": "task_name", diff --git a/server/apps/core/urls.py b/server/core/urls.py similarity index 100% rename from server/apps/core/urls.py rename to server/core/urls.py diff --git a/server/apps/core/views.py b/server/core/views.py similarity index 95% rename from server/apps/core/views.py rename to server/core/views.py index b180f8a0c..41c7b29d9 100644 --- a/server/apps/core/views.py +++ b/server/core/views.py @@ -5,7 +5,7 @@ from rest_framework.response import Response from rest_framework.views import APIView -from apps.core.services.task_service import get_task_status, launch_example_task +from core.services.task_service import get_task_status, launch_example_task class LaunchExampleTaskView(APIView): diff --git a/server/apps/handler/__init__.py b/server/handler/__init__.py similarity index 100% rename from server/apps/handler/__init__.py rename to server/handler/__init__.py diff --git a/server/apps/handler/admin.py b/server/handler/admin.py similarity index 97% rename from server/apps/handler/admin.py rename to server/handler/admin.py index 11f3997bc..bba589bc2 100644 --- a/server/apps/handler/admin.py +++ b/server/handler/admin.py @@ -3,7 +3,7 @@ from django.urls import reverse from django.utils.html import format_html, urlencode -from apps.core.admin import HiddenListView +from core.admin import HiddenListView from .models import ( ESignature, diff --git a/server/apps/handler/apps.py b/server/handler/apps.py similarity index 82% rename from server/apps/handler/apps.py rename to server/handler/apps.py index c2a058439..f4db87f6e 100644 --- a/server/apps/handler/apps.py +++ b/server/handler/apps.py @@ -3,4 +3,4 @@ class TrakConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" - name = "apps.handler" + name = "handler" diff --git a/server/apps/handler/migrations/0001_initial.py b/server/handler/migrations/0001_initial.py similarity index 98% rename from server/apps/handler/migrations/0001_initial.py rename to server/handler/migrations/0001_initial.py index d90750395..fc03a627c 100644 --- a/server/apps/handler/migrations/0001_initial.py +++ b/server/handler/migrations/0001_initial.py @@ -1,10 +1,9 @@ # Generated by Django 4.2.10 on 2024-02-21 22:17 import django.db.models.deletion +import handler.models.contact from django.db import migrations, models -import apps.handler.models.contact - class Migration(migrations.Migration): initial = True @@ -37,7 +36,7 @@ class Migration(migrations.Migration): auto_created=True, primary_key=True, serialize=False, verbose_name="ID" ), ), - ("number", apps.handler.models.contact.ManifestPhoneNumber(max_length=12)), + ("number", handler.models.contact.ManifestPhoneNumber(max_length=12)), ("extension", models.CharField(blank=True, max_length=6, null=True)), ], options={ diff --git a/server/apps/handler/migrations/0002_initial.py b/server/handler/migrations/0002_initial.py similarity index 100% rename from server/apps/handler/migrations/0002_initial.py rename to server/handler/migrations/0002_initial.py diff --git a/server/apps/handler/migrations/0003_alter_papersignature_options.py b/server/handler/migrations/0003_alter_papersignature_options.py similarity index 100% rename from server/apps/handler/migrations/0003_alter_papersignature_options.py rename to server/handler/migrations/0003_alter_papersignature_options.py diff --git a/server/apps/handler/migrations/__init__.py b/server/handler/migrations/__init__.py similarity index 100% rename from server/apps/handler/migrations/__init__.py rename to server/handler/migrations/__init__.py diff --git a/server/apps/handler/models/__init__.py b/server/handler/models/__init__.py similarity index 100% rename from server/apps/handler/models/__init__.py rename to server/handler/models/__init__.py diff --git a/server/apps/handler/models/contact.py b/server/handler/models/contact.py similarity index 100% rename from server/apps/handler/models/contact.py rename to server/handler/models/contact.py diff --git a/server/apps/handler/models/handler.py b/server/handler/models/handler.py similarity index 99% rename from server/apps/handler/models/handler.py rename to server/handler/models/handler.py index 0e662b9f2..c935af8d8 100644 --- a/server/apps/handler/models/handler.py +++ b/server/handler/models/handler.py @@ -5,7 +5,7 @@ from django.core.exceptions import ValidationError from django.db import models -from apps.rcrasite.models import RcraSite +from rcrasite.models import RcraSite from .contact import ManifestPhone from .signature import ESignature, PaperSignature diff --git a/server/apps/handler/models/signature.py b/server/handler/models/signature.py similarity index 100% rename from server/apps/handler/models/signature.py rename to server/handler/models/signature.py diff --git a/server/apps/handler/serializers/__init__.py b/server/handler/serializers/__init__.py similarity index 100% rename from server/apps/handler/serializers/__init__.py rename to server/handler/serializers/__init__.py diff --git a/server/apps/handler/serializers/base_serializer.py b/server/handler/serializers/base_serializer.py similarity index 100% rename from server/apps/handler/serializers/base_serializer.py rename to server/handler/serializers/base_serializer.py diff --git a/server/apps/handler/serializers/handler_serializer.py b/server/handler/serializers/handler_serializer.py similarity index 96% rename from server/apps/handler/serializers/handler_serializer.py rename to server/handler/serializers/handler_serializer.py index 804a056db..3ccd3991b 100644 --- a/server/apps/handler/serializers/handler_serializer.py +++ b/server/handler/serializers/handler_serializer.py @@ -3,8 +3,8 @@ from rest_framework import serializers from rest_framework.exceptions import ValidationError -from apps.handler.models import Handler, ManifestPhone, Transporter -from apps.rcrasite.serializers import RcraSiteSerializer +from handler.models import Handler, ManifestPhone, Transporter +from rcrasite.serializers import RcraSiteSerializer from .signatures import ESignatureSerializer, PaperSignatureSerializer diff --git a/server/apps/handler/serializers/signatures.py b/server/handler/serializers/signatures.py similarity index 97% rename from server/apps/handler/serializers/signatures.py rename to server/handler/serializers/signatures.py index 182a5930d..e9d8fba16 100644 --- a/server/apps/handler/serializers/signatures.py +++ b/server/handler/serializers/signatures.py @@ -4,8 +4,8 @@ from rest_framework import serializers -from apps.handler.models import ESignature, PaperSignature, QuickerSign, Signer -from apps.rcrasite.serializers import RcraPhoneSerializer +from handler.models import ESignature, PaperSignature, QuickerSign, Signer +from rcrasite.serializers import RcraPhoneSerializer from .base_serializer import HandlerBaseSerializer diff --git a/server/apps/handler/tests/__init__.py b/server/handler/tests/__init__.py similarity index 100% rename from server/apps/handler/tests/__init__.py rename to server/handler/tests/__init__.py diff --git a/server/apps/handler/tests/conftest.py b/server/handler/tests/conftest.py similarity index 96% rename from server/apps/handler/tests/conftest.py rename to server/handler/tests/conftest.py index 4120edf4f..94865b1e4 100644 --- a/server/apps/handler/tests/conftest.py +++ b/server/handler/tests/conftest.py @@ -4,15 +4,15 @@ import pytest from faker import Faker -from apps.handler.models import ( +from handler.models import ( ESignature, Handler, PaperSignature, Signer, Transporter, ) -from apps.manifest.models import Manifest -from apps.rcrasite.models import RcraSite +from manifest.models import Manifest +from rcrasite.models import RcraSite @pytest.fixture diff --git a/server/apps/handler/tests/test_handler_models.py b/server/handler/tests/test_handler_models.py similarity index 97% rename from server/apps/handler/tests/test_handler_models.py rename to server/handler/tests/test_handler_models.py index 737ba4dac..bd5091b4b 100644 --- a/server/apps/handler/tests/test_handler_models.py +++ b/server/handler/tests/test_handler_models.py @@ -1,6 +1,6 @@ import pytest -from apps.handler.models import Handler +from handler.models import Handler @pytest.mark.django_db diff --git a/server/apps/handler/tests/test_handler_serializer.py b/server/handler/tests/test_handler_serializer.py similarity index 94% rename from server/apps/handler/tests/test_handler_serializer.py rename to server/handler/tests/test_handler_serializer.py index 1aa1e864e..ac388c4e9 100644 --- a/server/apps/handler/tests/test_handler_serializer.py +++ b/server/handler/tests/test_handler_serializer.py @@ -1,7 +1,7 @@ import pytest -from apps.handler.models import Handler, PaperSignature -from apps.handler.serializers import HandlerSerializer +from handler.models import Handler, PaperSignature +from handler.serializers import HandlerSerializer @pytest.mark.django_db diff --git a/server/apps/handler/tests/test_handler_services.py b/server/handler/tests/test_handler_services.py similarity index 92% rename from server/apps/handler/tests/test_handler_services.py rename to server/handler/tests/test_handler_services.py index d975b2b85..7efa3a56a 100644 --- a/server/apps/handler/tests/test_handler_services.py +++ b/server/handler/tests/test_handler_services.py @@ -1,8 +1,8 @@ import pytest -from apps.core.services import RcraClient -from apps.rcrasite.models import RcraSite -from apps.rcrasite.services import RcraSiteService +from core.services import RcraClient +from rcrasite.models import RcraSite +from rcrasite.services import RcraSiteService class TestHandlerService: diff --git a/server/apps/handler/tests/test_signature_models.py b/server/handler/tests/test_signature_models.py similarity index 93% rename from server/apps/handler/tests/test_signature_models.py rename to server/handler/tests/test_signature_models.py index 1a04de297..b8a6859f8 100644 --- a/server/apps/handler/tests/test_signature_models.py +++ b/server/handler/tests/test_signature_models.py @@ -3,7 +3,7 @@ import pytest from django.db import IntegrityError -from apps.handler.models import PaperSignature +from handler.models import PaperSignature @pytest.mark.django_db diff --git a/server/apps/handler/tests/test_signature_serializer.py b/server/handler/tests/test_signature_serializer.py similarity index 92% rename from server/apps/handler/tests/test_signature_serializer.py rename to server/handler/tests/test_signature_serializer.py index 93972dc2c..3813c0c32 100644 --- a/server/apps/handler/tests/test_signature_serializer.py +++ b/server/handler/tests/test_signature_serializer.py @@ -1,7 +1,7 @@ import pytest -from apps.handler.models import Signer -from apps.handler.serializers import ESignatureSerializer +from handler.models import Signer +from handler.serializers import ESignatureSerializer @pytest.fixture diff --git a/server/haztrak/settings/base.py b/server/haztrak/settings/base.py index 340454b34..7a94d8033 100644 --- a/server/haztrak/settings/base.py +++ b/server/haztrak/settings/base.py @@ -50,14 +50,14 @@ "django_celery_results", "django_celery_beat", "drf_spectacular", - "apps.handler", - "apps.rcrasite", - "apps.core", - "apps.manifest", - "apps.wasteline", - "apps.org", - "apps.site", - "apps.profile", + "handler", + "rcrasite", + "core", + "manifest", + "wasteline", + "org", + "orgsite", + "profile", ] MIDDLEWARE = [ @@ -143,7 +143,7 @@ "DEFAULT_PARSER_CLASSES": [ "rest_framework.parsers.JSONParser", ], - "EXCEPTION_HANDLER": "apps.core.exceptions.haztrak_exception_handler", + "EXCEPTION_HANDLER": "core.exceptions.haztrak_exception_handler", "DEFAULT_RENDERER_CLASSES": [ "rest_framework.renderers.JSONRenderer", ], @@ -217,12 +217,12 @@ "handlers": ["console"], "propagate": False, }, - "apps.rcrasite": { + "rcrasite": { "level": HT_TRAK_LOG_LEVEL, "handlers": ["console"], "propagate": False, }, - "apps.core": { + "core": { "level": HT_CORE_LOG_LEVEL, "handlers": ["console"], "propagate": False, @@ -230,7 +230,7 @@ }, } -REST_AUTH = {"USER_DETAILS_SERIALIZER": "apps.core.serializers.TrakUserSerializer"} +REST_AUTH = {"USER_DETAILS_SERIALIZER": "core.serializers.TrakUserSerializer"} # Guardian GUARDIAN_USER_OBJ_PERMS_MODEL = "core.UserPermission" @@ -240,6 +240,6 @@ TRAK_ORG_MODEL = "org.Org" TRAK_RCRAINFO_SITE_MODEL = "rcrasite.RcraSite" TRAK_MANIFEST_MODEL = "manifest.Manifest" -TRAK_SITE_MODEL = "site.Site" +TRAK_SITE_MODEL = "orgsite.Site" TRAK_WASTELINE_MODEL = "wasteline.Wasteline" TRAK_HANDLER_MODEL = "handler.Handler" diff --git a/server/haztrak/urls.py b/server/haztrak/urls.py index 0f6f5df30..b4ce8c609 100644 --- a/server/haztrak/urls.py +++ b/server/haztrak/urls.py @@ -28,13 +28,13 @@ "api/", include( [ - path("", include("apps.manifest.urls", namespace="manifest")), - path("", include("apps.wasteline.urls", namespace="wasteline")), - path("", include("apps.rcrasite.urls", namespace="rcrasite")), - path("", include("apps.core.urls", namespace="core")), - path("", include("apps.org.urls", namespace="org")), - path("", include("apps.site.urls", namespace="site")), - path("", include("apps.profile.urls", namespace="profile")), + path("", include("manifest.urls", namespace="manifest")), + path("", include("wasteline.urls", namespace="wasteline")), + path("", include("rcrasite.urls", namespace="rcrasite")), + path("", include("core.urls", namespace="core")), + path("", include("org.urls", namespace="org")), + path("", include("orgsite.urls", namespace="site")), + path("", include("profile.urls", namespace="profile")), path("schema/", SpectacularAPIView.as_view(), name="schema"), path( "schema/swagger-ui", diff --git a/server/apps/manifest/__init__.py b/server/manifest/__init__.py similarity index 100% rename from server/apps/manifest/__init__.py rename to server/manifest/__init__.py diff --git a/server/apps/manifest/admin.py b/server/manifest/admin.py similarity index 89% rename from server/apps/manifest/admin.py rename to server/manifest/admin.py index 15bdb9f2a..d084487e4 100644 --- a/server/apps/manifest/admin.py +++ b/server/manifest/admin.py @@ -1,9 +1,9 @@ from django.contrib import admin from django.db.models import Q, QuerySet -from apps.handler.models import Transporter -from apps.manifest.models import Manifest -from apps.wasteline.admin import WasteLineInline +from handler.models import Transporter +from manifest.models import Manifest +from wasteline.admin import WasteLineInline class IsDraftMtn(admin.SimpleListFilter): diff --git a/server/apps/manifest/apps.py b/server/manifest/apps.py similarity index 82% rename from server/apps/manifest/apps.py rename to server/manifest/apps.py index 0e3e8f1ea..07bee23c3 100644 --- a/server/apps/manifest/apps.py +++ b/server/manifest/apps.py @@ -3,4 +3,4 @@ class ManifestConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" - name = "apps.manifest" + name = "manifest" diff --git a/server/manifest/migrations/0001_initial.py b/server/manifest/migrations/0001_initial.py new file mode 100644 index 000000000..33da08327 --- /dev/null +++ b/server/manifest/migrations/0001_initial.py @@ -0,0 +1,322 @@ +# Generated by Django 4.2.10 on 2024-02-21 22:17 + +import django.db.models.deletion +import manifest.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + initial = True + + dependencies = [ + ("handler", "0001_initial"), + ] + + operations = [ + migrations.CreateModel( + name="AdditionalInfo", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ( + "original_mtn", + models.JSONField( + blank=True, + help_text="Original manifest tracking number of rejected manifestRegex expression validation: [0-9]{9}[A-Z]{3}", + null=True, + validators=[manifest.models.validate_mtn], + ), + ), + ( + "new_destination", + models.CharField( + blank=True, + choices=[("GEN", "Generator"), ("TSD", "Tsdf")], + help_text="Destination of the new manifest created during rejection or residue.", + max_length=255, + null=True, + ), + ), + ("consent_number", models.CharField(blank=True, max_length=12, null=True)), + ("comments", models.JSONField(blank=True, null=True)), + ( + "handling_instructions", + models.CharField( + blank=True, + help_text="Special Handling Instructions", + max_length=4000, + null=True, + ), + ), + ], + options={ + "verbose_name": "Additional Info", + "verbose_name_plural": "Additional Info", + }, + ), + migrations.CreateModel( + name="PortOfEntry", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ( + "state", + models.CharField( + blank=True, + choices=[ + ("AK", "Alaska"), + ("AL", "Alabama"), + ("AP", "Armed Forces Pacific"), + ("AR", "Arkansas"), + ("AZ", "Arizona"), + ("CA", "California"), + ("CO", "Colorado"), + ("CT", "Connecticut"), + ("DC", "Washington DC"), + ("DE", "Delaware"), + ("FL", "Florida"), + ("GA", "Georgia"), + ("GU", "Guam"), + ("HI", "Hawaii"), + ("IA", "Iowa"), + ("ID", "Idaho"), + ("IL", "Illinois"), + ("IN", "Indiana"), + ("KS", "Kansas"), + ("KY", "Kentucky"), + ("LA", "Louisiana"), + ("MA", "Massachusetts"), + ("MD", "Maryland"), + ("ME", "Maine"), + ("MI", "Michigan"), + ("MN", "Minnesota"), + ("MO", "Missouri"), + ("MS", "Mississippi"), + ("MT", "Montana"), + ("NC", "North Carolina"), + ("ND", "North Dakota"), + ("NE", "Nebraska"), + ("NH", "New Hampshire"), + ("NJ", "New Jersey"), + ("NM", "New Mexico"), + ("NV", "Nevada"), + ("NY", "New York"), + ("OH", "Ohio"), + ("OK", "Oklahoma"), + ("OR", "Oregon"), + ("PA", "Pennsylvania"), + ("PR", "Puerto Rico"), + ("RI", "Rhode Island"), + ("SC", "South Carolina"), + ("SD", "South Dakota"), + ("TN", "Tennessee"), + ("TX", "Texas"), + ("UT", "Utah"), + ("VA", "Virginia"), + ("VI", "Virgin Islands"), + ("VT", "Vermont"), + ("WA", "Washington"), + ("WI", "Wisconsin"), + ("WV", "West Virginia"), + ("WY", "Wyoming"), + ("XA", "REGION 01 PURVIEW"), + ("XB", "REGION 02 PURVIEW"), + ("XC", "REGION 03 PURVIEW"), + ("XD", "REGION 04 PURVIEW"), + ("XE", "REGION 05 PURVIEW"), + ("XF", "REGION 06 PURVIEW"), + ("XG", "REGION 07 PURVIEW"), + ("XH", "REGION 08 PURVIEW"), + ("XI", "REGION 09 PURVIEW"), + ("XJ", "REGION 10 PURVIEW"), + ], + max_length=2, + null=True, + ), + ), + ("city_port", models.CharField(blank=True, max_length=100, null=True)), + ], + options={ + "verbose_name": "Port of Entry", + "verbose_name_plural": "Ports of Entry", + }, + ), + migrations.CreateModel( + name="Manifest", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ("created_date", models.DateTimeField(auto_now=True, null=True)), + ("update_date", models.DateTimeField(auto_now=True)), + ( + "mtn", + models.CharField( + default=manifest.models.draft_mtn, + max_length=30, + unique=True, + validators=[manifest.models.validate_mtn], + verbose_name="manifest Tracking Number", + ), + ), + ( + "status", + models.CharField( + choices=[ + ("NotAssigned", "Not Assigned"), + ("Pending", "Pending"), + ("Scheduled", "Scheduled"), + ("InTransit", "In Transit"), + ("ReadyForSignature", "Ready for Signature"), + ("Signed", "Signed"), + ("Corrected", "Corrected"), + ("UnderCorrection", "Under Correction"), + ("MtnValidationFailed", "MTN Validation Failed"), + ], + default="NotAssigned", + max_length=25, + ), + ), + ( + "submission_type", + models.CharField( + choices=[ + ("FullElectronic", "Full Electronic"), + ("DataImage5Copy", "Data + Image"), + ("Hybrid", "Hybrid"), + ("Image", "Image"), + ], + default="FullElectronic", + max_length=25, + ), + ), + ("signature_status", models.BooleanField(blank=True, null=True)), + ( + "origin_type", + models.CharField( + choices=[("Web", "Web"), ("Service", "Service"), ("Mail", "Mail")], + default="Service", + max_length=25, + ), + ), + ("shipped_date", models.DateTimeField(blank=True, null=True)), + ( + "potential_ship_date", + models.DateTimeField( + blank=True, null=True, verbose_name="potential ship date" + ), + ), + ("received_date", models.DateTimeField(blank=True, null=True)), + ("certified_date", models.DateTimeField(blank=True, null=True)), + ("certified_by", models.JSONField(blank=True, null=True)), + ("broker", models.JSONField(blank=True, null=True)), + ("rejection", models.BooleanField(blank=True, null=True)), + ( + "rejection_info", + models.JSONField(blank=True, null=True, verbose_name="Rejection Information"), + ), + ("discrepancy", models.BooleanField(blank=True, default=False)), + ("residue", models.BooleanField(blank=True, default=False)), + ( + "residue_new_mtn", + models.JSONField(blank=True, default=list, verbose_name="residue new MTN"), + ), + ( + "import_flag", + models.BooleanField(blank=True, default=False, verbose_name="import"), + ), + ( + "import_info", + models.JSONField(blank=True, null=True, verbose_name="import information"), + ), + ( + "contains_residue_or_rejection", + models.BooleanField( + blank=True, + null=True, + verbose_name="contains previous rejection or residue waste", + ), + ), + ("printed_document", models.JSONField(blank=True, null=True)), + ("form_document", models.JSONField(blank=True, null=True)), + ("correction_info", models.JSONField(blank=True, null=True)), + ("ppc_status", models.JSONField(blank=True, null=True, verbose_name="PPC info")), + ("locked", models.BooleanField(blank=True, null=True)), + ( + "lock_reason", + models.CharField( + blank=True, + choices=[ + ("ACS", "AsyncSign"), + ("ECB", "EpaChangeBiller"), + ("EPC", "EpaCorrection"), + ], + max_length=25, + null=True, + ), + ), + ("transfer_requested", models.BooleanField(blank=True, null=True)), + ("transfer_status", models.CharField(blank=True, max_length=200, null=True)), + ( + "original_sub_type", + models.CharField( + blank=True, + choices=[ + ("FullElectronic", "Full Electronic"), + ("DataImage5Copy", "Data + Image"), + ("Hybrid", "Hybrid"), + ("Image", "Image"), + ], + max_length=25, + null=True, + verbose_name="original submission type", + ), + ), + ("transfer_count", models.IntegerField(blank=True, null=True)), + ( + "next_transfer_time", + models.DateTimeField(blank=True, null=True, verbose_name="next transfer time"), + ), + ( + "additional_info", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="manifest.additionalinfo", + ), + ), + ( + "generator", + models.ForeignKey( + on_delete=django.db.models.deletion.PROTECT, + related_name="generator", + to="handler.handler", + ), + ), + ( + "tsdf", + models.ForeignKey( + on_delete=django.db.models.deletion.PROTECT, + related_name="designated_facility", + to="handler.handler", + verbose_name="designated facility", + ), + ), + ], + options={ + "ordering": ["update_date", "mtn"], + }, + ), + ] diff --git a/server/apps/manifest/migrations/__init__.py b/server/manifest/migrations/__init__.py similarity index 100% rename from server/apps/manifest/migrations/__init__.py rename to server/manifest/migrations/__init__.py diff --git a/server/apps/manifest/models.py b/server/manifest/models.py similarity index 98% rename from server/apps/manifest/models.py rename to server/manifest/models.py index a932a9f65..6aa66b3db 100644 --- a/server/apps/manifest/models.py +++ b/server/manifest/models.py @@ -9,9 +9,9 @@ from django.db.models import Q, QuerySet from django.utils.translation import gettext_lazy as _ -from apps.handler.models import Handler, Transporter -from apps.rcrasite.models import RcraSiteType, RcraStates -from apps.wasteline.models import WasteLine +from handler.models import Handler, Transporter +from rcrasite.models import RcraSiteType, RcraStates +from wasteline.models import WasteLine logger = logging.getLogger(__name__) diff --git a/server/apps/manifest/serializers.py b/server/manifest/serializers.py similarity index 98% rename from server/apps/manifest/serializers.py rename to server/manifest/serializers.py index 3ada689cb..d11bb90d3 100644 --- a/server/apps/manifest/serializers.py +++ b/server/manifest/serializers.py @@ -3,18 +3,18 @@ from rest_framework import serializers -from apps.handler.serializers import ( +from handler.serializers import ( HandlerSerializer, TransporterSerializer, ) -from apps.manifest.models import ( +from manifest.models import ( AdditionalInfo, Manifest, PortOfEntry, draft_mtn, ) -from apps.rcrasite.models import RcraStates -from apps.wasteline.serializers import ( +from rcrasite.models import RcraStates +from wasteline.serializers import ( WasteLineSerializer, ) diff --git a/server/apps/manifest/services/__init__.py b/server/manifest/services/__init__.py similarity index 100% rename from server/apps/manifest/services/__init__.py rename to server/manifest/services/__init__.py diff --git a/server/apps/manifest/services/emanifest.py b/server/manifest/services/emanifest.py similarity index 94% rename from server/apps/manifest/services/emanifest.py rename to server/manifest/services/emanifest.py index db9d638b0..e10c0ef0a 100644 --- a/server/apps/manifest/services/emanifest.py +++ b/server/manifest/services/emanifest.py @@ -7,13 +7,13 @@ from emanifest import RcrainfoResponse from requests import RequestException -from apps.core.services import RcraClient, get_rcra_client -from apps.handler.models import QuickerSign -from apps.handler.serializers import QuickerSignSerializer -from apps.manifest.models import Manifest -from apps.manifest.serializers import ManifestSerializer -from apps.manifest.services.emanifest_search import EmanifestSearch -from apps.manifest.tasks import pull_manifest, sign_manifest +from core.services import RcraClient, get_rcra_client +from handler.models import QuickerSign +from handler.serializers import QuickerSignSerializer +from manifest.models import Manifest +from manifest.serializers import ManifestSerializer +from manifest.services.emanifest_search import EmanifestSearch +from manifest.tasks import pull_manifest, sign_manifest logger = logging.getLogger(__name__) diff --git a/server/apps/manifest/services/emanifest_search.py b/server/manifest/services/emanifest_search.py similarity index 99% rename from server/apps/manifest/services/emanifest_search.py rename to server/manifest/services/emanifest_search.py index 66d0806b5..ec2626e39 100644 --- a/server/apps/manifest/services/emanifest_search.py +++ b/server/manifest/services/emanifest_search.py @@ -1,7 +1,7 @@ from datetime import UTC, datetime, timedelta, timezone from typing import Literal, Optional, get_args -from apps.core.services import RcraClient +from core.services import RcraClient EmanifestStatus = Literal[ "Pending", diff --git a/server/apps/manifest/services/manifest.py b/server/manifest/services/manifest.py similarity index 89% rename from server/apps/manifest/services/manifest.py rename to server/manifest/services/manifest.py index 9c03ec286..45c52ac46 100644 --- a/server/apps/manifest/services/manifest.py +++ b/server/manifest/services/manifest.py @@ -4,10 +4,10 @@ from django.db import transaction from django.db.models import Q, QuerySet -from apps.manifest.models import Manifest -from apps.manifest.services import EManifest, EManifestError, TaskResponse -from apps.manifest.tasks import save_to_emanifest as save_to_emanifest_task -from apps.site.models import Site +from manifest.models import Manifest +from manifest.services import EManifest, EManifestError, TaskResponse +from manifest.tasks import save_to_emanifest as save_to_emanifest_task +from orgsite.models import Site logger = logging.getLogger(__name__) diff --git a/server/apps/manifest/tasks.py b/server/manifest/tasks.py similarity index 89% rename from server/apps/manifest/tasks.py rename to server/manifest/tasks.py index d41b684f3..413d2a22d 100644 --- a/server/apps/manifest/tasks.py +++ b/server/manifest/tasks.py @@ -4,7 +4,7 @@ from celery import Task, shared_task, states from celery.exceptions import Ignore, Reject -from apps.core.services import get_rcra_client +from core.services import get_rcra_client logger = logging.getLogger(__name__) @@ -15,8 +15,8 @@ def pull_manifest(self: Task, *, mtn: List[str], username: str) -> dict: This task initiates a call to the EManifest to pull a manifest by MTN """ - from apps.core.services import TaskService - from apps.manifest.services import EManifest + from core.services import TaskService + from manifest.services import EManifest logger.info(f"start task {self.name}, manifest {mtn}") task_status = TaskService(task_id=self.request.id, task_name=self.name, status="STARTED") @@ -44,7 +44,7 @@ def sign_manifest( """ a task to Quicker Sign manifest, by MTN, in RCRAInfo """ - from apps.manifest.services import EManifest + from manifest.services import EManifest try: emanifest = EManifest(username=username) @@ -60,8 +60,8 @@ def sign_manifest( def sync_site_manifests(self, *, site_id: str, username: str): """asynchronous task to sync an EPA site's manifests""" - from apps.manifest.services.emanifest import sync_manifests - from apps.site.services import get_user_site, update_emanifest_sync_date + from manifest.services.emanifest import sync_manifests + from orgsite.services import get_user_site, update_emanifest_sync_date try: client = get_rcra_client(username=username) @@ -84,8 +84,8 @@ def save_to_emanifest(self, *, manifest_data: dict, username: str): it accepts a Python dict of the manifest data to be submitted as JSON, and the username of the user who is creating the manifest """ - from apps.core.services import TaskService - from apps.manifest.services import EManifest, EManifestError + from core.services import TaskService + from manifest.services import EManifest, EManifestError logger.info(f"start task: {self.name}") task_status = TaskService(task_id=self.request.id, task_name=self.name, status="STARTED") diff --git a/server/apps/manifest/tests/__init__.py b/server/manifest/tests/__init__.py similarity index 100% rename from server/apps/manifest/tests/__init__.py rename to server/manifest/tests/__init__.py diff --git a/server/apps/manifest/tests/conftest.py b/server/manifest/tests/conftest.py similarity index 96% rename from server/apps/manifest/tests/conftest.py rename to server/manifest/tests/conftest.py index cb1015eec..b580f8c25 100644 --- a/server/apps/manifest/tests/conftest.py +++ b/server/manifest/tests/conftest.py @@ -8,9 +8,9 @@ from faker import Faker from faker.providers import BaseProvider -from apps.handler.models import Handler, PaperSignature, Transporter -from apps.manifest.models import Manifest -from apps.rcrasite.models import RcraSite, RcraSiteType +from handler.models import Handler, PaperSignature, Transporter +from manifest.models import Manifest +from rcrasite.models import RcraSite, RcraSiteType class MtnProvider(BaseProvider): diff --git a/server/apps/manifest/tests/test_emanifest_service.py b/server/manifest/tests/test_emanifest_service.py similarity index 92% rename from server/apps/manifest/tests/test_emanifest_service.py rename to server/manifest/tests/test_emanifest_service.py index 0323635a3..e22bc99a0 100644 --- a/server/apps/manifest/tests/test_emanifest_service.py +++ b/server/manifest/tests/test_emanifest_service.py @@ -2,8 +2,8 @@ import pytest_mock from rest_framework import status -from apps.core.services import RcraClient, get_rcra_client -from apps.manifest.services import EManifest +from core.services import RcraClient, get_rcra_client +from manifest.services import EManifest class TestEManifestService: diff --git a/server/apps/manifest/tests/test_manifest_services.py b/server/manifest/tests/test_manifest_services.py similarity index 96% rename from server/apps/manifest/tests/test_manifest_services.py rename to server/manifest/tests/test_manifest_services.py index 9616ae061..e52e8eb20 100644 --- a/server/apps/manifest/tests/test_manifest_services.py +++ b/server/manifest/tests/test_manifest_services.py @@ -1,6 +1,6 @@ -from apps.manifest.models import Manifest -from apps.manifest.serializers import ManifestSerializer -from apps.manifest.services import create_manifest, get_manifests +from manifest.models import Manifest +from manifest.serializers import ManifestSerializer +from manifest.services import create_manifest, get_manifests class TestGetManifestService: diff --git a/server/apps/manifest/tests/test_models.py b/server/manifest/tests/test_models.py similarity index 95% rename from server/apps/manifest/tests/test_models.py rename to server/manifest/tests/test_models.py index 5a23b4d67..8f5f847c0 100644 --- a/server/apps/manifest/tests/test_models.py +++ b/server/manifest/tests/test_models.py @@ -4,9 +4,9 @@ import pytest from django.core.exceptions import ValidationError -from apps.handler.serializers import HandlerSerializer -from apps.manifest.models import Manifest, draft_mtn, manifest_factory, validate_mtn -from apps.rcrasite.models import RcraSiteType +from handler.serializers import HandlerSerializer +from manifest.models import Manifest, draft_mtn, manifest_factory, validate_mtn +from rcrasite.models import RcraSiteType @pytest.mark.django_db @@ -14,7 +14,7 @@ class TestManifestModel: def test_draft_mtn_follow_rcrainfo_pattern_with_dft_suffix(self, mocker): mock = MagicMock() mock.count.return_value = 5 - with patch("apps.manifest.models.Manifest.objects.all", return_value=mock): + with patch("manifest.models.Manifest.objects.all", return_value=mock): result = draft_mtn() assert isinstance(result, str) assert re.match(r"\d{9}DFT", result) diff --git a/server/apps/manifest/tests/test_search_emanifest.py b/server/manifest/tests/test_search_emanifest.py similarity index 97% rename from server/apps/manifest/tests/test_search_emanifest.py rename to server/manifest/tests/test_search_emanifest.py index c30591c1d..b13f97bb3 100644 --- a/server/apps/manifest/tests/test_search_emanifest.py +++ b/server/manifest/tests/test_search_emanifest.py @@ -3,8 +3,8 @@ import pytest -from apps.core.services import RcraClient -from apps.manifest.services.emanifest_search import EmanifestSearch +from core.services import RcraClient +from manifest.services.emanifest_search import EmanifestSearch class TestEmanifestSearchClass: diff --git a/server/apps/manifest/tests/test_serializers.py b/server/manifest/tests/test_serializers.py similarity index 90% rename from server/apps/manifest/tests/test_serializers.py rename to server/manifest/tests/test_serializers.py index 0c58ddb5c..267c93d81 100644 --- a/server/apps/manifest/tests/test_serializers.py +++ b/server/manifest/tests/test_serializers.py @@ -1,8 +1,8 @@ import pytest -from apps.manifest.models import AdditionalInfo, Manifest -from apps.manifest.serializers import ManifestSerializer -from apps.wasteline.models import WasteLine +from manifest.models import AdditionalInfo, Manifest +from manifest.serializers import ManifestSerializer +from wasteline.models import WasteLine @pytest.fixture diff --git a/server/apps/manifest/tests/test_views.py b/server/manifest/tests/test_views.py similarity index 90% rename from server/apps/manifest/tests/test_views.py rename to server/manifest/tests/test_views.py index 8166778e3..8f270e435 100644 --- a/server/apps/manifest/tests/test_views.py +++ b/server/manifest/tests/test_views.py @@ -6,7 +6,7 @@ from rest_framework.reverse import reverse from rest_framework.test import APIRequestFactory, force_authenticate -from apps.manifest.views import ElectronicManifestSignView, ManifestViewSet, MtnListView +from manifest.views import ElectronicManifestSignView, ManifestViewSet, MtnListView class TestManifestCRUD: @@ -51,7 +51,7 @@ def _user(self, user_factory): @pytest.fixture(autouse=True) def _patch_task(self, mocker): - mock_task = mocker.patch("apps.manifest.tasks.sign_manifest.delay") + mock_task = mocker.patch("manifest.tasks.sign_manifest.delay") self.mock_task_id = "mock_task_id" mock_task.return_value = AsyncResult(self.mock_task_id) @@ -87,7 +87,7 @@ def user(self, user_factory): return user_factory() def test_returns_empty_list_if_no_manifests(self, factory, user): - with patch("apps.manifest.views.get_manifests") as mock_get_manifests: + with patch("manifest.views.get_manifests") as mock_get_manifests: mock_get_manifests.return_value = [] request = factory.get(reverse("manifest:mtn:list")) force_authenticate(request, user) @@ -95,7 +95,7 @@ def test_returns_empty_list_if_no_manifests(self, factory, user): assert isinstance(response.data, list) def test_401_if_not_authorized(self, factory, user): - with patch("apps.manifest.views.get_manifests") as mock_get_manifests: + with patch("manifest.views.get_manifests") as mock_get_manifests: mock_get_manifests.return_value = [] request = factory.get(reverse("manifest:mtn:list")) response = MtnListView.as_view()(request) diff --git a/server/apps/manifest/urls.py b/server/manifest/urls.py similarity index 96% rename from server/apps/manifest/urls.py rename to server/manifest/urls.py index ae3369673..2e9af6a55 100644 --- a/server/apps/manifest/urls.py +++ b/server/manifest/urls.py @@ -1,7 +1,7 @@ from django.urls import include, path from rest_framework.routers import SimpleRouter -from apps.manifest.views import ( # type: ignore +from manifest.views import ( # type: ignore ElectronicManifestSaveView, ElectronicManifestSignView, ManifestViewSet, diff --git a/server/apps/manifest/views.py b/server/manifest/views.py similarity index 94% rename from server/apps/manifest/views.py rename to server/manifest/views.py index ee329a0ba..93582e113 100644 --- a/server/apps/manifest/views.py +++ b/server/manifest/views.py @@ -7,10 +7,10 @@ from rest_framework.response import Response from rest_framework.views import APIView -from apps.handler.serializers import QuickerSignSerializer -from apps.manifest.models import Manifest -from apps.manifest.serializers import ManifestSerializer, MtnSerializer -from apps.manifest.services import ( +from handler.serializers import QuickerSignSerializer +from manifest.models import Manifest +from manifest.serializers import ManifestSerializer, MtnSerializer +from manifest.services import ( EManifest, TaskResponse, create_manifest, @@ -18,7 +18,7 @@ save_emanifest, update_manifest, ) -from apps.site.services import sync_site_manifest_with_rcrainfo +from orgsite.services import sync_site_manifest_with_rcrainfo logger = logging.getLogger(__name__) diff --git a/server/apps/org/__init__.py b/server/org/__init__.py similarity index 100% rename from server/apps/org/__init__.py rename to server/org/__init__.py diff --git a/server/apps/org/admin.py b/server/org/admin.py similarity index 92% rename from server/apps/org/admin.py rename to server/org/admin.py index 61af84df3..be44afbc1 100644 --- a/server/apps/org/admin.py +++ b/server/org/admin.py @@ -3,8 +3,8 @@ from django.contrib.contenttypes.models import ContentType from guardian.admin import GuardedModelAdmin -from apps.org.models import Org, OrgAccess, OrgGroupObjectPermission, OrgUserObjectPermission -from apps.site.models import Site +from org.models import Org, OrgAccess, OrgGroupObjectPermission, OrgUserObjectPermission +from orgsite.models import Site admin.site.register(OrgAccess) diff --git a/server/apps/org/apps.py b/server/org/apps.py similarity index 84% rename from server/apps/org/apps.py rename to server/org/apps.py index b56998371..5dcb63c7f 100644 --- a/server/apps/org/apps.py +++ b/server/org/apps.py @@ -3,4 +3,4 @@ class OrgConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" - name = "apps.org" + name = "org" diff --git a/server/apps/org/migrations/0001_initial.py b/server/org/migrations/0001_initial.py similarity index 100% rename from server/apps/org/migrations/0001_initial.py rename to server/org/migrations/0001_initial.py diff --git a/server/apps/org/migrations/0002_rename_trakorg_org_rename_trakorgaccess_orgaccess.py b/server/org/migrations/0002_rename_trakorg_org_rename_trakorgaccess_orgaccess.py similarity index 64% rename from server/apps/org/migrations/0002_rename_trakorg_org_rename_trakorgaccess_orgaccess.py rename to server/org/migrations/0002_rename_trakorg_org_rename_trakorgaccess_orgaccess.py index 27fb5b43c..87f26c340 100644 --- a/server/apps/org/migrations/0002_rename_trakorg_org_rename_trakorgaccess_orgaccess.py +++ b/server/org/migrations/0002_rename_trakorg_org_rename_trakorgaccess_orgaccess.py @@ -5,20 +5,19 @@ class Migration(migrations.Migration): - dependencies = [ - ('org', '0001_initial'), - ('site', '0001_initial'), + ("org", "0001_initial"), + ("orgsite", "0001_initial"), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.RenameModel( - old_name='TrakOrg', - new_name='Org', + old_name="TrakOrg", + new_name="Org", ), migrations.RenameModel( - old_name='TrakOrgAccess', - new_name='OrgAccess', + old_name="TrakOrgAccess", + new_name="OrgAccess", ), ] diff --git a/server/apps/org/migrations/0003_orggroupobjectpermission_orguserobjectpermission.py b/server/org/migrations/0003_orggroupobjectpermission_orguserobjectpermission.py similarity index 100% rename from server/apps/org/migrations/0003_orggroupobjectpermission_orguserobjectpermission.py rename to server/org/migrations/0003_orggroupobjectpermission_orguserobjectpermission.py diff --git a/server/apps/org/migrations/__init__.py b/server/org/migrations/__init__.py similarity index 100% rename from server/apps/org/migrations/__init__.py rename to server/org/migrations/__init__.py diff --git a/server/apps/org/models.py b/server/org/models.py similarity index 98% rename from server/apps/org/models.py rename to server/org/models.py index fbaa958f2..0b2014e47 100644 --- a/server/apps/org/models.py +++ b/server/org/models.py @@ -1,11 +1,10 @@ import uuid +from profile.models import RcrainfoProfile from django.conf import settings from django.db import models from guardian.models.models import GroupObjectPermissionBase, UserObjectPermissionBase -from apps.profile.models import RcrainfoProfile - class OrgManager(models.Manager): """Organization Repository manager""" diff --git a/server/apps/org/serializers.py b/server/org/serializers.py similarity index 94% rename from server/apps/org/serializers.py rename to server/org/serializers.py index 0fbd30d50..41cbbc875 100644 --- a/server/apps/org/serializers.py +++ b/server/org/serializers.py @@ -1,7 +1,7 @@ from rest_framework import serializers from rest_framework.serializers import ModelSerializer -from apps.org.models import Org +from org.models import Org class OrgSerializer(ModelSerializer): diff --git a/server/apps/org/services.py b/server/org/services.py similarity index 96% rename from server/apps/org/services.py rename to server/org/services.py index 41e3e855a..ee2331142 100644 --- a/server/apps/org/services.py +++ b/server/org/services.py @@ -1,4 +1,4 @@ -from apps.org.models import Org +from org.models import Org def get_org_by_id(org_id: str) -> Org: diff --git a/server/apps/org/tests/__init__.py b/server/org/tests/__init__.py similarity index 100% rename from server/apps/org/tests/__init__.py rename to server/org/tests/__init__.py diff --git a/server/apps/org/tests/test_models.py b/server/org/tests/test_models.py similarity index 98% rename from server/apps/org/tests/test_models.py rename to server/org/tests/test_models.py index 82f025175..25e63dcd6 100644 --- a/server/apps/org/tests/test_models.py +++ b/server/org/tests/test_models.py @@ -1,4 +1,4 @@ -from apps.org.models import Org +from org.models import Org class TestOrgModel: diff --git a/server/apps/org/tests/test_serializers.py b/server/org/tests/test_serializers.py similarity index 95% rename from server/apps/org/tests/test_serializers.py rename to server/org/tests/test_serializers.py index 226f7fc35..beca53dff 100644 --- a/server/apps/org/tests/test_serializers.py +++ b/server/org/tests/test_serializers.py @@ -1,4 +1,4 @@ -from apps.org.serializers import OrgSerializer +from org.serializers import OrgSerializer class TestOrgSerializer: diff --git a/server/apps/org/tests/test_services.py b/server/org/tests/test_services.py similarity index 92% rename from server/apps/org/tests/test_services.py rename to server/org/tests/test_services.py index 071aa45cb..f45ad3c0f 100644 --- a/server/apps/org/tests/test_services.py +++ b/server/org/tests/test_services.py @@ -1,6 +1,6 @@ import uuid -from apps.org.services import get_org_by_id, get_org_rcrainfo_api_credentials +from org.services import get_org_by_id, get_org_rcrainfo_api_credentials class TestOrgServices: diff --git a/server/apps/org/tests/test_views.py b/server/org/tests/test_views.py similarity index 89% rename from server/apps/org/tests/test_views.py rename to server/org/tests/test_views.py index e4f498797..7f668d6cb 100644 --- a/server/apps/org/tests/test_views.py +++ b/server/org/tests/test_views.py @@ -5,8 +5,8 @@ from rest_framework.reverse import reverse from rest_framework.test import APIRequestFactory, force_authenticate -from apps.org.models import Org -from apps.org.views import OrgDetailsView +from org.models import Org +from org.views import OrgDetailsView class TestOrgDetailsView: @@ -31,7 +31,7 @@ def test_get_returns_org_details(self, org, org_access_factory, user): def test_404_when_org_id_not_defined(self, org, org_access_factory, user): request = self.factory.get(reverse("org:details", args=["foo"])) force_authenticate(request, user) - with patch("apps.org.views.get_org_by_id") as mock_org: + with patch("org.views.get_org_by_id") as mock_org: mock_org.side_effect = Org.DoesNotExist response = OrgDetailsView.as_view()(request, org_id="foo") assert response.status_code == status.HTTP_404_NOT_FOUND diff --git a/server/apps/org/urls.py b/server/org/urls.py similarity index 76% rename from server/apps/org/urls.py rename to server/org/urls.py index e794468c0..72bccda31 100644 --- a/server/apps/org/urls.py +++ b/server/org/urls.py @@ -1,6 +1,6 @@ from django.urls import path -from apps.org.views import OrgDetailsView +from org.views import OrgDetailsView app_name = "org" urlpatterns = [ diff --git a/server/apps/org/views.py b/server/org/views.py similarity index 85% rename from server/apps/org/views.py rename to server/org/views.py index 17abb601c..149f0ee5f 100644 --- a/server/apps/org/views.py +++ b/server/org/views.py @@ -6,9 +6,9 @@ from rest_framework.generics import RetrieveAPIView from rest_framework.response import Response -from apps.org.models import Org -from apps.org.serializers import OrgSerializer -from apps.org.services import get_org_by_id +from org.models import Org +from org.serializers import OrgSerializer +from org.services import get_org_by_id logger = logging.getLogger(__name__) diff --git a/server/apps/profile/__init__.py b/server/orgsite/__init__.py similarity index 100% rename from server/apps/profile/__init__.py rename to server/orgsite/__init__.py diff --git a/server/apps/site/admin.py b/server/orgsite/admin.py similarity index 93% rename from server/apps/site/admin.py rename to server/orgsite/admin.py index ad87c304e..047533e89 100644 --- a/server/apps/site/admin.py +++ b/server/orgsite/admin.py @@ -3,7 +3,7 @@ from django.contrib.contenttypes.models import ContentType from guardian.admin import GuardedModelAdmin -from apps.site.models import Site, SiteGroupObjectPermission, SiteUserObjectPermission +from orgsite.models import Site, SiteGroupObjectPermission, SiteUserObjectPermission @admin.register(Site) diff --git a/server/apps/site/apps.py b/server/orgsite/apps.py similarity index 84% rename from server/apps/site/apps.py rename to server/orgsite/apps.py index 723484fbf..4b6482feb 100644 --- a/server/apps/site/apps.py +++ b/server/orgsite/apps.py @@ -3,4 +3,4 @@ class FooConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" - name = "apps.site" + name = "orgsite" diff --git a/server/orgsite/migrations/0001_initial.py b/server/orgsite/migrations/0001_initial.py new file mode 100644 index 000000000..973863fc9 --- /dev/null +++ b/server/orgsite/migrations/0001_initial.py @@ -0,0 +1,105 @@ +# Generated by Django 5.0.4 on 2024-05-11 23:37 + +import django.core.validators +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + initial = True + + dependencies = [ + ("org", "0001_initial"), + ("rcrasite", "0001_initial"), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name="Site", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ( + "name", + models.CharField( + max_length=200, + validators=[ + django.core.validators.MinLengthValidator( + 2, "site aliases must be longer than 2 characters" + ) + ], + verbose_name="site alias", + ), + ), + ( + "last_rcrainfo_manifest_sync", + models.DateTimeField( + blank=True, null=True, verbose_name="last RCRAInfo manifest sync date" + ), + ), + ( + "org", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="org.trakorg" + ), + ), + ( + "rcra_site", + models.OneToOneField( + on_delete=django.db.models.deletion.CASCADE, + to="rcrasite.rcrasite", + verbose_name="rcra_site", + ), + ), + ], + options={ + "verbose_name": "Haztrak Site", + "verbose_name_plural": "Haztrak Sites", + "ordering": ["rcra_site__epa_id"], + }, + ), + migrations.CreateModel( + name="SiteAccess", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ( + "emanifest", + models.CharField( + choices=[("viewer", "view"), ("editor", "edit"), ("signer", "sign")], + default="view", + max_length=6, + ), + ), + ( + "site", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="orgsite.site" + ), + ), + ( + "user", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="site_permissions", + to=settings.AUTH_USER_MODEL, + ), + ), + ], + options={ + "verbose_name": "New Site Permission", + "verbose_name_plural": "New Site Permissions", + "ordering": ["user"], + }, + ), + ] diff --git a/server/orgsite/migrations/0002_alter_siteaccess_options_sitegroupobjectpermission_and_more.py b/server/orgsite/migrations/0002_alter_siteaccess_options_sitegroupobjectpermission_and_more.py new file mode 100644 index 000000000..c42801f0d --- /dev/null +++ b/server/orgsite/migrations/0002_alter_siteaccess_options_sitegroupobjectpermission_and_more.py @@ -0,0 +1,90 @@ +# Generated by Django 5.0.6 on 2024-07-22 19:25 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("auth", "0012_alter_user_first_name_max_length"), + ("orgsite", "0001_initial"), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AlterModelOptions( + name="siteaccess", + options={ + "ordering": ["user"], + "verbose_name": "Site Permission", + "verbose_name_plural": "Site Permissions", + }, + ), + migrations.CreateModel( + name="SiteGroupObjectPermission", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ( + "content_object", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="orgsite.site" + ), + ), + ( + "group", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="auth.group" + ), + ), + ( + "permission", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="auth.permission" + ), + ), + ], + options={ + "abstract": False, + "unique_together": {("group", "permission", "content_object")}, + }, + ), + migrations.CreateModel( + name="SiteUserObjectPermission", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ( + "content_object", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="orgsite.site" + ), + ), + ( + "permission", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="auth.permission" + ), + ), + ( + "user", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL + ), + ), + ], + options={ + "abstract": False, + "unique_together": {("user", "permission", "content_object")}, + }, + ), + ] diff --git a/server/orgsite/migrations/0003_alter_sitegroupobjectpermission_options_and_more.py b/server/orgsite/migrations/0003_alter_sitegroupobjectpermission_options_and_more.py new file mode 100644 index 000000000..9e6fe3392 --- /dev/null +++ b/server/orgsite/migrations/0003_alter_sitegroupobjectpermission_options_and_more.py @@ -0,0 +1,20 @@ +# Generated by Django 5.0.7 on 2024-07-22 20:17 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("orgsite", "0002_alter_siteaccess_options_sitegroupobjectpermission_and_more"), + ] + + operations = [ + migrations.AlterModelOptions( + name="sitegroupobjectpermission", + options={"verbose_name": "Site Role", "verbose_name_plural": "Site Roles"}, + ), + migrations.AlterModelOptions( + name="siteuserobjectpermission", + options={"verbose_name": "Site Permission", "verbose_name_plural": "Site Permissions"}, + ), + ] diff --git a/server/orgsite/migrations/0004_alter_siteaccess_site_and_more.py b/server/orgsite/migrations/0004_alter_siteaccess_site_and_more.py new file mode 100644 index 000000000..52b320567 --- /dev/null +++ b/server/orgsite/migrations/0004_alter_siteaccess_site_and_more.py @@ -0,0 +1,29 @@ +# Generated by Django 5.0.7 on 2024-07-24 21:51 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('orgsite', '0003_alter_sitegroupobjectpermission_options_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='siteaccess', + name='site', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='orgsite.site'), + ), + migrations.AlterField( + model_name='sitegroupobjectpermission', + name='content_object', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='orgsite.site'), + ), + migrations.AlterField( + model_name='siteuserobjectpermission', + name='content_object', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='orgsite.site'), + ), + ] diff --git a/server/apps/profile/migrations/__init__.py b/server/orgsite/migrations/__init__.py similarity index 100% rename from server/apps/profile/migrations/__init__.py rename to server/orgsite/migrations/__init__.py diff --git a/server/apps/site/models.py b/server/orgsite/models.py similarity index 100% rename from server/apps/site/models.py rename to server/orgsite/models.py diff --git a/server/apps/site/serializers.py b/server/orgsite/serializers.py similarity index 79% rename from server/apps/site/serializers.py rename to server/orgsite/serializers.py index b6c102303..d360fd911 100644 --- a/server/apps/site/serializers.py +++ b/server/orgsite/serializers.py @@ -1,9 +1,9 @@ from rest_framework import serializers from rest_framework.serializers import ModelSerializer -from apps.rcrasite.serializers import RcraSiteSerializer -from apps.rcrasite.serializers.base_serializer import SitesBaseSerializer -from apps.site.models import Site, SiteAccess +from orgsite.models import Site, SiteAccess +from rcrasite.serializers import RcraSiteSerializer +from rcrasite.serializers.base_serializer import SitesBaseSerializer class SiteSerializer(ModelSerializer): diff --git a/server/apps/site/services.py b/server/orgsite/services.py similarity index 93% rename from server/apps/site/services.py rename to server/orgsite/services.py index 8dd18bac3..c9fe9132a 100644 --- a/server/apps/site/services.py +++ b/server/orgsite/services.py @@ -5,9 +5,9 @@ from django.db import transaction from django.db.models import QuerySet -from apps.manifest.services import TaskResponse -from apps.manifest.tasks import sync_site_manifests -from apps.site.models import Site +from manifest.services import TaskResponse +from manifest.tasks import sync_site_manifests +from orgsite.models import Site logger = logging.getLogger(__name__) diff --git a/server/apps/profile/tests/__init__.py b/server/orgsite/tests/__init__.py similarity index 100% rename from server/apps/profile/tests/__init__.py rename to server/orgsite/tests/__init__.py diff --git a/server/apps/site/tests/conftest.py b/server/orgsite/tests/conftest.py similarity index 82% rename from server/apps/site/tests/conftest.py rename to server/orgsite/tests/conftest.py index b9b7aa476..2425b2272 100644 --- a/server/apps/site/tests/conftest.py +++ b/server/orgsite/tests/conftest.py @@ -2,9 +2,9 @@ import pytest -from apps.org.models import Org -from apps.rcrasite.models import RcraSite -from apps.site.models import Site +from org.models import Org +from orgsite.models import Site +from rcrasite.models import RcraSite @pytest.fixture diff --git a/server/apps/site/tests/test_models.py b/server/orgsite/tests/test_models.py similarity index 99% rename from server/apps/site/tests/test_models.py rename to server/orgsite/tests/test_models.py index e992c77c6..e7122bd0a 100644 --- a/server/apps/site/tests/test_models.py +++ b/server/orgsite/tests/test_models.py @@ -1,7 +1,7 @@ import pytest from django.db.models import QuerySet -from apps.site.models import Site +from orgsite.models import Site @pytest.mark.django_db diff --git a/server/apps/site/tests/test_services.py b/server/orgsite/tests/test_services.py similarity index 80% rename from server/apps/site/tests/test_services.py rename to server/orgsite/tests/test_services.py index 31306e582..8d918db99 100644 --- a/server/apps/site/tests/test_services.py +++ b/server/orgsite/tests/test_services.py @@ -3,8 +3,8 @@ import pytest -from apps.site.models import Site -from apps.site.services import filter_sites_by_org, get_user_site, update_emanifest_sync_date +from orgsite.models import Site +from orgsite.services import filter_sites_by_org, get_user_site, update_emanifest_sync_date class TestFilterOrgSites: @@ -17,14 +17,14 @@ def test_get_org_sites(self, org_factory, site_factory): class TestGetUserSite: def test_returns_site_by_epa_id(self, site_class_factory): - with patch("apps.site.services.Site.objects.get_by_username_and_epa_id") as mock_query: + with patch("orgsite.services.Site.objects.get_by_username_and_epa_id") as mock_query: mock_site = site_class_factory() mock_query.return_value = mock_site result = get_user_site(username="test", epa_id="test") assert result == mock_site def test_raises_error_when_site_not_found(self, site_class_factory): - with patch("apps.site.services.Site.objects.get_by_username_and_epa_id") as mock_query: + with patch("orgsite.services.Site.objects.get_by_username_and_epa_id") as mock_query: mock_query.side_effect = Site.DoesNotExist with pytest.raises(Site.DoesNotExist): get_user_site(username="test", epa_id="test") @@ -32,14 +32,14 @@ def test_raises_error_when_site_not_found(self, site_class_factory): class TestFilterSitesByUser: def test_returns_array_of_sites(self, site_factory, user_factory): - with patch("apps.site.services.Site.objects.filter_by_user") as mock_query: + with patch("orgsite.services.Site.objects.filter_by_user") as mock_query: site = site_factory() mock_query.return_value = [site] result = Site.objects.filter_by_user("username") assert site in result def test_returns_empty_list_when_no_sites_found(self, site_factory, user_factory): - with patch("apps.site.services.Site.objects.filter_by_user") as mock_query: + with patch("orgsite.services.Site.objects.filter_by_user") as mock_query: mock_query.return_value = [] result = Site.objects.filter_by_user("username") assert isinstance(result, list) @@ -52,7 +52,7 @@ def test_updates_the_last_sync_field(self, site_factory): assert site.last_rcrainfo_manifest_sync is not None def test_uses_datetime_now_by_default(self, site_factory): - with patch("apps.site.services.datetime") as mock_datetime: + with patch("orgsite.services.datetime") as mock_datetime: mock_datetime.now.return_value = datetime.datetime(2021, 1, 1) site = site_factory(last_rcrainfo_manifest_sync=None) update_emanifest_sync_date(site=site) diff --git a/server/apps/site/tests/test_views.py b/server/orgsite/tests/test_views.py similarity index 98% rename from server/apps/site/tests/test_views.py rename to server/orgsite/tests/test_views.py index 812e89553..a640f8983 100644 --- a/server/apps/site/tests/test_views.py +++ b/server/orgsite/tests/test_views.py @@ -3,7 +3,7 @@ from rest_framework.reverse import reverse from rest_framework.test import APIClient, APIRequestFactory, force_authenticate -from apps.site.views import SiteDetailsView +from orgsite.views import SiteDetailsView class TestSiteListView: diff --git a/server/apps/site/urls.py b/server/orgsite/urls.py similarity index 100% rename from server/apps/site/urls.py rename to server/orgsite/urls.py diff --git a/server/apps/site/views.py b/server/orgsite/views.py similarity index 92% rename from server/apps/site/views.py rename to server/orgsite/views.py index 671a09f7e..fa766d150 100644 --- a/server/apps/site/views.py +++ b/server/orgsite/views.py @@ -7,9 +7,9 @@ from rest_framework.response import Response from rest_framework.views import APIView -from apps.site.models import Site -from apps.site.serializers import SiteSerializer -from apps.site.services import filter_sites_by_org, filter_sites_by_username, get_user_site +from orgsite.models import Site +from orgsite.serializers import SiteSerializer +from orgsite.services import filter_sites_by_org, filter_sites_by_username, get_user_site logger = logging.getLogger(__name__) diff --git a/server/apps/rcrasite/__init__.py b/server/profile/__init__.py similarity index 100% rename from server/apps/rcrasite/__init__.py rename to server/profile/__init__.py diff --git a/server/apps/profile/admin.py b/server/profile/admin.py similarity index 100% rename from server/apps/profile/admin.py rename to server/profile/admin.py diff --git a/server/apps/profile/apps.py b/server/profile/apps.py similarity index 82% rename from server/apps/profile/apps.py rename to server/profile/apps.py index 8788bba5c..ca5c4053a 100644 --- a/server/apps/profile/apps.py +++ b/server/profile/apps.py @@ -3,4 +3,4 @@ class FooConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" - name = "apps.profile" + name = "profile" diff --git a/server/apps/profile/migrations/0001_initial.py b/server/profile/migrations/0001_initial.py similarity index 100% rename from server/apps/profile/migrations/0001_initial.py rename to server/profile/migrations/0001_initial.py diff --git a/server/apps/profile/migrations/0002_rename_trakprofile_profile.py b/server/profile/migrations/0002_rename_trakprofile_profile.py similarity index 100% rename from server/apps/profile/migrations/0002_rename_trakprofile_profile.py rename to server/profile/migrations/0002_rename_trakprofile_profile.py diff --git a/server/apps/rcrasite/migrations/__init__.py b/server/profile/migrations/__init__.py similarity index 100% rename from server/apps/rcrasite/migrations/__init__.py rename to server/profile/migrations/__init__.py diff --git a/server/apps/profile/models.py b/server/profile/models.py similarity index 100% rename from server/apps/profile/models.py rename to server/profile/models.py diff --git a/server/apps/profile/serializers/__init__.py b/server/profile/serializers/__init__.py similarity index 100% rename from server/apps/profile/serializers/__init__.py rename to server/profile/serializers/__init__.py diff --git a/server/apps/profile/serializers/profile.py b/server/profile/serializers/profile.py similarity index 80% rename from server/apps/profile/serializers/profile.py rename to server/profile/serializers/profile.py index 72281b98a..ce8b3c397 100644 --- a/server/apps/profile/serializers/profile.py +++ b/server/profile/serializers/profile.py @@ -1,9 +1,10 @@ +from profile.models import Profile + from rest_framework import serializers from rest_framework.serializers import ModelSerializer -from apps.org.serializers import OrgSerializer -from apps.profile.models import Profile -from apps.site.serializers import SiteAccessSerializer +from org.serializers import OrgSerializer +from orgsite.serializers import SiteAccessSerializer class ProfileSerializer(ModelSerializer): diff --git a/server/apps/profile/serializers/rcrainfo_profile.py b/server/profile/serializers/rcrainfo_profile.py similarity index 96% rename from server/apps/profile/serializers/rcrainfo_profile.py rename to server/profile/serializers/rcrainfo_profile.py index 72d43a956..4d393e0f6 100644 --- a/server/apps/profile/serializers/rcrainfo_profile.py +++ b/server/profile/serializers/rcrainfo_profile.py @@ -1,8 +1,8 @@ +from profile.models import RcrainfoProfile + from rest_framework import serializers from rest_framework.serializers import ModelSerializer -from apps.profile.models import RcrainfoProfile - from .rcrasite_access import RcraSitePermissionSerializer diff --git a/server/apps/profile/serializers/rcrasite_access.py b/server/profile/serializers/rcrasite_access.py similarity index 98% rename from server/apps/profile/serializers/rcrasite_access.py rename to server/profile/serializers/rcrasite_access.py index 6c6955f69..d71086ed7 100644 --- a/server/apps/profile/serializers/rcrasite_access.py +++ b/server/profile/serializers/rcrasite_access.py @@ -1,8 +1,8 @@ +from profile.models import RcrainfoSiteAccess + from rest_framework import serializers from rest_framework.exceptions import ValidationError -from apps.profile.models import RcrainfoSiteAccess - class RcraSiteBaseSerializer(serializers.ModelSerializer): def __str__(self): diff --git a/server/apps/profile/services.py b/server/profile/services.py similarity index 92% rename from server/apps/profile/services.py rename to server/profile/services.py index 34e39d98c..09962806b 100644 --- a/server/apps/profile/services.py +++ b/server/profile/services.py @@ -1,17 +1,17 @@ """business logic related to a user's Haztrak profile (note: not their RcrainfoProfile)""" +from profile.models import Profile, RcrainfoProfile, RcrainfoSiteAccess +from profile.serializers import RcrainfoSitePermissionsSerializer from typing import Optional from django.conf import settings from django.db import transaction -from apps.core.models import TrakUser -from apps.core.services import RcraClient, get_rcra_client -from apps.profile.models import Profile, RcrainfoProfile, RcrainfoSiteAccess -from apps.profile.serializers import RcrainfoSitePermissionsSerializer -from apps.rcrasite.models import RcraSite -from apps.rcrasite.services import RcraSiteService -from apps.site.services import SiteServiceError +from core.models import TrakUser +from core.services import RcraClient, get_rcra_client +from orgsite.services import SiteServiceError +from rcrasite.models import RcraSite +from rcrasite.services import RcraSiteService @transaction.atomic diff --git a/server/apps/rcrasite/tests/__init__.py b/server/profile/tests/__init__.py similarity index 100% rename from server/apps/rcrasite/tests/__init__.py rename to server/profile/tests/__init__.py diff --git a/server/apps/profile/tests/conftest.py b/server/profile/tests/conftest.py similarity index 91% rename from server/apps/profile/tests/conftest.py rename to server/profile/tests/conftest.py index b9edea564..2d3bf8f45 100644 --- a/server/apps/profile/tests/conftest.py +++ b/server/profile/tests/conftest.py @@ -1,10 +1,10 @@ +from profile.models import RcrainfoProfile, RcrainfoSiteAccess from typing import Optional import pytest from faker import Faker -from apps.conftest import SiteIDProvider -from apps.profile.models import RcrainfoProfile, RcrainfoSiteAccess +from conftest import SiteIDProvider @pytest.fixture diff --git a/server/apps/profile/tests/test_models.py b/server/profile/tests/test_models.py similarity index 97% rename from server/apps/profile/tests/test_models.py rename to server/profile/tests/test_models.py index 962afc9ca..c77613195 100644 --- a/server/apps/profile/tests/test_models.py +++ b/server/profile/tests/test_models.py @@ -1,6 +1,6 @@ -import pytest +from profile.models import Profile, RcrainfoProfile -from apps.profile.models import Profile, RcrainfoProfile +import pytest @pytest.mark.django_db diff --git a/server/apps/profile/tests/test_serializers.py b/server/profile/tests/test_serializers.py similarity index 97% rename from server/apps/profile/tests/test_serializers.py rename to server/profile/tests/test_serializers.py index 7a6927eda..391ffc022 100644 --- a/server/apps/profile/tests/test_serializers.py +++ b/server/profile/tests/test_serializers.py @@ -1,12 +1,12 @@ -import pytest - -from apps.profile.models import RcrainfoSiteAccess -from apps.profile.serializers import ( +from profile.models import RcrainfoSiteAccess +from profile.serializers import ( ProfileSerializer, RcrainfoSitePermissionsSerializer, RcraSitePermissionSerializer, ) +import pytest + @pytest.mark.django_db class TestTrakProfileSerializer: diff --git a/server/apps/profile/tests/test_services.py b/server/profile/tests/test_services.py similarity index 95% rename from server/apps/profile/tests/test_services.py rename to server/profile/tests/test_services.py index ffbe97f80..a11fc9618 100644 --- a/server/apps/profile/tests/test_services.py +++ b/server/profile/tests/test_services.py @@ -1,5 +1,5 @@ -from apps.profile.models import Profile, RcrainfoProfile -from apps.profile.services import ( +from profile.models import Profile, RcrainfoProfile +from profile.services import ( get_or_create_rcra_profile, get_user_profile, get_user_rcrainfo_profile, diff --git a/server/apps/profile/tests/test_views.py b/server/profile/tests/test_views.py similarity index 98% rename from server/apps/profile/tests/test_views.py rename to server/profile/tests/test_views.py index 7558fa945..65c0475f5 100644 --- a/server/apps/profile/tests/test_views.py +++ b/server/profile/tests/test_views.py @@ -1,10 +1,10 @@ +from profile.views import ProfileDetailsView, RcrainfoProfileRetrieveUpdateView + import pytest from rest_framework import status from rest_framework.reverse import reverse from rest_framework.test import APIRequestFactory, force_authenticate -from apps.profile.views import ProfileDetailsView, RcrainfoProfileRetrieveUpdateView - class TestRcrainfoProfileRetrieveUpdateView: factory = APIRequestFactory() diff --git a/server/apps/profile/urls.py b/server/profile/urls.py similarity index 100% rename from server/apps/profile/urls.py rename to server/profile/urls.py diff --git a/server/apps/profile/views.py b/server/profile/views.py similarity index 89% rename from server/apps/profile/views.py rename to server/profile/views.py index 4d014d111..128c0e161 100644 --- a/server/apps/profile/views.py +++ b/server/profile/views.py @@ -1,3 +1,7 @@ +from profile.models import Profile, RcrainfoProfile +from profile.serializers import ProfileSerializer, RcrainfoProfileSerializer +from profile.services import get_user_profile + from celery.exceptions import CeleryError from celery.result import AsyncResult as CeleryTask from rest_framework import status @@ -5,10 +9,7 @@ from rest_framework.request import Request from rest_framework.response import Response -from apps.profile.models import Profile, RcrainfoProfile -from apps.profile.serializers import ProfileSerializer, RcrainfoProfileSerializer -from apps.profile.services import get_user_profile -from apps.rcrasite.tasks import sync_user_rcrainfo_sites +from rcrasite.tasks import sync_user_rcrainfo_sites class ProfileDetailsView(RetrieveAPIView): diff --git a/server/apps/site/__init__.py b/server/rcrasite/__init__.py similarity index 100% rename from server/apps/site/__init__.py rename to server/rcrasite/__init__.py diff --git a/server/apps/rcrasite/admin.py b/server/rcrasite/admin.py similarity index 85% rename from server/apps/rcrasite/admin.py rename to server/rcrasite/admin.py index 28aa241bc..d424e10be 100644 --- a/server/apps/rcrasite/admin.py +++ b/server/rcrasite/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin -from apps.core.admin import HiddenListView -from apps.rcrasite.models import ( +from core.admin import HiddenListView +from rcrasite.models import ( Address, Contact, RcraSite, diff --git a/server/apps/rcrasite/apps.py b/server/rcrasite/apps.py similarity index 82% rename from server/apps/rcrasite/apps.py rename to server/rcrasite/apps.py index c9b5b517c..e6f0e727e 100644 --- a/server/apps/rcrasite/apps.py +++ b/server/rcrasite/apps.py @@ -3,4 +3,4 @@ class SitesConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" - name = "apps.rcrasite" + name = "rcrasite" diff --git a/server/rcrasite/migrations/0001_initial.py b/server/rcrasite/migrations/0001_initial.py new file mode 100644 index 000000000..5c1d7b011 --- /dev/null +++ b/server/rcrasite/migrations/0001_initial.py @@ -0,0 +1,268 @@ +# Generated by Django 4.2.10 on 2024-02-21 22:17 + +import rcrasite.models.contact +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="Address", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ("street_number", models.CharField(blank=True, max_length=12, null=True)), + ("address1", models.CharField(max_length=50, verbose_name="address 1")), + ( + "address2", + models.CharField( + blank=True, + default=None, + max_length=50, + null=True, + verbose_name="address 2", + ), + ), + ("city", models.CharField(blank=True, max_length=25, null=True)), + ( + "state", + models.CharField( + blank=True, + choices=[ + ("AK", "Alaska"), + ("AL", "Alabama"), + ("AP", "Armed Forces Pacific"), + ("AR", "Arkansas"), + ("AZ", "Arizona"), + ("CA", "California"), + ("CO", "Colorado"), + ("CT", "Connecticut"), + ("DC", "Washington DC"), + ("DE", "Delaware"), + ("FL", "Florida"), + ("GA", "Georgia"), + ("GU", "Guam"), + ("HI", "Hawaii"), + ("IA", "Iowa"), + ("ID", "Idaho"), + ("IL", "Illinois"), + ("IN", "Indiana"), + ("KS", "Kansas"), + ("KY", "Kentucky"), + ("LA", "Louisiana"), + ("MA", "Massachusetts"), + ("MD", "Maryland"), + ("ME", "Maine"), + ("MI", "Michigan"), + ("MN", "Minnesota"), + ("MO", "Missouri"), + ("MS", "Mississippi"), + ("MT", "Montana"), + ("NC", "North Carolina"), + ("ND", "North Dakota"), + ("NE", "Nebraska"), + ("NH", "New Hampshire"), + ("NJ", "New Jersey"), + ("NM", "New Mexico"), + ("NV", "Nevada"), + ("NY", "New York"), + ("OH", "Ohio"), + ("OK", "Oklahoma"), + ("OR", "Oregon"), + ("PA", "Pennsylvania"), + ("PR", "Puerto Rico"), + ("RI", "Rhode Island"), + ("SC", "South Carolina"), + ("SD", "South Dakota"), + ("TN", "Tennessee"), + ("TX", "Texas"), + ("UT", "Utah"), + ("VA", "Virginia"), + ("VI", "Virgin Islands"), + ("VT", "Vermont"), + ("WA", "Washington"), + ("WI", "Wisconsin"), + ("WV", "West Virginia"), + ("WY", "Wyoming"), + ("XA", "REGION 01 PURVIEW"), + ("XB", "REGION 02 PURVIEW"), + ("XC", "REGION 03 PURVIEW"), + ("XD", "REGION 04 PURVIEW"), + ("XE", "REGION 05 PURVIEW"), + ("XF", "REGION 06 PURVIEW"), + ("XG", "REGION 07 PURVIEW"), + ("XH", "REGION 08 PURVIEW"), + ("XI", "REGION 09 PURVIEW"), + ("XJ", "REGION 10 PURVIEW"), + ], + max_length=3, + null=True, + ), + ), + ( + "country", + models.CharField( + blank=True, + choices=[("US", "United States"), ("MX", "Mexico"), ("CA", "Canada")], + max_length=3, + null=True, + ), + ), + ("zip", models.CharField(blank=True, max_length=5, null=True)), + ], + options={ + "ordering": ["address1"], + }, + ), + migrations.CreateModel( + name="Contact", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ("first_name", models.CharField(blank=True, max_length=38, null=True)), + ("middle_initial", models.CharField(blank=True, max_length=1, null=True)), + ("last_name", models.CharField(blank=True, max_length=38, null=True)), + ("email", models.EmailField(blank=True, max_length=254, null=True)), + ("company_name", models.CharField(blank=True, max_length=80, null=True)), + ], + options={ + "ordering": ["first_name"], + }, + ), + migrations.CreateModel( + name="RcraPhone", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ("number", rcrasite.models.contact.RcraPhoneNumber(max_length=12)), + ("extension", models.CharField(blank=True, max_length=6, null=True)), + ], + options={ + "ordering": ["number"], + }, + ), + migrations.CreateModel( + name="RcraSite", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ( + "site_type", + models.CharField( + blank=True, + choices=[ + ("Generator", "Generator"), + ("Transporter", "Transporter"), + ("Tsdf", "Tsdf"), + ("Broker", "Broker"), + ], + max_length=20, + null=True, + ), + ), + ( + "epa_id", + models.CharField(max_length=25, unique=True, verbose_name="EPA ID number"), + ), + ("name", models.CharField(max_length=200)), + ("modified", models.BooleanField(blank=True, null=True)), + ("registered", models.BooleanField(blank=True, null=True)), + ( + "gis_primary", + models.BooleanField( + blank=True, default=False, null=True, verbose_name="GIS primary" + ), + ), + ( + "can_esign", + models.BooleanField( + blank=True, null=True, verbose_name="can electronically sign" + ), + ), + ( + "limited_esign", + models.BooleanField( + blank=True, null=True, verbose_name="limited electronic signing ability" + ), + ), + ( + "registered_emanifest_user", + models.BooleanField( + blank=True, + default=False, + null=True, + verbose_name="has registered e-manifest user", + ), + ), + ( + "contact", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="rcrasite.contact", + verbose_name="contact information", + ), + ), + ( + "emergency_phone", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="rcrasite.rcraphone", + ), + ), + ( + "mail_address", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="mail_address", + to="rcrasite.address", + ), + ), + ( + "site_address", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="site_address", + to="rcrasite.address", + ), + ), + ], + options={ + "verbose_name": "RCRAInfo Site", + "verbose_name_plural": "RCRAInfo Sites", + "ordering": ["epa_id"], + }, + ), + migrations.AddField( + model_name="contact", + name="phone", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="rcrasite.rcraphone", + ), + ), + ] diff --git a/server/apps/site/migrations/__init__.py b/server/rcrasite/migrations/__init__.py similarity index 100% rename from server/apps/site/migrations/__init__.py rename to server/rcrasite/migrations/__init__.py diff --git a/server/apps/rcrasite/models/__init__.py b/server/rcrasite/models/__init__.py similarity index 100% rename from server/apps/rcrasite/models/__init__.py rename to server/rcrasite/models/__init__.py diff --git a/server/apps/rcrasite/models/contact.py b/server/rcrasite/models/contact.py similarity index 100% rename from server/apps/rcrasite/models/contact.py rename to server/rcrasite/models/contact.py diff --git a/server/apps/rcrasite/models/rcrasite.py b/server/rcrasite/models/rcrasite.py similarity index 98% rename from server/apps/rcrasite/models/rcrasite.py rename to server/rcrasite/models/rcrasite.py index c1a51dc4d..4e8761107 100644 --- a/server/apps/rcrasite/models/rcrasite.py +++ b/server/rcrasite/models/rcrasite.py @@ -5,7 +5,7 @@ from django.db import models from django.utils.translation import gettext_lazy as _ -from apps.rcrasite.models import Address, Contact, RcraPhone +from rcrasite.models import Address, Contact, RcraPhone logger = logging.getLogger(__name__) diff --git a/server/apps/rcrasite/serializers/__init__.py b/server/rcrasite/serializers/__init__.py similarity index 100% rename from server/apps/rcrasite/serializers/__init__.py rename to server/rcrasite/serializers/__init__.py diff --git a/server/apps/rcrasite/serializers/address_serializer.py b/server/rcrasite/serializers/address_serializer.py similarity index 95% rename from server/apps/rcrasite/serializers/address_serializer.py rename to server/rcrasite/serializers/address_serializer.py index 1a31d169e..f471baf20 100644 --- a/server/apps/rcrasite/serializers/address_serializer.py +++ b/server/rcrasite/serializers/address_serializer.py @@ -3,7 +3,7 @@ from rest_framework import serializers from rest_framework.exceptions import ValidationError -from apps.rcrasite.models import Address, RcraCountries, RcraStates +from rcrasite.models import Address, RcraCountries, RcraStates from .base_serializer import SitesBaseSerializer diff --git a/server/apps/rcrasite/serializers/base_serializer.py b/server/rcrasite/serializers/base_serializer.py similarity index 100% rename from server/apps/rcrasite/serializers/base_serializer.py rename to server/rcrasite/serializers/base_serializer.py diff --git a/server/apps/rcrasite/serializers/contact_serializer.py b/server/rcrasite/serializers/contact_serializer.py similarity index 97% rename from server/apps/rcrasite/serializers/contact_serializer.py rename to server/rcrasite/serializers/contact_serializer.py index 749761525..449197049 100644 --- a/server/apps/rcrasite/serializers/contact_serializer.py +++ b/server/rcrasite/serializers/contact_serializer.py @@ -1,6 +1,6 @@ from rest_framework import serializers -from apps.rcrasite.models import Contact +from rcrasite.models import Contact from .base_serializer import SitesBaseSerializer diff --git a/server/apps/rcrasite/serializers/site_serializer.py b/server/rcrasite/serializers/site_serializer.py similarity index 94% rename from server/apps/rcrasite/serializers/site_serializer.py rename to server/rcrasite/serializers/site_serializer.py index 1d1e930e9..f38313ca3 100644 --- a/server/apps/rcrasite/serializers/site_serializer.py +++ b/server/rcrasite/serializers/site_serializer.py @@ -1,7 +1,7 @@ from rest_framework import serializers -from apps.rcrasite.models import RcraSite, RcraSiteType -from apps.rcrasite.serializers import AddressSerializer, ContactSerializer, RcraPhoneSerializer +from rcrasite.models import RcraSite, RcraSiteType +from rcrasite.serializers import AddressSerializer, ContactSerializer, RcraPhoneSerializer from .base_serializer import SitesBaseSerializer diff --git a/server/apps/rcrasite/services/__init__.py b/server/rcrasite/services/__init__.py similarity index 100% rename from server/apps/rcrasite/services/__init__.py rename to server/rcrasite/services/__init__.py diff --git a/server/apps/rcrasite/services/rcra_site.py b/server/rcrasite/services/rcra_site.py similarity index 95% rename from server/apps/rcrasite/services/rcra_site.py rename to server/rcrasite/services/rcra_site.py index d418daef0..6fa7733ac 100644 --- a/server/apps/rcrasite/services/rcra_site.py +++ b/server/rcrasite/services/rcra_site.py @@ -6,9 +6,9 @@ from django.db.models import QuerySet from rest_framework.exceptions import ValidationError -from apps.core.services import RcraClient, get_rcra_client -from apps.rcrasite.models import RcraSite -from apps.rcrasite.serializers import RcraSiteSerializer +from core.services import RcraClient, get_rcra_client +from rcrasite.models import RcraSite +from rcrasite.serializers import RcraSiteSerializer from .rcra_site_search import RcraSiteSearch diff --git a/server/apps/rcrasite/services/rcra_site_search.py b/server/rcrasite/services/rcra_site_search.py similarity index 98% rename from server/apps/rcrasite/services/rcra_site_search.py rename to server/rcrasite/services/rcra_site_search.py index a993c1a27..fe6876869 100644 --- a/server/apps/rcrasite/services/rcra_site_search.py +++ b/server/rcrasite/services/rcra_site_search.py @@ -2,7 +2,7 @@ from emanifest import RcrainfoResponse -from apps.core.services import RcraClient +from core.services import RcraClient SiteType = Literal["Generator", "Tsdf", "Transporter", "Broker"] diff --git a/server/apps/rcrasite/tasks/__init__.py b/server/rcrasite/tasks/__init__.py similarity index 100% rename from server/apps/rcrasite/tasks/__init__.py rename to server/rcrasite/tasks/__init__.py diff --git a/server/apps/rcrasite/tasks/profile_tasks.py b/server/rcrasite/tasks/profile_tasks.py similarity index 93% rename from server/apps/rcrasite/tasks/profile_tasks.py rename to server/rcrasite/tasks/profile_tasks.py index 344fdefe8..b279bd337 100644 --- a/server/apps/rcrasite/tasks/profile_tasks.py +++ b/server/rcrasite/tasks/profile_tasks.py @@ -1,11 +1,10 @@ import logging +from profile.services import RcraProfileService, RcraProfileServiceError from celery import Task, shared_task, states from celery.exceptions import Ignore, Reject from requests import RequestException -from apps.profile.services import RcraProfileService, RcraProfileServiceError - logger = logging.getLogger(__name__) diff --git a/server/apps/rcrasite/tasks/site_tasks.py b/server/rcrasite/tasks/site_tasks.py similarity index 91% rename from server/apps/rcrasite/tasks/site_tasks.py rename to server/rcrasite/tasks/site_tasks.py index db2f88d73..ecc53ec59 100644 --- a/server/apps/rcrasite/tasks/site_tasks.py +++ b/server/rcrasite/tasks/site_tasks.py @@ -3,7 +3,7 @@ from celery import shared_task, states from celery.exceptions import Ignore -from apps.rcrasite.services import RcraSiteService +from rcrasite.services import RcraSiteService logger = logging.getLogger(__name__) diff --git a/server/apps/site/tests/__init__.py b/server/rcrasite/tests/__init__.py similarity index 100% rename from server/apps/site/tests/__init__.py rename to server/rcrasite/tests/__init__.py diff --git a/server/apps/rcrasite/tests/test_models.py b/server/rcrasite/tests/test_models.py similarity index 96% rename from server/apps/rcrasite/tests/test_models.py rename to server/rcrasite/tests/test_models.py index ce30aa811..f4413933b 100644 --- a/server/apps/rcrasite/tests/test_models.py +++ b/server/rcrasite/tests/test_models.py @@ -2,7 +2,7 @@ from django.core.exceptions import ValidationError from django.db import IntegrityError -from apps.rcrasite.models import Address, Contact +from rcrasite.models import Address, Contact @pytest.mark.django_db diff --git a/server/apps/rcrasite/tests/test_serializers.py b/server/rcrasite/tests/test_serializers.py similarity index 94% rename from server/apps/rcrasite/tests/test_serializers.py rename to server/rcrasite/tests/test_serializers.py index 583b8620e..12606cc52 100644 --- a/server/apps/rcrasite/tests/test_serializers.py +++ b/server/rcrasite/tests/test_serializers.py @@ -1,6 +1,6 @@ import pytest -from apps.rcrasite.serializers import ( +from rcrasite.serializers import ( ContactSerializer, RcraSiteSerializer, ) diff --git a/server/apps/rcrasite/tests/test_site_search.py b/server/rcrasite/tests/test_site_search.py similarity index 96% rename from server/apps/rcrasite/tests/test_site_search.py rename to server/rcrasite/tests/test_site_search.py index 16b46df95..9b806ee15 100644 --- a/server/apps/rcrasite/tests/test_site_search.py +++ b/server/rcrasite/tests/test_site_search.py @@ -2,8 +2,8 @@ import pytest -from apps.core.services import RcraClient -from apps.rcrasite.services import RcraSiteSearch +from core.services import RcraClient +from rcrasite.services import RcraSiteSearch class TestRcraSiteSearchClass: diff --git a/server/apps/rcrasite/tests/test_views.py b/server/rcrasite/tests/test_views.py similarity index 95% rename from server/apps/rcrasite/tests/test_views.py rename to server/rcrasite/tests/test_views.py index 8d7cdaacd..ef57dc6cc 100644 --- a/server/apps/rcrasite/tests/test_views.py +++ b/server/rcrasite/tests/test_views.py @@ -6,8 +6,8 @@ from rest_framework.reverse import reverse from rest_framework.test import APIClient, APIRequestFactory, force_authenticate -from apps.rcrasite.models import RcraSiteType # type: ignore -from apps.rcrasite.views import HandlerSearchView, RcraSiteSearchView # type: ignore +from rcrasite.models import RcraSiteType # type: ignore +from rcrasite.views import HandlerSearchView, RcraSiteSearchView # type: ignore class TestRcraSiteView: @@ -111,7 +111,7 @@ def set_up(self): self.request_factory = APIRequestFactory() def test_valid_search_returns_200(self, user_factory): - with patch("apps.rcrasite.views.RcraSiteService") as MockRcraSiteService: + with patch("rcrasite.views.RcraSiteService") as MockRcraSiteService: mock_service = MockRcraSiteService.return_value mock_service.search_rcrainfo_handlers.return_value = {"sites": []} user = user_factory() diff --git a/server/apps/rcrasite/urls.py b/server/rcrasite/urls.py similarity index 82% rename from server/apps/rcrasite/urls.py rename to server/rcrasite/urls.py index f3e81df8c..781a94a22 100644 --- a/server/apps/rcrasite/urls.py +++ b/server/rcrasite/urls.py @@ -1,6 +1,6 @@ from django.urls import include, path -from apps.rcrasite.views import HandlerSearchView, RcraSiteDetailsView, RcraSiteSearchView +from rcrasite.views import HandlerSearchView, RcraSiteDetailsView, RcraSiteSearchView rcrainfo_rcrasite_patterns = ( [ diff --git a/server/apps/rcrasite/views.py b/server/rcrasite/views.py similarity index 95% rename from server/apps/rcrasite/views.py rename to server/rcrasite/views.py index 68bf6b675..adc6da678 100644 --- a/server/apps/rcrasite/views.py +++ b/server/rcrasite/views.py @@ -10,9 +10,9 @@ from rest_framework.response import Response from rest_framework.views import APIView -from apps.rcrasite.models import RcraSite -from apps.rcrasite.serializers import RcraSiteSearchSerializer, RcraSiteSerializer -from apps.rcrasite.services import RcraSiteService, query_rcra_sites +from rcrasite.models import RcraSite +from rcrasite.serializers import RcraSiteSearchSerializer, RcraSiteSerializer +from rcrasite.services import RcraSiteService, query_rcra_sites logger = logging.getLogger(__name__) diff --git a/server/apps/wasteline/__init__.py b/server/wasteline/__init__.py similarity index 100% rename from server/apps/wasteline/__init__.py rename to server/wasteline/__init__.py diff --git a/server/apps/wasteline/admin.py b/server/wasteline/admin.py similarity index 93% rename from server/apps/wasteline/admin.py rename to server/wasteline/admin.py index 6450b3ce0..7df61fa72 100644 --- a/server/apps/wasteline/admin.py +++ b/server/wasteline/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from apps.wasteline.models import DotLookup, WasteCode, WasteLine +from wasteline.models import DotLookup, WasteCode, WasteLine @admin.register(DotLookup) diff --git a/server/apps/wasteline/apps.py b/server/wasteline/apps.py similarity index 81% rename from server/apps/wasteline/apps.py rename to server/wasteline/apps.py index ff96512fb..11bca37bb 100644 --- a/server/apps/wasteline/apps.py +++ b/server/wasteline/apps.py @@ -3,4 +3,4 @@ class WastelineConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" - name = "apps.wasteline" + name = "wasteline" diff --git a/server/apps/wasteline/migrations/0001_initial.py b/server/wasteline/migrations/0001_initial.py similarity index 100% rename from server/apps/wasteline/migrations/0001_initial.py rename to server/wasteline/migrations/0001_initial.py diff --git a/server/apps/wasteline/migrations/0002_state_waste_codes.py b/server/wasteline/migrations/0002_state_waste_codes.py similarity index 99% rename from server/apps/wasteline/migrations/0002_state_waste_codes.py rename to server/wasteline/migrations/0002_state_waste_codes.py index aff9f9311..706212d5f 100644 --- a/server/apps/wasteline/migrations/0002_state_waste_codes.py +++ b/server/wasteline/migrations/0002_state_waste_codes.py @@ -1,6 +1,6 @@ from django.db import migrations -from apps.wasteline.models import WasteCode +from wasteline.models import WasteCode def populate_state_waste_codes(apps, schema_editor): diff --git a/server/apps/wasteline/migrations/0003_federal_waste_codes.py b/server/wasteline/migrations/0003_federal_waste_codes.py similarity index 99% rename from server/apps/wasteline/migrations/0003_federal_waste_codes.py rename to server/wasteline/migrations/0003_federal_waste_codes.py index 6017d8133..2d52c8abe 100644 --- a/server/apps/wasteline/migrations/0003_federal_waste_codes.py +++ b/server/wasteline/migrations/0003_federal_waste_codes.py @@ -1,6 +1,6 @@ from django.db import migrations -from apps.wasteline.models import WasteCode +from wasteline.models import WasteCode def populate_federal_waste_codes(apps, schema_editor): diff --git a/server/apps/wasteline/migrations/0004_dot_id_numbers.py b/server/wasteline/migrations/0004_dot_id_numbers.py similarity index 99% rename from server/apps/wasteline/migrations/0004_dot_id_numbers.py rename to server/wasteline/migrations/0004_dot_id_numbers.py index 49222ba61..9b02a8620 100644 --- a/server/apps/wasteline/migrations/0004_dot_id_numbers.py +++ b/server/wasteline/migrations/0004_dot_id_numbers.py @@ -2,7 +2,7 @@ from django.db import migrations -from apps.wasteline.models import DotLookupType, DotLookup +from wasteline.models import DotLookupType, DotLookup def populate_dot_id_numbers(apps, schema_editor): diff --git a/server/apps/wasteline/migrations/0005_dot_packing_groups.py b/server/wasteline/migrations/0005_dot_packing_groups.py similarity index 98% rename from server/apps/wasteline/migrations/0005_dot_packing_groups.py rename to server/wasteline/migrations/0005_dot_packing_groups.py index b5f7b246c..ffdb3dcfc 100644 --- a/server/apps/wasteline/migrations/0005_dot_packing_groups.py +++ b/server/wasteline/migrations/0005_dot_packing_groups.py @@ -2,7 +2,7 @@ from django.db import migrations -from apps.wasteline.models import DotLookup, DotLookupType +from wasteline.models import DotLookup, DotLookupType def populate_dot_packing_groups(apps, schema_editor): diff --git a/server/apps/wasteline/migrations/0006_dot_shipping_names.py b/server/wasteline/migrations/0006_dot_shipping_names.py similarity index 99% rename from server/apps/wasteline/migrations/0006_dot_shipping_names.py rename to server/wasteline/migrations/0006_dot_shipping_names.py index 7fa549ec6..39b7e12fb 100644 --- a/server/apps/wasteline/migrations/0006_dot_shipping_names.py +++ b/server/wasteline/migrations/0006_dot_shipping_names.py @@ -2,7 +2,7 @@ from django.db import migrations -from apps.wasteline.models import DotLookupType, DotLookup +from wasteline.models import DotLookupType, DotLookup def populate_dot_shipping_names(apps, schema_editor): diff --git a/server/apps/wasteline/migrations/__init__.py b/server/wasteline/migrations/__init__.py similarity index 100% rename from server/apps/wasteline/migrations/__init__.py rename to server/wasteline/migrations/__init__.py diff --git a/server/apps/wasteline/models.py b/server/wasteline/models.py similarity index 100% rename from server/apps/wasteline/models.py rename to server/wasteline/models.py diff --git a/server/apps/wasteline/serializers.py b/server/wasteline/serializers.py similarity index 97% rename from server/apps/wasteline/serializers.py rename to server/wasteline/serializers.py index ddfbc0b4b..979c6f8aa 100644 --- a/server/apps/wasteline/serializers.py +++ b/server/wasteline/serializers.py @@ -1,6 +1,6 @@ from rest_framework import serializers -from apps.wasteline.models import DotLookup, WasteCode, WasteLine +from wasteline.models import DotLookup, WasteCode, WasteLine class WasteBaseSerializer(serializers.ModelSerializer): diff --git a/server/apps/wasteline/services.py b/server/wasteline/services.py similarity index 95% rename from server/apps/wasteline/services.py rename to server/wasteline/services.py index a4c848f96..5fb08fb85 100644 --- a/server/apps/wasteline/services.py +++ b/server/wasteline/services.py @@ -1,6 +1,6 @@ from typing import Optional -from apps.wasteline.models import DotLookup, WasteCode +from wasteline.models import DotLookup, WasteCode def filter_dot_shipping_names(query: Optional[str]) -> list[str]: diff --git a/server/apps/wasteline/tasks.py b/server/wasteline/tasks.py similarity index 92% rename from server/apps/wasteline/tasks.py rename to server/wasteline/tasks.py index b52df7c29..f2c785529 100644 --- a/server/apps/wasteline/tasks.py +++ b/server/wasteline/tasks.py @@ -9,7 +9,7 @@ @shared_task(name="pull_federal_code", bind=True) def pull_federal_codes(self, api_user: Optional[str] = None): - from apps.core.services import get_rcra_client + from core.services import get_rcra_client logger.debug(f"start task {self.name}") try: diff --git a/server/apps/wasteline/tests/__init__.py b/server/wasteline/tests/__init__.py similarity index 100% rename from server/apps/wasteline/tests/__init__.py rename to server/wasteline/tests/__init__.py diff --git a/server/apps/wasteline/tests/conftest.py b/server/wasteline/tests/conftest.py similarity index 94% rename from server/apps/wasteline/tests/conftest.py rename to server/wasteline/tests/conftest.py index 45f96c718..1c77e2a07 100644 --- a/server/apps/wasteline/tests/conftest.py +++ b/server/wasteline/tests/conftest.py @@ -3,8 +3,8 @@ import pytest from faker import Faker -from apps.manifest.models import Manifest -from apps.wasteline.models import DotLookup, DotLookupType, WasteCode, WasteLine +from manifest.models import Manifest +from wasteline.models import DotLookup, DotLookupType, WasteCode, WasteLine @pytest.fixture diff --git a/server/apps/wasteline/tests/test_waste_views.py b/server/wasteline/tests/test_waste_views.py similarity index 98% rename from server/apps/wasteline/tests/test_waste_views.py rename to server/wasteline/tests/test_waste_views.py index f2243bfc0..cfbf24c34 100644 --- a/server/apps/wasteline/tests/test_waste_views.py +++ b/server/wasteline/tests/test_waste_views.py @@ -4,8 +4,8 @@ from rest_framework.reverse import reverse from rest_framework.test import APIRequestFactory, force_authenticate -from apps.wasteline.models import DotLookupType, WasteCode -from apps.wasteline.views import ( +from wasteline.models import DotLookupType, WasteCode +from wasteline.views import ( DotHazardClassView, DotIdNumberView, DotShippingNameView, diff --git a/server/apps/wasteline/tests/test_wl_models.py b/server/wasteline/tests/test_wl_models.py similarity index 97% rename from server/apps/wasteline/tests/test_wl_models.py rename to server/wasteline/tests/test_wl_models.py index 29a17d78a..9b381f8c2 100644 --- a/server/apps/wasteline/tests/test_wl_models.py +++ b/server/wasteline/tests/test_wl_models.py @@ -1,7 +1,7 @@ import pytest from django.db import IntegrityError -from apps.wasteline.models import DotLookup, DotLookupType, WasteCode +from wasteline.models import DotLookup, DotLookupType, WasteCode @pytest.mark.django_db diff --git a/server/apps/wasteline/tests/test_wl_serializer.py b/server/wasteline/tests/test_wl_serializer.py similarity index 84% rename from server/apps/wasteline/tests/test_wl_serializer.py rename to server/wasteline/tests/test_wl_serializer.py index 6d41f38bc..6ce4d8350 100644 --- a/server/apps/wasteline/tests/test_wl_serializer.py +++ b/server/wasteline/tests/test_wl_serializer.py @@ -1,6 +1,6 @@ import pytest -from apps.wasteline.serializers import WasteLineSerializer +from wasteline.serializers import WasteLineSerializer @pytest.fixture diff --git a/server/apps/wasteline/urls.py b/server/wasteline/urls.py similarity index 94% rename from server/apps/wasteline/urls.py rename to server/wasteline/urls.py index eb21a2205..1d41b8d6e 100644 --- a/server/apps/wasteline/urls.py +++ b/server/wasteline/urls.py @@ -1,6 +1,6 @@ from django.urls import include, path -from apps.wasteline.views import ( # type: ignore +from wasteline.views import ( # type: ignore DotHazardClassView, DotIdNumberView, DotShippingNameView, diff --git a/server/apps/wasteline/views.py b/server/wasteline/views.py similarity index 96% rename from server/apps/wasteline/views.py rename to server/wasteline/views.py index 800d0f954..e23e54738 100644 --- a/server/apps/wasteline/views.py +++ b/server/wasteline/views.py @@ -11,9 +11,9 @@ from rest_framework.response import Response from rest_framework.views import APIView -from apps.wasteline.models import DotLookup, WasteCode -from apps.wasteline.serializers import WasteCodeSerializer -from apps.wasteline.services import ( +from wasteline.models import DotLookup, WasteCode +from wasteline.serializers import WasteCodeSerializer +from wasteline.services import ( filter_dot_hazard_classes, filter_dot_id_numbers, filter_dot_shipping_names,