From a054b75f0d51e7397b53338ff64f5a672517d1bd Mon Sep 17 00:00:00 2001 From: Joel Hanson Date: Wed, 16 Oct 2019 15:47:49 +0530 Subject: [PATCH] disabling tags which have no tutorials --- app/static/app/css/customCSS.css | 8 ++++++++ app/templates/tags.html | 19 +++++++++++++------ app/views.py | 5 ++++- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/static/app/css/customCSS.css b/app/static/app/css/customCSS.css index 0dfb137..c882a1e 100644 --- a/app/static/app/css/customCSS.css +++ b/app/static/app/css/customCSS.css @@ -31,3 +31,11 @@ summary.title { summary.title + .table-container { clear: both; } + +.disabled-grey { + background-color: #cccccc; +} + +.disabled-grey a { + cursor: default; +} \ No newline at end of file diff --git a/app/templates/tags.html b/app/templates/tags.html index 142bba2..72ed8a5 100644 --- a/app/templates/tags.html +++ b/app/templates/tags.html @@ -4,12 +4,19 @@

Tags

- {% if tags %} - {% for tag in tags %} - - 📌 {{ tag.name }} -   - {% endfor %} + {% if active_tags %} + {% for tag in active_tags %} + + 📌 {{ tag.name }} +   + {% endfor %} + {% endif %} + {% if inactive_tags %} + {% for tag in inactive_tags %} + + 📌 {{ tag.name }} +   + {% endfor %} {% endif %}
diff --git a/app/views.py b/app/views.py index 485fa15..71a756d 100644 --- a/app/views.py +++ b/app/views.py @@ -75,8 +75,11 @@ def latest(request): def tags(request): """view for the tags""" tags = Tag.objects.all() + active_tags = tags.filter(tutorial__in=Tutorial.objects.filter(publish=True)).distinct() + inactive_tags = tags.exclude(id__in=active_tags.values_list('id', flat=True)) context = { - 'tags': tags, + 'active_tags': active_tags, + 'inactive_tags': inactive_tags, 'title': 'Tags' } return render(request, 'tags.html', context)