diff --git a/tom_common/templates/tom_common/partials/navbar_login.html b/tom_common/templates/tom_common/partials/navbar_login.html index 5e1bb22b..cf609e05 100644 --- a/tom_common/templates/tom_common/partials/navbar_login.html +++ b/tom_common/templates/tom_common/partials/navbar_login.html @@ -1,9 +1,9 @@ {% if user.is_authenticated %}
  • diff --git a/tom_common/urls.py b/tom_common/urls.py index 89be7440..04de96d9 100644 --- a/tom_common/urls.py +++ b/tom_common/urls.py @@ -26,7 +26,7 @@ from tom_base import __version__ from tom_common.api_views import GroupViewSet from tom_common.views import UserListView, UserPasswordChangeView, UserCreateView, UserDeleteView, UserUpdateView -from tom_common.views import CommentDeleteView, GroupCreateView, GroupUpdateView, GroupDeleteView, UserDetailView +from tom_common.views import CommentDeleteView, GroupCreateView, GroupUpdateView, GroupDeleteView, UserProfileView from tom_common.views import robots_txt from .api_router import collect_api_urls, SharedAPIRootRouter # DRF routers are setup in each INSTALL_APPS url.py @@ -49,7 +49,7 @@ path('users/create/', UserCreateView.as_view(), name='user-create'), path('users//delete/', UserDeleteView.as_view(), name='user-delete'), path('users//update/', UserUpdateView.as_view(), name='user-update'), - path('users//profile/', UserDetailView.as_view(), name='user-profile'), + path('users/profile/', UserProfileView.as_view(), name='user-profile'), path('groups/create/', GroupCreateView.as_view(), name='group-create'), path('groups//update/', GroupUpdateView.as_view(), name='group-update'), path('groups//delete/', GroupDeleteView.as_view(), name='group-delete'), diff --git a/tom_common/views.py b/tom_common/views.py index 72b69218..6fdb4460 100644 --- a/tom_common/views.py +++ b/tom_common/views.py @@ -82,22 +82,11 @@ def dispatch(self, *args, **kwargs): return super().dispatch(*args, **kwargs) -class UserDetailView(LoginRequiredMixin, DetailView): +class UserProfileView(LoginRequiredMixin, TemplateView): """ View to handle creating a user profile page. Requires a login. """ template_name = 'tom_common/user_profile.html' - model = User - - def dispatch(self, *args, **kwargs): - """ - Directs the class-based view to the correct method for the HTTP request method. Ensures that non-superusers - are not incorrectly updating the profiles of other users. - """ - if not self.request.user.is_superuser and self.request.user.id != self.kwargs['pk']: - return redirect('user-profile', self.request.user.id) - else: - return super().dispatch(*args, **kwargs) class UserPasswordChangeView(SuperuserRequiredMixin, FormView):