Fix datelisting formatting and titles
authorMagnus Hagander <magnus@hagander.net>
Sat, 16 Jun 2012 10:09:01 +0000 (18:09 +0800)
committerMagnus Hagander <magnus@hagander.net>
Sat, 16 Jun 2012 10:09:01 +0000 (18:09 +0800)
django/archives/mailarchives/templates/datelist.html
django/archives/mailarchives/views.py
django/archives/urls.py

index 43b2e77cd394547bbef394c6fdb68acd5f93d5ee..c5b27779611d2a79b26a9e6c362dd7f67ee06505 100644 (file)
@@ -1,9 +1,10 @@
+{%load pgfilters%}
 <html>
 <head>
-<title>Put Title Here</title>
+<title>{{title}}</title>
 </head>
 <body>
-<h1>Put Title Here</h1>
+<h1>{{title}}</h1>
 {%for m in messages%}
 {%ifchanged m.date.date%}
 {%if not forloop.first%}
 <h3>{{m.date.date}}</h3>
 <ul>
 {%endifchanged%}
-  <li><a href="/test/{{m.id}}/">{{m.subject}}</a> ({{m.date.time|time:"H:i"}})</li>
+  <li><a href="/message-id/{{m.messageid}}/">{{m.subject}}</a> ({{m.date.time|time:"H:i:s"}} from {{m.mailfrom|hidemail}})</li>
 {%if forloop.last%}
 </ul>
 {%endif%}
 {%endfor%}
 {%with messages|last as lastmsg%}
-<a href="/{{list.listname}}/since/{{lastmsg.id}}/">Next</a>
+<a href="/{{list.listname}}/since/{{lastmsg.messageid}}/">Next</a>
 {%endwith%}
 </body>
 </html>
index d8bc5bdeefe9f2feb4c5351934d24b2f32a6e228..2ecc799fd08a8a2e49bfd8c65cffc50e6c5bdda2 100644 (file)
@@ -8,21 +8,23 @@ from datetime import datetime
 
 from models import *
 
-def render_datelist_from(request, l, d):
+def render_datelist_from(request, l, d, title):
        mlist = Message.objects.select_related().filter(date__gte=d).extra(where=["threadid IN (SELECT threadid FROM list_threads WHERE listid=%s)" % l.listid]).order_by('date')[:200]
        return render_to_response('datelist.html', {
                        'list': l,
                        'messages': list(mlist),
+                       'title': title,
                        })
 
-def datelistsince(request, listname, msgnum):
+def datelistsince(request, listname, msgid):
        l = get_object_or_404(List, listname=listname)
-       msg = get_object_or_404(Message, pk=msgnum)
-       return render_datelist_from(request, l, msg.date)
+       msg = get_object_or_404(Message, messageid=msgid)
+       return render_datelist_from(request, l, msg.date, "%s since %s" % (l.listname, msg.date.strftime("%Y-%m-%d %H:%M:%S")))
        
 def datelist(request, listname, year, month):
-       listid = get_object_or_404(List, listname=listname)
-       return render_datelist_from(request, listid, datetime(int(year), int(month), 1))
+       l = get_object_or_404(List, listname=listname)
+       d = datetime(int(year), int(month), 1)
+       return render_datelist_from(request, l, d, "%s - %s %s" % (l.listname, d.strftime("%B"), d.year))
 
 
 def attachment(request, attid):
index a56de3a6125c98825fae3f02a99be41ae946ab6c..84a26676f2c15569dfd545f39df4d8902617f4c0 100644 (file)
@@ -19,7 +19,7 @@ urlpatterns = patterns('',
     (r'^test/oldsite/([^/]+)/$', 'archives.mailarchives.views.oldsite'),
 
     (r'^([\w-]+)/(\d+)-(\d+)/$', 'archives.mailarchives.views.datelist'),
-    (r'^([\w-]+)/since/(\d+)/$', 'archives.mailarchives.views.datelistsince'),
+    (r'^([\w-]+)/since/([^/]+)/$', 'archives.mailarchives.views.datelistsince'),
 
     (r'^attachment/(\d+)/$', 'archives.mailarchives.views.attachment'),
 )