Display all timers to any user with view_timer access.

This commit is contained in:
Christopher Charbonneau Wells 2017-09-09 11:57:58 -04:00
parent 1ae44c408f
commit 4def741d37
3 changed files with 10 additions and 5 deletions

View File

@ -11,12 +11,15 @@
<span class="timer-minutes">{{ object.current_duration|minutes }}</span>m <span class="timer-minutes">{{ object.current_duration|minutes }}</span>m
<span class="timer-seconds">{{ object.current_duration|seconds }}</span>s <span class="timer-seconds">{{ object.current_duration|seconds }}</span>s
</h1> </h1>
<p class="lead text-muted"> <p class="lead text-secondary">
Started {{ object.start }} Started {{ object.start }}
{% if not object.active %} {% if not object.active %}
/ Stopped {{ object.end }} / Stopped {{ object.end }}
{% endif %} {% endif %}
</p> </p>
<p class="text-muted">
Created by {{ object.user }}
</p>
{% if perms.core.add_feeding %} {% if perms.core.add_feeding %}
<a class="btn btn-success btn-lg btn-block p-3 mb-3" <a class="btn btn-success btn-lg btn-block p-3 mb-3"

View File

@ -19,10 +19,12 @@
<i class="fa fa-list" aria-hidden="true"></i> View Timers <i class="fa fa-list" aria-hidden="true"></i> View Timers
</a> </a>
{% endif %} {% endif %}
{% for timer in timers %}
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<h6 class="dropdown-header">Active Timers</h6> <h6 class="dropdown-header">Active Timers</h6>
<a class="dropdown-item" href="{% url 'timer-detail' timer.id %}">{{ timer }}</a> {% for timer in timers %}
<a class="dropdown-item" href="{% url 'timer-detail' timer.id %}">{{ timer }} ({{ timer.user }})</a>
{% empty %}
None
{% endfor %} {% endfor %}
</div> </div>
</li> </li>

View File

@ -12,7 +12,7 @@ register = template.Library()
@register.inclusion_tag('core/timer_nav.html', takes_context=True) @register.inclusion_tag('core/timer_nav.html', takes_context=True)
def timer_nav(context, active=True): def timer_nav(context, active=True):
request = context['request'] or None request = context['request'] or None
timers = Timer.objects.filter(user=request.user, active=active) timers = Timer.objects.filter(active=active)
perms = context['perms'] or None perms = context['perms'] or None
# The 'next' parameter is currently not used. # The 'next' parameter is currently not used.
return {'timers': timers, 'perms': perms, 'next': request.path} return {'timers': timers, 'perms': perms, 'next': request.path}