refactor(access): Update Entity model ViewSet attribute model_kwarg to model_name

ref: #847 #840 #841 #842 #843 #845
This commit is contained in:
2025-06-21 14:22:59 +09:30
parent 2eb0ba674e
commit 1ba7661f07
14 changed files with 28 additions and 28 deletions

View File

@ -53,11 +53,11 @@ class CompanyMetadataInheritedCases(
}
# self.url_kwargs = {
# 'entity_model': self.model._meta.sub_model_type
# 'model_name': self.model._meta.sub_model_type
# }
# self.url_view_kwargs = {
# 'entity_model': self.model._meta.sub_model_type
# 'model_name': self.model._meta.sub_model_type
# }
super().setUpTestData()

View File

@ -41,11 +41,11 @@ class ContactPermissionsAPIInheritedCases(
# def inherited_var_setup(self, request):
# request.cls.url_kwargs.update({
# 'entity_model': self.model._meta.sub_model_type
# 'model_name': self.model._meta.sub_model_type
# })
# request.cls.url_view_kwargs.update({
# 'entity_model': self.model._meta.sub_model_type
# 'model_name': self.model._meta.sub_model_type
# })

View File

@ -240,11 +240,11 @@ class EntityMetadataInheritedCases(
}
self.url_kwargs = {
'entity_model': self.model._meta.sub_model_type
'model_name': self.model._meta.sub_model_type
}
self.url_view_kwargs = {
'entity_model': self.model._meta.sub_model_type
'model_name': self.model._meta.sub_model_type
}
super().setUpTestData()

View File

@ -60,11 +60,11 @@ class EntityPermissionsAPIInheritedCases(
def inherited_var_setup(self, request):
request.cls.url_kwargs.update({
'entity_model': self.model._meta.sub_model_type
'model_name': self.model._meta.sub_model_type
})
request.cls.url_view_kwargs.update({
'entity_model': self.model._meta.sub_model_type
'model_name': self.model._meta.sub_model_type
})

View File

@ -247,11 +247,11 @@ class EntityViewSetInheritedCases(
}
self.url_kwargs = {
'entity_model': self.model._meta.sub_model_type
'model_name': self.model._meta.sub_model_type
}
self.url_view_kwargs = {
'entity_model': self.model._meta.sub_model_type
'model_name': self.model._meta.sub_model_type
}
super().setUpTestData()

View File

@ -64,11 +64,11 @@ class PersonMetadataInheritedCases(
}
# self.url_kwargs = {
# 'entity_model': self.model._meta.sub_model_type
# 'model_name': self.model._meta.sub_model_type
# }
# self.url_view_kwargs = {
# 'entity_model': self.model._meta.sub_model_type
# 'model_name': self.model._meta.sub_model_type
# }
super().setUpTestData()

View File

@ -62,11 +62,11 @@ class PersonPermissionsAPIInheritedCases(
# def inherited_var_setup(self, request):
# request.cls.url_kwargs.update({
# 'entity_model': self.model._meta.sub_model_type
# 'model_name': self.model._meta.sub_model_type
# })
# request.cls.url_view_kwargs.update({
# 'entity_model': self.model._meta.sub_model_type
# 'model_name': self.model._meta.sub_model_type
# })

View File

@ -24,7 +24,7 @@ class EntityAPITestCases(
if model != self.base_model:
request.cls.url_view_kwargs.update({
'entity_model': model._meta.sub_model_type,
'model_name': model._meta.sub_model_type,
})

View File

@ -66,7 +66,7 @@ class EntityViewsetInheritedCases(
def setUpTestData(self):
self.kwargs = {
'entity_model': self.model._meta.model_name
'model_name': self.model._meta.model_name
}
super().setUpTestData()

View File

@ -56,7 +56,7 @@ class APITestCases(
# if self.model._meta.model_name != 'entity':
# self.url_view_kwargs.update({
# 'entity_model': self.item.entity_type,
# 'model_name': self.item.entity_type,
# })

View File

@ -34,12 +34,12 @@ router = DefaultRouter(trailing_slash=False)
router.register('', access_v2.Index, basename = '_api_v2_access_home')
router.register(
prefix = '(?P<entity_model>[company]+)', viewset = entity.ViewSet,
prefix = '(?P<model_name>[company]+)', viewset = entity.ViewSet,
feature_flag = '2025-00008',basename = '_api_v2_company'
)
router.register(
prefix=f'entity/(?P<entity_model>[{entity_type_names}]+)?', viewset = entity.ViewSet,
prefix=f'entity/(?P<model_name>[{entity_type_names}]+)?', viewset = entity.ViewSet,
feature_flag = '2025-00002', basename = '_api_entity_sub'
)

View File

@ -65,7 +65,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
description='.',
parameters = [
OpenApiParameter(
name = 'entity_model',
name = 'model_name',
description = 'Enter the entity type. This is the name of the Entity sub-model.',
location = OpenApiParameter.PATH,
type = str,
@ -106,7 +106,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
description = '.',
parameters =[
OpenApiParameter(
name = 'entity_model',
name = 'model_name',
description = 'Enter the entity type. This is the name of the Entity sub-model.',
location = OpenApiParameter.PATH,
type = str,
@ -130,7 +130,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
description='.',
parameters = [
OpenApiParameter(
name = 'entity_model',
name = 'model_name',
description = 'Enter the entity type. This is the name of the Entity sub-model.',
location = OpenApiParameter.PATH,
type = str,
@ -162,7 +162,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
description='.',
parameters = [
OpenApiParameter(
name = 'entity_model',
name = 'model_name',
description = 'Enter the entity type. This is the name of the Entity sub-model.',
location = OpenApiParameter.PATH,
type = str,
@ -195,7 +195,7 @@ def spectacular_request_serializers( serializer_type = 'Model'):
description = '.',
parameters = [
OpenApiParameter(
name = 'entity_model',
name = 'model_name',
description = 'Enter the entity type. This is the name of the Entity sub-model.',
location = OpenApiParameter.PATH,
type = str,
@ -233,7 +233,7 @@ class ViewSet(
'organization',
]
model_kwarg = 'entity_model'
model_kwarg = 'model_name'
search_fields = [
'model_notes',
@ -254,7 +254,7 @@ class ViewSet(
viewname = '_api_entity_sub-list',
request = self.request,
kwargs = {
'entity_model': self.kwargs[self.model_kwarg],
'model_name': self.kwargs[self.model_kwarg],
}
)

View File

@ -30,7 +30,7 @@ class Index(IndexViewset):
if self.request.feature_flag['2025-00002']:
response.update({
"directory": reverse( 'v2:_api_entity_sub-list', request=request, kwargs = { 'entity_model': 'contact' } ),
"directory": reverse( 'v2:_api_entity_sub-list', request=request, kwargs = { 'model_name': 'contact' } ),
"entities": reverse( 'v2:_api_entity-list', request=request ),
})

View File

@ -24,7 +24,7 @@ class Index(IndexViewset):
def list(self, request, pk=None):
response = {
"employee": reverse( 'v2:_api_entity_sub-list', request=request, kwargs = { 'entity_model': 'employee' } ),
"employee": reverse( 'v2:_api_entity_sub-list', request=request, kwargs = { 'model_name': 'employee' } ),
}
return Response(response)