Skip to content

Commit 7fa51e0

Browse files
committed
Change the idindex search to use GET to allow bookmarking searches.
Use request.REQUEST to allow backwards-compatible searching. - Legacy-Id: 486
1 parent a6c5f1b commit 7fa51e0

2 files changed

Lines changed: 23 additions & 14 deletions

File tree

ietf/idindex/views.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,30 @@ def showdocs(request, cat=None, sortby=None):
9696
def search(request):
9797
form = IDIndexSearchForm()
9898
t = loader.get_template('idindex/search.html')
99-
# if there's a post, do the search and supply results to the template
100-
# XXX should handle GET too
101-
if request.method == 'POST':
102-
qdict = { 'filename': 'filename__icontains',
103-
'id_tracker_state_id': 'idinternal__cur_state',
104-
'wg_id': 'group',
105-
'status_id': 'status',
106-
'last_name': 'authors__person__last_name__icontains',
107-
'first_name': 'authors__person__first_name__icontains',
108-
}
109-
q_objs = [Q(**{qdict[k]: request.POST[k]})
99+
# if there's a query, do the search and supply results to the template
100+
searching = False
101+
qdict = { 'filename': 'filename__icontains',
102+
'id_tracker_state_id': 'idinternal__cur_state',
103+
'wg_id': 'group',
104+
'status_id': 'status',
105+
'last_name': 'authors__person__last_name__icontains',
106+
'first_name': 'authors__person__first_name__icontains',
107+
}
108+
for key in qdict.keys() + ['other_group']:
109+
if key in request.REQUEST:
110+
searching = True
111+
if searching:
112+
# '0' and '-1' are flag values for "any"
113+
# in the original .cgi search page.
114+
# They are compared as strings because the
115+
# query dict is always strings.
116+
q_objs = [Q(**{qdict[k]: request.REQUEST[k]})
110117
for k in qdict.keys()
111-
if request.POST[k] != '']
118+
if request.REQUEST.get(k, '') != '' and
119+
request.REQUEST[k] != '0' and
120+
request.REQUEST[k] != '-1']
112121
try:
113-
other = orgs_dict[request.POST['other_group']]
122+
other = orgs_dict[request.REQUEST['other_group']]
114123
q_objs += [orl(
115124
[Q(filename__istartswith="draft-%s-" % p)|
116125
Q(filename__istartswith="draft-ietf-%s-" % p)

ietf/templates/idindex/search.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h2>No results to your search.</h2>
1313
{% else %}
1414
<center>
1515
<h2>I-D Search</h2>
16-
<form action="" method="POST">
16+
<form action="." method="GET">
1717
<table cellpadding="1" cellspacing="1" border="0" bgcolor="#9999ff">
1818
<tr><td>
1919
<table cellpadding="2" cellspacing="1" border="0" bgcolor="#ffffff">

0 commit comments

Comments
 (0)