diff --git a/idhub/admin/views.py b/idhub/admin/views.py index 1d1497b..0f0b8e0 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -3,6 +3,7 @@ import logging from django.utils.translation import gettext_lazy as _ from django.views.generic.base import TemplateView from django.contrib.auth.models import User +from django.shortcuts import get_object_or_404 from django.urls import reverse_lazy from django.contrib import messages from idhub.mixins import AdminView @@ -40,7 +41,7 @@ class ImportExport(AdminView, TemplateView): section = "ImportExport" -class AdminPeopleView(People): +class AdminPeopleListView(People): template_name = "idhub/admin_people.html" subtitle = _('People list') icon = 'bi bi-person' @@ -52,6 +53,26 @@ class AdminPeopleView(People): }) return context + +class AdminPeopleView(People): + template_name = "idhub/admin_user.html" + subtitle = _('User Profile') + icon = 'bi bi-person' + model = User + + def get(self, request, *args, **kwargs): + self.pk = kwargs['pk'] + self.object = get_object_or_404(self.model, pk=self.pk) + return super().get(request, *args, **kwargs) + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context.update({ + 'object': self.object, + }) + return context + + class AdminPeopleRegisterView(People): template_name = "idhub/admin_people_register.html" subtitle = _('People Register') diff --git a/idhub/mixins.py b/idhub/mixins.py index 51d0378..c888327 100644 --- a/idhub/mixins.py +++ b/idhub/mixins.py @@ -25,9 +25,9 @@ class UserView(LoginRequiredMixin): class AdminView(UserView): - def get(self, request): + def get(self, request, *args, **kwargs): if not request.user.is_superuser: url = reverse_lazy('idhub:user_dashboard') return redirect(url) - return super().get(request) + return super().get(request, *args, **kwargs) diff --git a/idhub/templates/idhub/admin_people.html b/idhub/templates/idhub/admin_people.html index 9c6327a..947e0bc 100644 --- a/idhub/templates/idhub/admin_people.html +++ b/idhub/templates/idhub/admin_people.html @@ -22,7 +22,7 @@ {{ user.username }} {{ user.get_membership }} {{ user.get_role }} - {% trans 'View' %} + {% trans 'View' %} {% endfor %} diff --git a/idhub/templates/idhub/base_admin.html b/idhub/templates/idhub/base_admin.html index ecb9fb6..aa691f9 100644 --- a/idhub/templates/idhub/base_admin.html +++ b/idhub/templates/idhub/base_admin.html @@ -77,7 +77,7 @@