From a1e81b525c768ab2142ce00d8f06b38a6e4b14a3 Mon Sep 17 00:00:00 2001 From: TareqMonwer Date: Sat, 2 Nov 2024 23:02:47 +0600 Subject: [PATCH] add URL constants for accounts app --- .../accounts/constants.py | 24 ++++++++ django_school_management/accounts/urls.py | 58 ++++++++++++++----- 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/django_school_management/accounts/constants.py b/django_school_management/accounts/constants.py index 03a1eec..c4673a8 100644 --- a/django_school_management/accounts/constants.py +++ b/django_school_management/accounts/constants.py @@ -6,3 +6,27 @@ class ProfileApprovalStatusEnum(Enum): pending = 'p' request_declined = 'd' approved = 'a' + + +class AccountURLEnums(Enum): + approval_with_modification = 'modify-and-approve//' + dashboard = 'dashboard/' + groups = 'groups/' + permission_error = 'permission-error/' + profile_picture_upload = 'api/upload-profile-picture' + user_change = 'user//change' + user_requests = 'user-requests/' + user_approval = 'approval//' + profile_complete = '' + + +class AccountURLConstants: + approval_with_modification = f'account:{AccountURLEnums.approval_with_modification.name}' + dashboard = f'account:{AccountURLEnums.dashboard.name}' + groups = f'account:{AccountURLEnums.groups.name}' + permission_error = f'account:{AccountURLEnums.permission_error.name}' + profile_picture_upload = f'account:{AccountURLEnums.profile_picture_upload.name}' + user_change = f'account:{AccountURLEnums.user_change.name}' + user_requests = f'account:{AccountURLEnums.user_requests.name}' + user_approval = f'account:{AccountURLEnums.user_approval.name}' + profile_complete = f'account:{AccountURLEnums.profile_complete.name}' diff --git a/django_school_management/accounts/urls.py b/django_school_management/accounts/urls.py index 4fb9236..4b8212e 100644 --- a/django_school_management/accounts/urls.py +++ b/django_school_management/accounts/urls.py @@ -1,27 +1,55 @@ from permission_handlers.basic import permission_error from django.urls import path, include from . import views - +from .constants import AccountURLEnums app_name = 'account' urlpatterns = [ - path('', views.profile_complete, name='profile_complete'), + path( + AccountURLEnums.profile_complete.value, + views.profile_complete, + name=AccountURLEnums.profile_complete.name + ), path('auth/', include('django.contrib.auth.urls')), - # register path is archived since we're using allauth' - # path('register/', views.register, name='register'), - path('dashboard/', views.dashboard, name='dashboard'), - path('groups/', views.GroupListView.as_view(), name='groups'), - path('user-requests/', views.user_requests_list, name='user_requests'), - path('permission-error/', permission_error, name='permission_error'), - path('approval//', - views.user_approval, name='user_approval'), - path('modify-and-approve//', + path( + AccountURLEnums.dashboard.value, + views.dashboard, + name=AccountURLEnums.dashboard.name + ), + path( + AccountURLEnums.groups.value, + views.GroupListView.as_view(), + name=AccountURLEnums.groups.name + ), + path( + AccountURLEnums.user_requests.value, + views.user_requests_list, + name=AccountURLEnums.user_requests.name + ), + path( + AccountURLEnums.permission_error.value, + permission_error, + name=AccountURLEnums.permission_error.name + ), + path( + AccountURLEnums.approval_with_modification.value, + views.user_approval, + name=AccountURLEnums.approval_with_modification.name + ), + path( + AccountURLEnums.approval_with_modification.value, views.user_approval_with_modification, - name='approval_with_modification' + name=AccountURLEnums.approval_with_modification.name + ), + path( + AccountURLEnums.user_change.value, + views.UserUpdateView.as_view(), + name=AccountURLEnums.user_change.name ), - path('user//change', views.UserUpdateView.as_view(), name='user_change'), - path('api/upload-profile-picture', views.profile_picture_upload, - name='profile_picture_upload' + path( + AccountURLEnums.profile_complete.value, + views.profile_picture_upload, + name=AccountURLEnums.profile_complete.name ), ]