diff --git a/subjects/templates/subjects/list.html b/subjects/templates/subjects/list.html index 8dc1d4f..53dbd63 100644 --- a/subjects/templates/subjects/list.html +++ b/subjects/templates/subjects/list.html @@ -55,7 +55,13 @@

- {{ category.name }} ({{ category|subject_count:user }}) + {{ category.name }} + + {% if not all %} + ({{ category|subject_count:user }}) + {% else %} + ({{ category.subject_category.count }}) + {% endif %}

@@ -114,7 +120,13 @@

- {{category.name}} ({{ category|subject_count:user }}) + {{category.name}} + + {% if not all %} + ({{ category|subject_count:user }}) + {% else %} + ({{ category.subject_category.count }}) + {% endif %}

diff --git a/subjects/utils.py b/subjects/utils.py index 4a984b3..c2532c8 100644 --- a/subjects/utils.py +++ b/subjects/utils.py @@ -2,14 +2,14 @@ def has_student_profile(user, category): for subject in category.subject_category.all(): - if user in subject.students.all(): + if user in subject.students.all() and subject.visible: return True return False def has_professor_profile(user, category): for subject in category.subject_category.all(): - if user in subject.professor.all(): + if user in subject.professor.all() and subject.visible: return True return False diff --git a/subjects/views.py b/subjects/views.py index 619ddd6..1d9773f 100644 --- a/subjects/views.py +++ b/subjects/views.py @@ -72,6 +72,7 @@ class IndexView(LoginRequiredMixin, ListView): def get_queryset(self): categories = Category.objects.all().order_by('name') + categories = [category for category in categories if self.request.user.is_staff or self.request.user in category.coordinators.all() or category.visible] self.totals['all_subjects'] = count_subjects(categories, self.request.user) self.totals['my_subjects'] = self.totals['all_subjects'] -- libgit2 0.21.2