Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling tags which have no tutorials #57 #68

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/static/app/css/customCSS.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ summary.title {
summary.title + .table-container {
clear: both;
}

.disabled-grey {
background-color: #cccccc;
}

.disabled-grey a {
cursor: default;
}
19 changes: 13 additions & 6 deletions app/templates/tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
<div class="section">
<div class="container">
<h2 class="title is-1">Tags</h2>
{% if tags %}
{% for tag in tags %}
<span class="tag box" name="colorpad">
<a href="{% url 'app:tag-links' tag.name %}" class="title is-5">📌 {{ tag.name }}</a>
</span>&nbsp;
{% endfor %}
{% if active_tags %}
{% for tag in active_tags %}
<span class="tag box" name="colorpad">
<a href="{% url 'app:tag-links' tag.name %}" class="title is-5">📌 {{ tag.name }}</a>
</span>&nbsp;
{% endfor %}
{% endif %}
{% if inactive_tags %}
{% for tag in inactive_tags %}
<span class="tag box disabled-grey">
<a href="javascript:void(0);" class="title is-5">📌 {{ tag.name }}</a>
</span>&nbsp;
{% endfor %}
{% endif %}
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down