refactor(access): move url routes from core.urls to own module urls_api.py
ref: #776 #777
This commit is contained in:
95
app/access/urls_api.py
Normal file
95
app/access/urls_api.py
Normal file
@ -0,0 +1,95 @@
|
||||
from django.apps import apps
|
||||
|
||||
from centurion_feature_flag.urls.routers import DefaultRouter
|
||||
|
||||
from access.viewsets import (
|
||||
entity,
|
||||
entity_notes,
|
||||
index as access_v2,
|
||||
organization as organization_v2,
|
||||
organization_notes,
|
||||
role,
|
||||
role_notes,
|
||||
team as team_v2,
|
||||
team_notes,
|
||||
team_user as team_user_v2
|
||||
)
|
||||
|
||||
entity_type_names = ''
|
||||
history_type_names = ''
|
||||
history_app_labels = ''
|
||||
ticket_type_names = ''
|
||||
ticket_comment_names = ''
|
||||
|
||||
for model in apps.get_models():
|
||||
|
||||
if issubclass(model, entity.Entity):
|
||||
|
||||
entity_type_names += model._meta.sub_model_type + '|'
|
||||
|
||||
|
||||
entity_type_names = str(entity_type_names)[:-1]
|
||||
|
||||
|
||||
# app_name = "access"
|
||||
|
||||
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,
|
||||
feature_flag = '2025-00008',basename = '_api_v2_company'
|
||||
)
|
||||
|
||||
router.register(
|
||||
prefix=f'entity/(?P<entity_model>[{entity_type_names}]+)?', viewset = entity.ViewSet,
|
||||
feature_flag = '2025-00002', basename = '_api_v2_entity_sub'
|
||||
)
|
||||
|
||||
router.register(
|
||||
prefix = 'entity', viewset = entity.NoDocsViewSet,
|
||||
feature_flag = '2025-00002', basename = '_api_v2_entity'
|
||||
)
|
||||
|
||||
router.register(
|
||||
prefix = 'access/entity/(?P<model_id>[0-9]+)/notes', viewset = entity_notes.ViewSet,
|
||||
feature_flag = '2025-00002', basename = '_api_v2_entity_note'
|
||||
)
|
||||
|
||||
router.register(
|
||||
prefix = 'tenant', viewset = organization_v2.ViewSet,
|
||||
basename = '_api_v2_organization'
|
||||
)
|
||||
|
||||
router.register(
|
||||
prefix = 'tenant/(?P<model_id>[0-9]+)/notes', viewset = organization_notes.ViewSet,
|
||||
basename = '_api_v2_organization_note'
|
||||
)
|
||||
|
||||
router.register(
|
||||
prefix = 'tenant/(?P<organization_id>[0-9]+)/team', viewset = team_v2.ViewSet,
|
||||
basename = '_api_v2_organization_team'
|
||||
)
|
||||
|
||||
router.register(
|
||||
prefix = 'tenant/(?P<organization_id>[0-9]+)/team/(?P<model_id>[0-9]+)/notes', viewset = team_notes.ViewSet,
|
||||
basename = '_api_v2_team_note'
|
||||
)
|
||||
|
||||
router.register(
|
||||
prefix = 'access/tenant/(?P<organization_id>[0-9]+)/team/(?P<team_id>[0-9]+)/user', viewset = team_user_v2.ViewSet,
|
||||
basename = '_api_v2_organization_team_user'
|
||||
)
|
||||
|
||||
router.register(
|
||||
prefix = 'role', viewset = role.ViewSet,
|
||||
feature_flag = '2025-00003', basename = '_api_v2_role'
|
||||
)
|
||||
|
||||
router.register(
|
||||
prefix = 'role/(?P<model_id>[0-9]+)/notes', viewset = role_notes.ViewSet,
|
||||
feature_flag = '2025-00003', basename = '_api_v2_role_note'
|
||||
)
|
||||
|
||||
urlpatterns = router.urls
|
@ -17,19 +17,6 @@ from centurion.viewsets.base import (
|
||||
user as user_v2
|
||||
)
|
||||
|
||||
from access.viewsets import (
|
||||
entity,
|
||||
entity_notes,
|
||||
index as access_v2,
|
||||
organization as organization_v2,
|
||||
organization_notes,
|
||||
role,
|
||||
role_notes,
|
||||
team as team_v2,
|
||||
team_notes,
|
||||
team_user as team_user_v2
|
||||
)
|
||||
|
||||
from assistance.viewsets import (
|
||||
index as assistance_index_v2,
|
||||
knowledge_base as knowledge_base_v2,
|
||||
@ -138,7 +125,6 @@ router = DefaultRouter(trailing_slash=False)
|
||||
|
||||
router.register('', v2.Index, basename='_api_v2_home')
|
||||
|
||||
entity_type_names = ''
|
||||
history_type_names = ''
|
||||
history_app_labels = ''
|
||||
ticket_type_names = ''
|
||||
@ -164,32 +150,7 @@ for model in apps.get_models():
|
||||
|
||||
ticket_comment_names += model._meta.sub_model_type + '|'
|
||||
|
||||
|
||||
if issubclass(model, entity.Entity):
|
||||
|
||||
entity_type_names += model._meta.sub_model_type + '|'
|
||||
|
||||
|
||||
|
||||
entity_type_names = str(entity_type_names)[:-1]
|
||||
|
||||
# pylint: disable=C0301:line-too-long
|
||||
router.register('access', access_v2.Index, basename='_api_v2_access_home')
|
||||
|
||||
router.register('access/(?P<entity_model>[company]+)', entity.ViewSet, feature_flag = '2025-00008', basename='_api_v2_company')
|
||||
|
||||
router.register(f'access/entity/(?P<entity_model>[{entity_type_names}]+)?', entity.ViewSet, feature_flag = '2025-00002', basename='_api_v2_entity_sub')
|
||||
router.register('access/entity', entity.NoDocsViewSet, feature_flag = '2025-00002', basename='_api_v2_entity')
|
||||
router.register('access/entity/(?P<model_id>[0-9]+)/notes', entity_notes.ViewSet, feature_flag = '2025-00002', basename='_api_v2_entity_note')
|
||||
|
||||
router.register('access/tenant', organization_v2.ViewSet, basename='_api_v2_organization')
|
||||
router.register('access/tenant/(?P<model_id>[0-9]+)/notes', organization_notes.ViewSet, basename='_api_v2_organization_note')
|
||||
router.register('access/tenant/(?P<organization_id>[0-9]+)/team', team_v2.ViewSet, basename='_api_v2_organization_team')
|
||||
router.register('access/tenant/(?P<organization_id>[0-9]+)/team/(?P<model_id>[0-9]+)/notes', team_notes.ViewSet, basename='_api_v2_team_note')
|
||||
router.register('access/tenant/(?P<organization_id>[0-9]+)/team/(?P<team_id>[0-9]+)/user', team_user_v2.ViewSet, basename='_api_v2_organization_team_user')
|
||||
|
||||
router.register('access/role', role.ViewSet, feature_flag = '2025-00003', basename='_api_v2_role')
|
||||
router.register('access/role/(?P<model_id>[0-9]+)/notes', role_notes.ViewSet, feature_flag = '2025-00003', basename='_api_v2_role_note')
|
||||
|
||||
router.register('assistance', assistance_index_v2.Index, basename='_api_v2_assistance_home')
|
||||
router.register('assistance/knowledge_base', knowledge_base_v2.ViewSet, basename='_api_v2_knowledge_base')
|
||||
@ -328,6 +289,7 @@ urlpatterns = [
|
||||
urlpatterns += router.urls
|
||||
|
||||
urlpatterns += [
|
||||
path("access/", include("access.urls_api")),
|
||||
path("accounting/", include("accounting.urls")),
|
||||
path("devops/", include("devops.urls")),
|
||||
path("hr/", include('human_resources.urls')),
|
||||
|
Reference in New Issue
Block a user