aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--app/dispatch/templates/dispatch/drivers/detail.html36
-rw-r--r--app/dispatch/templatetags/dynamic_key.py4
-rw-r--r--app/dispatch/views.py20
4 files changed, 57 insertions, 10 deletions
diff --git a/README.md b/README.md
index 3f8f518..fd35fff 100644
--- a/README.md
+++ b/README.md
@@ -3,14 +3,11 @@
Requirements going forward:
+ * Don't return to the home page when you edit a load from the driver summary page
* Show Recent Changes on Loads ( Django auditlog )
- * Sane Date format on Loads listing for each week
* /loads
* Add the description for each load to the individual load
- * Sane date format for each individual day block
- * Sane date format for the title
- * Sane title format
- * Make loads with 0 amount red
+ * Make loads with 0 amount red # done on driver summary
* Make loads without paperwork blue
* Make loads with paperwork green
* A way for users to be invited via email
diff --git a/app/dispatch/templates/dispatch/drivers/detail.html b/app/dispatch/templates/dispatch/drivers/detail.html
index 24afcc1..2c28064 100644
--- a/app/dispatch/templates/dispatch/drivers/detail.html
+++ b/app/dispatch/templates/dispatch/drivers/detail.html
@@ -11,6 +11,37 @@
</div>
<div class="row">
+ <div class="col s12">
+ <table>
+ <thead>
+ <tr>
+ <td>Number of Loads</td>
+ <td>Total Load cost</td>
+ <td>Average Load cost</td>
+ </tr>
+ </thead>
+ <tr>
+ <td>{{stats.count}}</td>
+ <td>{{stats.sum}}</td>
+ <td>{{stats.average|stringformat:".3f"}}</td>
+ </tr>
+ </table>
+ </div>
+</div>
+
+{% if stats.incomplete_loads > 0 %}
+<div class="row">
+ <div class="col s12">
+ <h4 class="center">
+ <span class="flow-text red black-text">
+ Note: One or more loads has a 0 amount that needs attention
+ </span>
+ </p>
+ </div>
+</div>
+{% endif %}
+
+<div class="row">
<div class="col s6 left-align">
<a href="{% url 'driver_detail' object.id %}?date={{week_dates.previous_week|date:"m/d/Y"}}" class="btn blue"><i class="material-icons left">arrow_back</i> Prev</a>
</div>
@@ -20,6 +51,7 @@
</div>
+
{% load dynamic_key %}
{% for date in loads %}
<div class="row">
@@ -37,7 +69,11 @@
{% for load in loads|keyvalue:date %}
<tr class="green lighten-4">
<td><a href="{% url 'company_detail' load.company.id %}">{{ load.company.name }}</a></td>
+ {% if load.amount == 0 %}
+ <td><span class="red-text">{{ load.amount }}</span></td>
+ {% else %}
<td>{{ load.amount }}</td>
+ {% endif %}
<td class="right-align">
<a href="{% url 'load_edit' load.id %}" class="btn orange">Edit</a>
<a href="{% url 'load_detail' load.id %}" class="btn blue">View</a>
diff --git a/app/dispatch/templatetags/dynamic_key.py b/app/dispatch/templatetags/dynamic_key.py
index 6a79707..fdd7f10 100644
--- a/app/dispatch/templatetags/dynamic_key.py
+++ b/app/dispatch/templatetags/dynamic_key.py
@@ -3,5 +3,5 @@ from django import template
register = template.Library()
@register.filter
-def keyvalue(dict, key):
- return dict[key] \ No newline at end of file
+def keyvalue(dictionary, key):
+ return dictionary.get(key)
diff --git a/app/dispatch/views.py b/app/dispatch/views.py
index ea03355..106d20b 100644
--- a/app/dispatch/views.py
+++ b/app/dispatch/views.py
@@ -103,11 +103,25 @@ class DriverDetail(LoadDateSort):
# Shit gets fucky with super() really fast, but this seems to work
context = super(DriverDetail, self).get_context_data(**kwargs)
+ stats = {};
+ stats['count'], stats['average'], stats['sum'] = (0,0,0)
+ stats['incomplete_loads'] = 0
+
loads_by_date = context['loads']
for d in loads_by_date:
- print(d)
- for l in d:
- print(l)
+ # Iterate over the array for the given date
+ for l in loads_by_date[d]:
+ stats['count'] += 1
+ stats['sum'] += l.amount
+ if l.amount == 0:
+ stats['incomplete_loads'] += 1
+
+ if stats['sum'] is not 0 and stats['count'] is not 0:
+ stats['average'] = stats['sum']/stats['count']
+
+
+ # Add our stats to the context so we can use it in the template
+ context['stats'] = stats
return context