From 152fb646db3d15cc615f5a0cde5b36f6dc6654a5 Mon Sep 17 00:00:00 2001 From: Zambom Date: Thu, 19 Jan 2017 15:51:30 -0200 Subject: [PATCH] Adding subjects total number to home --- subjects/templates/subjects/initial.html | 2 +- subjects/views.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/subjects/templates/subjects/initial.html b/subjects/templates/subjects/initial.html index f9bb73b..246cace 100644 --- a/subjects/templates/subjects/initial.html +++ b/subjects/templates/subjects/initial.html @@ -26,7 +26,7 @@
-

{% trans "Meus Assuntos" %}

+

{% trans "Meus Assuntos" %} ({{ total_subs }})

{% if subjects|length > 0 %}
diff --git a/subjects/views.py b/subjects/views.py index 057d476..4bad55d 100644 --- a/subjects/views.py +++ b/subjects/views.py @@ -35,7 +35,8 @@ class HomeView(LoginRequiredMixin, ListView): redirect_field_name = 'next' template_name = 'subjects/initial.html' context_object_name = 'subjects' - paginate_by = 10 + paginate_by = 10 + total = 0 def get_queryset(self): if self.request.user.is_staff: @@ -44,7 +45,9 @@ class HomeView(LoginRequiredMixin, ListView): pk = self.request.user.pk subjects = Subject.objects.filter(Q(students__pk=pk) | Q(professor__pk=pk) | Q(category__coordinators__pk=pk)).distinct() - + + self.total = len(subjects) + return subjects def get_context_data(self, **kwargs): @@ -55,6 +58,7 @@ class HomeView(LoginRequiredMixin, ListView): #bringing users tags = Tag.objects.all() context['tags'] = tags + context['total_subs'] = self.total return context -- libgit2 0.21.2