Skip to content

Commit

Permalink
Merge pull request #163 from nelc/shadinaif/fix-urls
Browse files Browse the repository at this point in the history
fix: duplication in URL routes
  • Loading branch information
shadinaif authored Dec 9, 2024
2 parents a79d723 + e249a6c commit d4538ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion futurex_openedx_extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""One-line description for README and other doc files."""

__version__ = '0.9.16'
__version__ = '0.9.17'
11 changes: 6 additions & 5 deletions futurex_openedx_extensions/dashboard/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

QUERY_ALLOWED_SCOPES = '|'.join(ClickhouseQuery.allowed_scopes())

router = DefaultRouter()
router.register(r'user_roles', views.UserRolesManagementView, basename='user-roles')
router.register(r'tasks', views.DataExportManagementView, basename='data-export-tasks')
roles_router = DefaultRouter()
roles_router.register(r'user_roles', views.UserRolesManagementView, basename='user-roles')
export_router = DefaultRouter()
export_router.register(r'tasks', views.DataExportManagementView, basename='data-export-tasks')

urlpatterns = [
re_path(r'^api/fx/accessible/v1/info/$', views.AccessibleTenantsInfoView.as_view(), name='accessible-info'),
Expand All @@ -38,8 +39,8 @@
name='learner-courses'
),
re_path(r'^api/fx/roles/v1/my_roles/$', views.MyRolesView.as_view(), name='my-roles'),
re_path(r'^api/fx/roles/v1/', include(router.urls)),
re_path(r'^api/fx/export/v1/', include(router.urls)),
re_path(r'^api/fx/roles/v1/', include(roles_router.urls)),
re_path(r'^api/fx/export/v1/', include(export_router.urls)),
re_path(r'^api/fx/statistics/v1/course_statuses/$', views.CourseStatusesView.as_view(), name='course-statuses'),
re_path(r'^api/fx/statistics/v1/rating/$', views.GlobalRatingView.as_view(), name='statistics-rating'),
re_path(r'^api/fx/statistics/v1/total_counts/$', views.TotalCountsView.as_view(), name='total-counts'),
Expand Down
15 changes: 7 additions & 8 deletions tests/test_dashboard/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ def setUp(self):
self.view_name = self.VIEW_NAME
self.url_args = []
self.staff_user = 2
self.registry = {}
for _, viewset, basename in urls.router.registry:
self.registry[basename] = viewset
self.viewset_base = None

@property
def url(self):
Expand Down Expand Up @@ -466,17 +462,20 @@ class TestDataExportTasksView(BaseTestViewMixin):

def set_action(self, action, task_id=1):
"""Set the viewname and client method"""
self.viewset_base = 'data-export-tasks'
self.view_name = f'fx_dashboard:{self.viewset_base}-{action}'
self.view_name = f'fx_dashboard:data-export-tasks-{action}'
self.url_args = []
if action == 'detail':
self.url_args = [task_id]

def test_permission_classes(self):
"""Verify that the view has the correct permission classes"""
registry = {}
for _, viewset, basename in urls.export_router.registry:
registry[basename] = viewset

for action in self.view_actions:
self.set_action(action)
view_class = self.registry['data-export-tasks']
view_class = registry['data-export-tasks']
self.assertEqual(view_class.permission_classes, [FXHasTenantCourseAccess])

def test_unauthorized(self):
Expand Down Expand Up @@ -1018,7 +1017,7 @@ def test_permission_classes(self, action):
self.set_action(action)

registry = {}
for _, viewset, basename in urls.router.registry:
for _, viewset, basename in urls.roles_router.registry:
registry[basename] = viewset
view_class = registry['user-roles']
self.assertEqual(view_class.permission_classes, [FXHasTenantAllCoursesAccess])
Expand Down

0 comments on commit d4538ad

Please sign in to comment.