Use list name, not list id, in generated search form
authorMagnus Hagander <magnus@hagander.net>
Mon, 26 Mar 2018 12:35:04 +0000 (14:35 +0200)
committerMagnus Hagander <magnus@hagander.net>
Mon, 26 Mar 2018 12:36:43 +0000 (14:36 +0200)
The coupling between main site and archives was supposed to be loose,
which means that id's can be different. Meaning a listid sent from the
archives server might mean a different list on the website. So make sure
we pass out the list *name*, which the website knows what to do with.

django/archives/mailarchives/templates/searchform.html
django/archives/mailarchives/views.py

index 4222df5fcb6117f80e55c90c64f8d7cbd4ce644c..139fdb7d0c384159810eee5f053b1ea872a3f83c 100644 (file)
@@ -2,7 +2,7 @@
 </p>
 <form name="searchform" method="get" action="https://www.postgresql.org/search/">
  <input type="hidden" name="m" value="1" />
-{%if searchform_list%} <input type="hidden" name="l" value="{{searchform_list}}"/>{%endif%}
+{%if searchform_listname%} <input type="hidden" name="ln" value="{{searchform_listname}}"/>{%endif%}
  <div class="tblBasic">
   <table border="0" cellpadding="0" cellspacing="0" class="tblBasicGrey">
    <tr>
@@ -14,7 +14,7 @@
    <tr class="lastrow">
     <td class="colFirst"></td>
     <td>(enter a message-id to go directly to that message)</td>
-    <td class="colLast" align="right"><a href="https://www.postgresql.org/search/?m=1{%if searchform_list%}&amp;l={{searchform_list}}{%endif%}">Advanced Search</a></td>
+    <td class="colLast" align="right"><a href="https://www.postgresql.org/search/?m=1{%if searchform_list%}&amp;ln={{searchform_listname}}{%endif%}">Advanced Search</a></td>
    </tr>
   </table>
  </div>
index 37a4f69b1b8d99ef32f92b0777594c3d1acd69e4..47ef35f9e95381a11d3919a5a1880fef08a25f98 100644 (file)
@@ -157,7 +157,7 @@ def get_all_groups_and_lists(request, listid=None):
 
 
 class NavContext(object):
-       def __init__(self, request, listid=None, all_groups=None, expand_groupid=None):
+       def __init__(self, request, listid=None, listname=None, all_groups=None, expand_groupid=None):
                self.request = request
                self.ctx = {}
 
@@ -177,8 +177,8 @@ class NavContext(object):
                                g['lists'] = []
 
                self.ctx.update({'listgroups': groups})
-               if listid:
-                       self.ctx.update({'searchform_list': listid})
+               if listname:
+                       self.ctx.update({'searchform_listname': listname})
 
 def render_nav(navcontext, template, ctx):
        ctx.update(navcontext.ctx)
@@ -214,7 +214,7 @@ def monthlist(request, listname):
        curs.execute("SELECT year, month FROM list_months WHERE listid=%(listid)s ORDER BY year DESC, month DESC", {'listid': l.listid})
        months=[{'year':r[0],'month':r[1], 'date':datetime(r[0],r[1],1)} for r in curs.fetchall()]
 
-       return render_nav(NavContext(request, l.listid), 'monthlist.html', {
+       return render_nav(NavContext(request, l.listid, l.listname), 'monthlist.html', {
                        'list': l,
                        'months': months,
                        })
@@ -261,7 +261,7 @@ def _render_datelist(request, l, d, datefilter, title, queryproc):
        allyearmonths = set([(m.date.year, m.date.month) for m in mlist])
        (yearmonth, daysinmonth) = get_monthday_info(mlist, l, d)
 
-       r = render_nav(NavContext(request, l.listid), 'datelist.html', {
+       r = render_nav(NavContext(request, l.listid, l.listname), 'datelist.html', {
                        'list': l,
                        'messages': mlist,
                        'title': title,
@@ -443,7 +443,7 @@ def message(request, msgid):
                parent = None
        nextprev = _get_nextprevious(listmap, m.date)
 
-       r = render_nav(NavContext(request, lists[0].listid), 'message.html', {
+       r = render_nav(NavContext(request, lists[0].listid, lists[0].listname), 'message.html', {
                        'msg': m,
                        'threadstruct': threadstruct,
                        'responses': responses,