From f3490fa54fd89f56303ad257f1cc3c4f39f2f469 Mon Sep 17 00:00:00 2001 From: Mendo6472 Date: Sun, 12 May 2024 14:34:21 -0500 Subject: [PATCH] REF:BUILD: User list center container now displays real ammount of users --- .../components/user_list_center_container.html | 6 +++--- .../control_board/administrator_user_list_view.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hiring_module/hiring_app/templates/admin_user/components/user_list_center_container.html b/hiring_module/hiring_app/templates/admin_user/components/user_list_center_container.html index 275d54e..5c2ed80 100644 --- a/hiring_module/hiring_app/templates/admin_user/components/user_list_center_container.html +++ b/hiring_module/hiring_app/templates/admin_user/components/user_list_center_container.html @@ -1,5 +1,5 @@
- {% include 'admin_user/components/user_element_container.html' with count=1 status='Administradores' %} - {% include 'admin_user/components/user_element_container.html' with count=2 status='Lideres' %} - {% include 'admin_user/components/user_element_container.html' with count=2 status='Gestores' %} + {% include 'admin_user/components/user_element_container.html' with count=admins_ammount status='Administradores' %} + {% include 'admin_user/components/user_element_container.html' with count=leaders_ammount status='Lideres' %} + {% include 'admin_user/components/user_element_container.html' with count=managers_ammount status='Gestores' %}
diff --git a/hiring_module/hiring_app/views/control_board/administrator_user_list_view.py b/hiring_module/hiring_app/views/control_board/administrator_user_list_view.py index 6511824..d34c283 100644 --- a/hiring_module/hiring_app/views/control_board/administrator_user_list_view.py +++ b/hiring_module/hiring_app/views/control_board/administrator_user_list_view.py @@ -21,11 +21,23 @@ def dispatch(self, *args, **kwargs): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) users = CustomUser.objects.filter(groups__name__in=['admin', 'leader', 'manager']) + admins_ammount = 0 + leaders_ammount = 0 + managers_ammount = 0 # Add a role field to each user object for user in users: user.role = str(user.groups.first()) + if user.role == 'admin': + admins_ammount += 1 + elif user.role == 'leader': + leaders_ammount += 1 + elif user.role == 'manager': + managers_ammount += 1 context['users'] = users context['actualgroup'] = 'admin' + context['admins_ammount'] = admins_ammount + context['leaders_ammount'] = leaders_ammount + context['managers_ammount'] = managers_ammount return context def post(self, request, *args, **kwargs):