@@ -154,7 +154,7 @@ def get_all_groups_and_lists(request, listid=None):
154
154
'sortkey' : l .group .sortkey ,
155
155
'lists' : [l ,],
156
156
'homelink' : 'list/group/%s' % l .group .groupid ,
157
- }
157
+ }
158
158
159
159
return (sorted (list (groups .values ()), key = lambda g : g ['sortkey' ]), listgroupid )
160
160
@@ -193,8 +193,8 @@ def index(request):
193
193
194
194
(groups , listgroupid ) = get_all_groups_and_lists (request )
195
195
return render_nav (NavContext (request , all_groups = groups ), 'index.html' , {
196
- 'groups' : [{'groupname' : g ['groupname' ], 'lists' : g ['lists' ]} for g in groups ],
197
- })
196
+ 'groups' : [{'groupname' : g ['groupname' ], 'lists' : g ['lists' ]} for g in groups ],
197
+ })
198
198
199
199
200
200
@cache (hours = 8 )
@@ -205,8 +205,8 @@ def groupindex(request, groupid):
205
205
raise Http404 ('List group does not exist' )
206
206
207
207
return render_nav (NavContext (request , all_groups = groups , expand_groupid = groupid ), 'index.html' , {
208
- 'groups' : mygroups ,
209
- })
208
+ 'groups' : mygroups ,
209
+ })
210
210
211
211
@cache (hours = 8 )
212
212
def monthlist (request , listname ):
@@ -218,9 +218,9 @@ def monthlist(request, listname):
218
218
months = [{'year' :r [0 ],'month' :r [1 ], 'date' :datetime (r [0 ],r [1 ],1 )} for r in curs .fetchall ()]
219
219
220
220
return render_nav (NavContext (request , l .listid , l .listname ), 'monthlist.html' , {
221
- 'list' : l ,
222
- 'months' : months ,
223
- })
221
+ 'list' : l ,
222
+ 'months' : months ,
223
+ })
224
224
225
225
def get_monthday_info (mlist , l , d ):
226
226
allmonths = set ([m .date .month for m in mlist ])
@@ -236,10 +236,10 @@ def get_monthday_info(mlist, l, d):
236
236
if monthdate :
237
237
curs = connection .cursor ()
238
238
curs .execute ("SELECT DISTINCT extract(day FROM date) FROM messages WHERE date >= %(startdate)s AND date < %(enddate)s AND threadid IN (SELECT threadid FROM list_threads WHERE listid=%(listid)s) ORDER BY 1" , {
239
- 'startdate' : datetime (year = monthdate .year , month = monthdate .month , day = 1 ),
240
- 'enddate' : monthdate + timedelta (days = calendar .monthrange (monthdate .year , monthdate .month )[1 ]),
241
- 'listid' : l .listid ,
242
- })
239
+ 'startdate' : datetime (year = monthdate .year , month = monthdate .month , day = 1 ),
240
+ 'enddate' : monthdate + timedelta (days = calendar .monthrange (monthdate .year , monthdate .month )[1 ]),
241
+ 'listid' : l .listid ,
242
+ })
243
243
daysinmonth = [int (r [0 ]) for r in curs .fetchall ()]
244
244
245
245
yearmonth = None
@@ -265,12 +265,12 @@ def _render_datelist(request, l, d, datefilter, title, queryproc):
265
265
(yearmonth , daysinmonth ) = get_monthday_info (mlist , l , d )
266
266
267
267
r = render_nav (NavContext (request , l .listid , l .listname ), 'datelist.html' , {
268
- 'list' : l ,
269
- 'messages' : mlist ,
270
- 'title' : title ,
271
- 'daysinmonth' : daysinmonth ,
272
- 'yearmonth' : yearmonth ,
273
- })
268
+ 'list' : l ,
269
+ 'messages' : mlist ,
270
+ 'title' : title ,
271
+ 'daysinmonth' : daysinmonth ,
272
+ 'yearmonth' : yearmonth ,
273
+ })
274
274
r ['X-pglm' ] = ':%s:' % (':' .join (['%s/%s/%s' % (l .listid , year , month ) for year ,month in allyearmonths ]))
275
275
return r
276
276
@@ -379,7 +379,8 @@ def _build_thread_structure(threadid):
379
379
380
380
def _get_nextprevious (listmap , dt ):
381
381
curs = connection .cursor ()
382
- curs .execute ("""WITH l(listid) AS (
382
+ curs .execute ("""
383
+ WITH l(listid) AS (
383
384
SELECT unnest(%(lists)s)
384
385
)
385
386
SELECT l.listid,1,
@@ -394,10 +395,11 @@ def _get_nextprevious(listmap, dt):
394
395
INNER JOIN list_threads lt ON lt.threadid=m.threadid
395
396
WHERE m.date<%(time)s AND lt.listid=l.listid
396
397
ORDER BY m.date DESC LIMIT 1
397
- ) FROM l""" , {
398
- 'lists' : list (listmap .keys ()),
399
- 'time' : dt ,
400
- })
398
+ ) FROM l""" ,
399
+ {
400
+ 'lists' : list (listmap .keys ()),
401
+ 'time' : dt ,
402
+ })
401
403
retval = {}
402
404
for listid , isnext , data in curs .fetchall ():
403
405
if data :
@@ -408,13 +410,13 @@ def _get_nextprevious(listmap, dt):
408
410
'date' : data [1 ],
409
411
'subject' : data [2 ],
410
412
'from' : data [3 ],
411
- }
413
+ }
412
414
if listname in retval :
413
415
retval [listname ][isnext and 'next' or 'prev' ] = d
414
416
else :
415
417
retval [listname ] = {
416
418
isnext and 'next' or 'prev' : d
417
- }
419
+ }
418
420
return retval
419
421
420
422
@cache (hours = 4 )
@@ -447,13 +449,13 @@ def message(request, msgid):
447
449
nextprev = _get_nextprevious (listmap , m .date )
448
450
449
451
r = render_nav (NavContext (request , lists [0 ].listid , lists [0 ].listname ), 'message.html' , {
450
- 'msg' : m ,
451
- 'threadstruct' : threadstruct ,
452
- 'responses' : responses ,
453
- 'parent' : parent ,
454
- 'lists' : lists ,
455
- 'nextprev' : nextprev ,
456
- })
452
+ 'msg' : m ,
453
+ 'threadstruct' : threadstruct ,
454
+ 'responses' : responses ,
455
+ 'parent' : parent ,
456
+ 'lists' : lists ,
457
+ 'nextprev' : nextprev ,
458
+ })
457
459
r ['X-pgthread' ] = ":%s:" % m .threadid
458
460
r ['Last-Modified' ] = http_date (newest )
459
461
return r
@@ -478,11 +480,11 @@ def message_flat(request, msgid):
478
480
return HttpResponseNotModified ()
479
481
480
482
r = render_nav (NavContext (request ), 'message_flat.html' , {
481
- 'msg' : msg ,
482
- 'allmsg' : allmsg ,
483
- 'lists' : lists ,
484
- 'isfirst' : isfirst ,
485
- })
483
+ 'msg' : msg ,
484
+ 'allmsg' : allmsg ,
485
+ 'lists' : lists ,
486
+ 'isfirst' : isfirst ,
487
+ })
486
488
r ['X-pgthread' ] = ":%s:" % msg .threadid
487
489
r ['Last-Modified' ] = http_date (newest )
488
490
return r
@@ -572,9 +574,9 @@ def mbox(request, listname, listname2, mboxyear, mboxmonth):
572
574
573
575
query = "SELECT messageid, rawtxt FROM messages m INNER JOIN list_threads t ON t.threadid=m.threadid WHERE listid=%(listid)s AND hiddenstatus IS NULL AND date >= %(startdate)s AND date <= %(enddate)s %%% ORDER BY date"
574
576
params = {
575
- 'listid' : l .listid ,
576
- 'startdate' : date (mboxyear , mboxmonth , 1 ),
577
- 'enddate' : datetime (mboxyear , mboxmonth , calendar .monthrange (mboxyear , mboxmonth )[1 ], 23 , 59 , 59 ),
577
+ 'listid' : l .listid ,
578
+ 'startdate' : date (mboxyear , mboxmonth , 1 ),
579
+ 'enddate' : datetime (mboxyear , mboxmonth , calendar .monthrange (mboxyear , mboxmonth )[1 ], 23 , 59 , 59 ),
578
580
}
579
581
580
582
if not settings .PUBLIC_ARCHIVES and not request .user .is_superuser :
@@ -647,8 +649,8 @@ def search(request):
647
649
# We don't do a more specific check if it's a messageid because doing
648
650
# a key lookup is cheap...
649
651
curs .execute ("SELECT messageid FROM messages WHERE messageid=%(q)s" , {
650
- 'q' : query ,
651
- })
652
+ 'q' : query ,
653
+ })
652
654
a = curs .fetchall ()
653
655
if len (a ) == 1 :
654
656
# Yup, this was a messageid
@@ -680,16 +682,16 @@ def search(request):
680
682
681
683
resp = HttpResponse (content_type = 'application/json' )
682
684
683
- json .dump ([{
684
- 'm' : messageid ,
685
- 'd ' : date . isoformat () ,
686
- 's ' : subject ,
687
- 'f ' : mailfrom ,
688
- 'r ' : rank ,
689
- 'a ' : abstract . replace ( "[[[[[[" , "<b>" ). replace ( "]]]]]]" , "</b>" ) ,
690
-
691
- } for messageid , date , subject , mailfrom , rank , abstract in curs .fetchall ()],
692
- resp )
685
+ json .dump ([
686
+ {
687
+ 'm ' : messageid ,
688
+ 'd ' : date . isoformat () ,
689
+ 's ' : subject ,
690
+ 'f ' : mailfrom ,
691
+ 'r ' : rank ,
692
+ 'a' : abstract . replace ( "[[[[[[" , "<b>" ). replace ( "]]]]]]" , "</b>" ),
693
+ } for messageid , date , subject , mailfrom , rank , abstract in curs .fetchall ()],
694
+ resp )
693
695
return resp
694
696
695
697
@cache (seconds = 10 )
@@ -703,11 +705,11 @@ def web_sync_timestamp(request):
703
705
def legacy (request , listname , year , month , msgnum ):
704
706
curs = connection .cursor ()
705
707
curs .execute ("SELECT msgid FROM legacymap WHERE listid=(SELECT listid FROM lists WHERE listname=%(list)s) AND year=%(year)s AND month=%(month)s AND msgnum=%(msgnum)s" , {
706
- 'list' : listname ,
707
- 'year' : year ,
708
- 'month' : month ,
709
- 'msgnum' : msgnum ,
710
- })
708
+ 'list' : listname ,
709
+ 'year' : year ,
710
+ 'month' : month ,
711
+ 'msgnum' : msgnum ,
712
+ })
711
713
r = curs .fetchall ()
712
714
if len (r ) != 1 :
713
715
raise Http404 ('Message does not exist' )
@@ -723,7 +725,7 @@ def legacy(request, listname, year, month, msgnum):
723
725
'media/css/table.css' ,
724
726
'media/css/text.css' ,
725
727
'media/css/docs.css' ],
726
- }
728
+ }
727
729
728
730
@cache (hours = 8 )
729
731
def dynamic_css (request , css ):
0 commit comments