Skip to content

Commit

Permalink
add URL constants for accounts app
Browse files Browse the repository at this point in the history
  • Loading branch information
TareqMonwer committed Nov 2, 2024
1 parent c7a8ea4 commit a1e81b5
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 15 deletions.
24 changes: 24 additions & 0 deletions django_school_management/accounts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,27 @@ class ProfileApprovalStatusEnum(Enum):
pending = 'p'
request_declined = 'd'
approved = 'a'


class AccountURLEnums(Enum):
approval_with_modification = 'modify-and-approve/<int:pk>/'
dashboard = 'dashboard/'
groups = 'groups/'
permission_error = 'permission-error/'
profile_picture_upload = 'api/upload-profile-picture'
user_change = 'user/<int:pk>/change'
user_requests = 'user-requests/'
user_approval = 'approval/<int:pk>/<int:approved>'
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}'
58 changes: 43 additions & 15 deletions django_school_management/accounts/urls.py
Original file line number Diff line number Diff line change
@@ -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/<int:pk>/<int:approved>',
views.user_approval, name='user_approval'),
path('modify-and-approve/<int:pk>/',
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/<int:pk>/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
),
]

0 comments on commit a1e81b5

Please sign in to comment.