Add basic template tag for timers.

This commit is contained in:
Christopher Charbonneau Wells 2017-08-16 18:53:53 -04:00
parent 6b2de93736
commit 463dd0c1d7
4 changed files with 24 additions and 1 deletions

View File

@ -1,4 +1,5 @@
{% load static %} {% load static %}
{% load timers %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
@ -56,9 +57,13 @@
<div id="view-{{ request.resolver_match.view_name }}" class="container-fluid"> <div id="view-{{ request.resolver_match.view_name }}" class="container-fluid">
<div class="row justify-content-md-center"> <div class="row justify-content-md-center">
<div class="col-lg-8"> <div class="col-lg-8 mb-4">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
<div class="col-lg-2">
<h1>Timers</h1>
{% list_timers %}
</div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,3 @@
{% for timer in timers %}
{{ timer.name }} ({{ timer.duration }})
{% endfor %}

View File

View File

@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django import template
from core.models import Timer
register = template.Library()
@register.inclusion_tag('timer_list.html')
def list_timers(active=True):
timers = Timer.objects.filter(active=active)
return {'timers': timers}