Commit 152fb646db3d15cc615f5a0cde5b36f6dc6654a5
1 parent
297f7d86
Exists in
master
and in
3 other branches
Adding subjects total number to home
Showing
2 changed files
with
7 additions
and
3 deletions
Show diff stats
subjects/templates/subjects/initial.html
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | </div> | 26 | </div> |
27 | 27 | ||
28 | <div class="col-md-12 cards-content"> | 28 | <div class="col-md-12 cards-content"> |
29 | - <h2 class=" my-subjects-title"><b><i>{% trans "Meus Assuntos" %}</i></b></h2> | 29 | + <h2 class=" my-subjects-title"><b><i>{% trans "Meus Assuntos" %} ({{ total_subs }})</i></b></h2> |
30 | 30 | ||
31 | {% if subjects|length > 0 %} | 31 | {% if subjects|length > 0 %} |
32 | <div class="panel-group" id="subject-accordion" role="tablist" aria-multiselectable="true"> | 32 | <div class="panel-group" id="subject-accordion" role="tablist" aria-multiselectable="true"> |
subjects/views.py
@@ -35,7 +35,8 @@ class HomeView(LoginRequiredMixin, ListView): | @@ -35,7 +35,8 @@ class HomeView(LoginRequiredMixin, ListView): | ||
35 | redirect_field_name = 'next' | 35 | redirect_field_name = 'next' |
36 | template_name = 'subjects/initial.html' | 36 | template_name = 'subjects/initial.html' |
37 | context_object_name = 'subjects' | 37 | context_object_name = 'subjects' |
38 | - paginate_by = 10 | 38 | + paginate_by = 10 |
39 | + total = 0 | ||
39 | 40 | ||
40 | def get_queryset(self): | 41 | def get_queryset(self): |
41 | if self.request.user.is_staff: | 42 | if self.request.user.is_staff: |
@@ -44,7 +45,9 @@ class HomeView(LoginRequiredMixin, ListView): | @@ -44,7 +45,9 @@ class HomeView(LoginRequiredMixin, ListView): | ||
44 | pk = self.request.user.pk | 45 | pk = self.request.user.pk |
45 | 46 | ||
46 | subjects = Subject.objects.filter(Q(students__pk=pk) | Q(professor__pk=pk) | Q(category__coordinators__pk=pk)).distinct() | 47 | subjects = Subject.objects.filter(Q(students__pk=pk) | Q(professor__pk=pk) | Q(category__coordinators__pk=pk)).distinct() |
47 | - | 48 | + |
49 | + self.total = len(subjects) | ||
50 | + | ||
48 | return subjects | 51 | return subjects |
49 | 52 | ||
50 | def get_context_data(self, **kwargs): | 53 | def get_context_data(self, **kwargs): |
@@ -55,6 +58,7 @@ class HomeView(LoginRequiredMixin, ListView): | @@ -55,6 +58,7 @@ class HomeView(LoginRequiredMixin, ListView): | ||
55 | #bringing users | 58 | #bringing users |
56 | tags = Tag.objects.all() | 59 | tags = Tag.objects.all() |
57 | context['tags'] = tags | 60 | context['tags'] = tags |
61 | + context['total_subs'] = self.total | ||
58 | 62 | ||
59 | return context | 63 | return context |
60 | 64 |