refactor(access): Rename History models

ref: #765 #759
This commit is contained in:
2025-05-18 03:38:58 +09:30
parent 41ec865618
commit ef82c40555
23 changed files with 72 additions and 42 deletions

View File

@ -0,0 +1,30 @@
# Generated by Django 5.1.9 on 2025-05-17 17:50
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('access', '0010_company_alter_entity_entity_type_alter_person_dob_and_more'),
('core', '0026_rename_manufacturerhistory_manufactureraudithistory'),
]
operations = [
migrations.RenameModel(
old_name='EntityHistory',
new_name='EntityAuditHistory',
),
migrations.RenameModel(
old_name='OrganizationHistory',
new_name='OrganizationAuditHistory',
),
migrations.RenameModel(
old_name='RoleHistory',
new_name='RoleAuditHistory',
),
migrations.RenameModel(
old_name='TeamHistory',
new_name='TeamAuditHistory',
),
]

View File

@ -238,12 +238,12 @@ class Entity(
def save_history(self, before: dict, after: dict) -> bool:
from access.models.entity_history import EntityHistory
from access.models.entity_history import EntityAuditHistory
history = super().save_history(
before = before,
after = after,
history_model = EntityHistory
history_model = EntityAuditHistory
)
return history

View File

@ -8,7 +8,7 @@ from devops.models.feature_flag import FeatureFlag
class EntityHistory(
class EntityAuditHistory(
ModelHistory
):

View File

@ -6,7 +6,7 @@ from access.models.tenant import Tenant
class OrganizationHistory(
class OrganizationAuditHistory(
ModelHistory
):

View File

@ -132,12 +132,12 @@ class Role(
def save_history(self, before: dict, after: dict) -> bool:
from access.models.role_history import RoleHistory
from access.models.role_history import RoleAuditHistory
history = super().save_history(
before = before,
after = after,
history_model = RoleHistory
history_model = RoleAuditHistory
)
return history

View File

@ -6,7 +6,7 @@ from access.models.role import Role
class RoleHistory(
class RoleAuditHistory(
ModelHistory
):

View File

@ -179,12 +179,12 @@ class Team(Group, TenancyObject):
def save_history(self, before: dict, after: dict) -> bool:
from access.models.team_history import TeamHistory
from access.models.team_history import TeamAuditHistory
history = super().save_history(
before = before,
after = after,
history_model = TeamHistory
history_model = TeamAuditHistory
)

View File

@ -6,7 +6,7 @@ from access.models.team import Team
class TeamHistory(
class TeamAuditHistory(
ModelHistory
):

View File

@ -145,12 +145,12 @@ class Tenant(SaveHistory):
def save_history(self, before: dict, after: dict) -> bool:
from access.models.organization_history import OrganizationHistory
from access.models.organization_history import OrganizationAuditHistory
history = super().save_history(
before = before,
after = after,
history_model = OrganizationHistory
history_model = OrganizationAuditHistory
)

View File

@ -1,6 +1,6 @@
from django.test import TestCase
from access.models.entity_history import Entity, EntityHistory
from access.models.entity_history import Entity, EntityAuditHistory
from core.tests.abstract.test_functional_history import HistoryEntriesCommon
@ -12,7 +12,7 @@ class HistoryTestCases(
field_name = 'model_notes'
history_model = EntityHistory
history_model = EntityAuditHistory
kwargs_create_obj: dict = {}
@ -43,7 +43,7 @@ class HistoryTestCases(
class EntityHistoryInheritedCases(
class EntityAuditHistoryInheritedCases(
HistoryTestCases,
):
@ -70,7 +70,7 @@ class EntityHistoryInheritedCases(
class EntityHistoryTest(
class EntityAuditHistoryTest(
HistoryTestCases,
TestCase,
):

View File

@ -1,6 +1,6 @@
from django.test import TestCase
from access.models.organization_history import Tenant as Organization, OrganizationHistory
from access.models.organization_history import Tenant as Organization, OrganizationAuditHistory
from core.tests.abstract.test_functional_history import HistoryEntriesCommon
@ -13,7 +13,7 @@ class History(
model = Organization
history_model = OrganizationHistory
history_model = OrganizationAuditHistory
@classmethod

View File

@ -2,13 +2,13 @@ from django.test import TestCase
from access.models.person import Person
from access.tests.functional.entity.test_functional_entity_history import (
EntityHistoryInheritedCases
EntityAuditHistoryInheritedCases
)
class PersonTestCases(
EntityHistoryInheritedCases,
EntityAuditHistoryInheritedCases,
):
field_name = 'model_notes'

View File

@ -1,6 +1,6 @@
from django.test import TestCase
from access.models.role_history import Role, RoleHistory
from access.models.role_history import Role, RoleAuditHistory
from core.tests.abstract.test_functional_history import HistoryEntriesCommon
@ -10,7 +10,7 @@ class HistoryTestCases(
HistoryEntriesCommon,
):
history_model = RoleHistory
history_model = RoleAuditHistory
kwargs_create_obj: dict = {}
@ -41,7 +41,7 @@ class HistoryTestCases(
class RoleHistoryTest(
class RoleAuditHistoryTest(
HistoryTestCases,
TestCase,
):

View File

@ -1,6 +1,6 @@
from django.test import TestCase
from access.models.team_history import Team, TeamHistory
from access.models.team_history import Team, TeamAuditHistory
from core.tests.abstract.test_functional_history import HistoryEntriesCommon
@ -13,7 +13,7 @@ class History(
model = Team
history_model = TeamHistory
history_model = TeamAuditHistory
@classmethod

View File

@ -1,7 +1,7 @@
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from access.models.entity_history import Entity, EntityHistory
from access.models.entity_history import Entity, EntityAuditHistory
from core.tests.abstract.test_unit_model_history_api_v2 import PrimaryModelHistoryAPI
@ -20,7 +20,7 @@ class ModelHistoryAPITestCases(
kwargs_create_audit_object: dict = {}
model = EntityHistory
model = EntityAuditHistory
@classmethod
def setUpTestData(self):

View File

@ -3,7 +3,7 @@ from django.test import TestCase
from core.tests.abstract.test_unit_model_history_api_v2 import PrimaryModelHistoryAPI
from access.models.organization_history import Tenant as Organization, OrganizationHistory
from access.models.organization_history import Tenant as Organization, OrganizationAuditHistory
@ -14,7 +14,7 @@ class ModelHistoryAPI(
audit_model = Organization
model = OrganizationHistory
model = OrganizationAuditHistory
@classmethod
def setUpTestData(self):

View File

@ -1,7 +1,7 @@
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from access.models.role_history import Role, RoleHistory
from access.models.role_history import Role, RoleAuditHistory
from core.tests.abstract.test_unit_model_history_api_v2 import PrimaryModelHistoryAPI
@ -51,7 +51,7 @@ class ModelHistoryAPITestCases(
class RoleHistoryAPITest(
class RoleAuditHistoryAPITest(
ModelHistoryAPITestCases,
TestCase,
):
@ -60,7 +60,7 @@ class RoleHistoryAPITest(
kwargs_create_audit_object: dict = {}
model = RoleHistory
model = RoleAuditHistory
@classmethod
def setUpTestData(self):

View File

@ -3,7 +3,7 @@ from django.test import TestCase
from core.tests.abstract.test_unit_model_history_api_v2 import PrimaryModelHistoryAPI
from access.models.team_history import Team, TeamHistory
from access.models.team_history import Team, TeamAuditHistory
@ -14,7 +14,7 @@ class ModelHistoryAPI(
audit_model = Team
model = TeamHistory
model = TeamAuditHistory
@classmethod
def setUpTestData(self):

View File

@ -13,7 +13,7 @@ from drf_spectacular.utils import (
from rest_framework.reverse import reverse
# THis import only exists so that the migrations can be created
from access.models.entity_history import EntityHistory # pylint: disable=W0611:unused-import
from access.models.entity_history import EntityAuditHistory # pylint: disable=W0611:unused-import
from access.models.entity import (
Entity,
)

View File

@ -1,7 +1,7 @@
from drf_spectacular.utils import extend_schema, extend_schema_view, OpenApiResponse
# THis import only exists so that the migrations can be created
from access.models.organization_history import OrganizationHistory # pylint: disable=W0611:unused-import
from access.models.organization_history import OrganizationAuditHistory # pylint: disable=W0611:unused-import
from access.serializers.organization import (
Tenant,
TenantModelSerializer,

View File

@ -1,7 +1,7 @@
from drf_spectacular.utils import extend_schema, extend_schema_view, OpenApiResponse
# THis import only exists so that the migrations can be created
from access.models.role_history import RoleHistory # pylint: disable=W0611:unused-import
from access.models.role_history import RoleAuditHistory # pylint: disable=W0611:unused-import
from access.serializers.role import (
Role,
ModelSerializer,

View File

@ -2,7 +2,7 @@ from drf_spectacular.utils import extend_schema, extend_schema_view, OpenApiPara
from access.models.tenant import Tenant as Organization
# THis import only exists so that the migrations can be created
from access.models.team_history import TeamHistory # pylint: disable=W0611:unused-import
from access.models.team_history import TeamAuditHistory # pylint: disable=W0611:unused-import
from access.serializers.teams import (
Team,
TeamModelSerializer,

View File

@ -6,8 +6,8 @@ from django.conf import settings
from django.contrib.auth.models import ContentType
from django.db import migrations, models
from access.models.organization_history import Tenant, OrganizationHistory
from access.models.team_history import Team, TeamHistory
from access.models.organization_history import Tenant, OrganizationAuditHistory
from access.models.team_history import Team, TeamAuditHistory
from assistance.models.knowledge_base_history import KnowledgeBase, KnowledgeBaseAuditHistory
from assistance.models.knowledge_base_category_history import KnowledgeBaseCategory, KnowledgeBaseCategoryAuditHistory
@ -336,7 +336,7 @@ def model_details(item_pk, item_class) -> dict:
model_class = Tenant
history_class = OrganizationHistory
history_class = OrganizationAuditHistory
case 'port':
@ -396,7 +396,7 @@ def model_details(item_pk, item_class) -> dict:
model_class = Team
history_class = TeamHistory
history_class = TeamAuditHistory
if(