Commit b0b22052bb2f32d200ccb13f94b12ea6057f676a
1 parent
71ad373d
Exists in
master
and in
3 other branches
modifying tag cloud, now it shows if the it a resource has that tag or any other subject
Showing
1 changed file
with
4 additions
and
3 deletions
Show diff stats
subjects/views.py
... | ... | @@ -62,9 +62,10 @@ class HomeView(LoginRequiredMixin, ListView): |
62 | 62 | tags = Tag.objects.all() |
63 | 63 | tags_list = [] |
64 | 64 | for tag in tags: |
65 | - if Resource.objects.filter(tags__pk=tag.pk, students__pk = self.request.user.pk).count() > 0 and len(tags_list) <= tag_amount: | |
66 | - tags_list.append((tag.name, Subject.objects.filter(tags__pk = tag.pk).count())) | |
67 | - tags_list.sort(key= lambda x: x[1], reverse=True) #sort by value | |
65 | + if len(tags_list) <= tag_amount: | |
66 | + if Resource.objects.filter(tags__pk=tag.pk, students__pk = self.request.user.pk).count() > 0 or Subject.objects.filter(tags__pk = tag.pk).count() > 0: | |
67 | + tags_list.append((tag.name, Subject.objects.filter(tags__pk = tag.pk).count())) | |
68 | + tags_list.sort(key= lambda x: x[1], reverse=True) #sort by value | |
68 | 69 | |
69 | 70 | elif len(tags_list) > tag_amount: |
70 | 71 | count = Subject.objects.filter(tags__pk = tag.pk).count() | ... | ... |