Add display of subscriptions in taskDetail for the current user

This commit is contained in:
Adam Goldsmith 2021-05-20 20:12:52 -04:00
parent 71074e6f1b
commit d2ff139c51
3 changed files with 35 additions and 0 deletions

View File

@ -7,6 +7,38 @@
{% block admin_link %}{% url 'admin:tasks_task_change' task.id %}{% endblock %}
{% block nav_extra %}
{% if user.is_authenticated %}
{% if task_subs or tool_subs %}
<span class="nav-item dropdown">
<button class="btn nav-link dropdown-toggle"
data-bs-toggle="dropdown"
aria-expanded="false">
🔔
</button>
<ul class="dropdown-menu">
<li><h6 class="dropdown-header">Group Task Subscriptions</h6></li>
{% for task_sub in task_subs %}
<li class="dropdown-item disabled text-reset">
{{ task_sub.group }} - {{ task_sub.days_before }} days
</li>
{% endfor %}
<li><hr class="dropdown-divider"></li>
<li><h6 class="dropdown-header">Group Tool Subscriptions</h6></li>
{% for tool_sub in tool_subs %}
<li class="dropdown-item disabled text-reset">
{{ tool_sub.tool }} - {{ tool_sub.group }} - {{ tool_sub.days_before }} days
</li>
{% endfor %}
</ul>
</span>
{% else %}
<span class="navbar-text">🔕</span>
{% endif %}
{% endif %}
{% endblock %}
{% block content %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">

View File

@ -43,6 +43,8 @@ def taskDetail(request, tool_slug, task_slug):
context = {
'tool': tool,
'task': task,
'task_subs': task.grouptasksubscription_set.filter(group__user=request.user),
'tool_subs': tool.grouptoolsubscription_set.filter(group__user=request.user),
'events': events,
'form': form,
}

View File

@ -19,6 +19,7 @@
</button>
<div id="user-nav" class="collapse navbar-collapse justify-content-end">
<div class="navbar-nav">
{% block nav_extra %}{% endblock %}
{% if user.is_staff %}
<a class="nav-item nav-link" href="{% block admin_link %}/admin{% endblock %}"> Admin </a>
{% endif %}