Skip to content

Commit

Permalink
Merge pull request #101 from ICESI-PI1-2024A-G1/user-list-information
Browse files Browse the repository at this point in the history
User list center container now displays real ammount of users
  • Loading branch information
Mendo6472 authored May 12, 2024
2 parents 83b5286 + f3490fa commit 00dfd84
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="row justify-content-center">
{% 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' %}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 00dfd84

Please sign in to comment.