Permalink
Browse files

Dressed up review page a little bit

  • Loading branch information...
1 parent f710509 commit d3bcf6ff1ba412edc4d8ba291ea9de274220bc43 @palewire palewire committed Aug 20, 2012
Showing with 29 additions and 7 deletions.
  1. +3 −2 archive/managers.py
  2. +9 −5 archive/templates/review.html
  3. +17 −0 toolbox/templatetags/misc_tags.py
View
@@ -1,4 +1,5 @@
from django.db import models
+from datetime import timedelta
from django.utils import timezone
from django.db.models import Count
@@ -36,8 +37,8 @@ def stats(self):
'sortable_name': l[2],
'slug': l[3],
'total_screenshots': l[4],
- 'first_screenshot': l[5],
- 'last_screenshot': l[6],
+ 'last_screenshot': timezone.localtime(l[6]),
+ 'tardy': (timezone.now() - timezone.localtime(l[6])) > timedelta(days=1),
})
return sorted(results, key=lambda x: x['sortable_name'])
@@ -1,4 +1,4 @@
-{% load i18n admin_static admin_modify humanize tz %}
+{% load i18n admin_static admin_modify humanize tz misc_tags %}
<html>
<body>
<style type="text/css">
@@ -9,25 +9,29 @@
{
border: 1px solid black;
padding: 5px;
+ margin: 5px;
+ line-height:140%;
text-align:left;
}
+ td.tardy {
+ background-color:red;
+ color:white;
+ }
</style>
<table>
<thead>
<tr>
<th>Site</th>
<th>Screenshots</th>
- <th>First</th>
- <th>Last</th>
+ <th>Last update</th>
</tr>
</thead>
<tbody>
{% for obj in site_list %}
<tr>
<td>{{ obj.name }}</td>
<td>{{ obj.total_screenshots|intcomma }}</td>
- <td>{{ obj.first_screenshot|localtime }}</td>
- <td>{{ obj.last_screenshot|localtime }}</td>
+ <td {% if obj.tardy %}class="tardy"{% endif %}>{{ obj.last_screenshot|timedelta }}</td>
</tr>
{% endfor %}
</tbody>
@@ -1,9 +1,26 @@
from django import template
+from django.utils import timezone
+from datetime import timedelta as td
+from django.utils.timesince import timesince
from django.utils.safestring import mark_safe, SafeData
from django.template.defaultfilters import stringfilter
register = template.Library()
+def timedelta(value, arg=None):
+ if not value:
+ return ''
+ if arg:
+ cmp = arg
+ else:
+ cmp = timezone.now()
+ if value > cmp:
+ return "in %s" % timesince(cmp,value)
+ else:
+ return "%s ago" % timesince(value,cmp)
+timedelta.is_safe = True
+register.filter(timedelta)
+
def datejs(dt):
"""
Reformats a datetime object as a JavaScript Date() object.

0 comments on commit d3bcf6f

Please sign in to comment.