aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/dispatch/templates/dispatch/companies/list.html11
-rw-r--r--app/dispatch/templatetags/dynamic_key.py29
2 files changed, 32 insertions, 8 deletions
diff --git a/app/dispatch/templates/dispatch/companies/list.html b/app/dispatch/templates/dispatch/companies/list.html
index 97e54f7..2dc4f7c 100644
--- a/app/dispatch/templates/dispatch/companies/list.html
+++ b/app/dispatch/templates/dispatch/companies/list.html
@@ -3,6 +3,7 @@
{% block title %}Customers{% endblock %}
{% block content %}
+{% load dynamic_key %}
<div class="row">
<div class="col s12 m6">
<h1>Customers</h1>
@@ -18,18 +19,20 @@
<thead>
<tr>
<th>Name</th>
- <th>Address</th>
- <th>Phone</th>
<th>Email</th>
+ <th>Total Loads</th>
+ <th>Last Week</th>
+ <th>This Week</th>
</tr>
</thead>
<tbody>
{% for customer in object_list %}
<tr>
<td>{{ customer.name }}</td>
- <td>{{ customer.address }}</td>
- <td>{{ customer.phone_number }}</td>
<td>{{ customer.email_address }}</td>
+ <td>{{ customer|customer_loads }}</td>
+ <td>{{ customer|customer_loads_last_week }}</td>
+ <td>{{ customer|customer_loads_this_week }}</td>
<td class="right-align">
{% if user.is_superuser %}
<a href="{% url 'customer_edit' customer.id %}" class="btn orange">Edit</a>
diff --git a/app/dispatch/templatetags/dynamic_key.py b/app/dispatch/templatetags/dynamic_key.py
index ae23704..b3cd165 100644
--- a/app/dispatch/templatetags/dynamic_key.py
+++ b/app/dispatch/templatetags/dynamic_key.py
@@ -1,5 +1,7 @@
from django import template
+from dispatch.misc import get_week_dates, get_week_dates_datetime
+
register = template.Library()
@register.filter
@@ -7,10 +9,6 @@ def keyvalue(dictionary, key):
return dictionary.get(key)
@register.filter
-def customer_has_load_for_datetime(cu, dt):
- return cu.has_paperwork(dt)
-
-@register.filter
def getindex(my_list, index):
return my_list[index]
@@ -19,3 +17,26 @@ def endRange(number, start):
# +1 because 1 based index instead of 0
return range(start, number+1)
+
+# Customer Object stuff
+
+@register.filter
+def customer_has_load_for_datetime(cu, dt):
+ return cu.has_paperwork(dt)
+
+@register.filter
+def customer_loads(cu):
+ return len(cu.load_set.all())
+
+@register.filter
+def customer_loads_last_week(cu):
+ wk = get_week_dates()
+ wk = get_week_dates_datetime(wk['previous_week'])
+ return len(cu.load_set.filter(date__range=(wk['start_date'],
+ wk['end_date'])))
+
+@register.filter
+def customer_loads_this_week(cu):
+ wk = get_week_dates()
+ return len(cu.load_set.filter(date__range=(wk['start_date'],
+ wk['end_date'])))