Skip to content

Commit 566fba6

Browse files
committed
Use normalize_draftname to strip version number and .txt from
I-D names entered in search box. - Legacy-Id: 832
1 parent 64df229 commit 566fba6

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

ietf/idindex/views.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ietf.idtracker.models import Acronym, IETFWG, InternetDraft, Rfc
1212
from ietf.idindex.forms import IDIndexSearchForm
1313
from ietf.idindex.models import alphabet, orgs, orgs_dict
14-
from ietf.utils import orl, flattenl
14+
from ietf.utils import orl, flattenl, normalize_draftname
1515

1616
base_extra = { 'alphabet': alphabet, 'orgs': orgs }
1717

@@ -101,6 +101,9 @@ def showdocs(request, cat=None):
101101

102102

103103
def search(request):
104+
args = request.GET.copy()
105+
if args.has_key('filename'):
106+
args['filename'] = normalize_draftname(args['filename'])
104107
form = IDIndexSearchForm()
105108
t = loader.get_template('idindex/search.html')
106109
# if there's a query, do the search and supply results to the template
@@ -113,20 +116,20 @@ def search(request):
113116
'first_name': 'authors__person__first_name__icontains',
114117
}
115118
for key in qdict.keys() + ['other_group']:
116-
if key in request.REQUEST:
119+
if key in args:
117120
searching = True
118121
if searching:
119122
# '0' and '-1' are flag values for "any"
120123
# in the original .cgi search page.
121124
# They are compared as strings because the
122125
# query dict is always strings.
123-
q_objs = [Q(**{qdict[k]: request.REQUEST[k]})
126+
q_objs = [Q(**{qdict[k]: args[k]})
124127
for k in qdict.keys()
125-
if request.REQUEST.get(k, '') != '' and
126-
request.REQUEST[k] != '0' and
127-
request.REQUEST[k] != '-1']
128+
if args.get(k, '') != '' and
129+
args[k] != '0' and
130+
args[k] != '-1']
128131
try:
129-
other = orgs_dict[request.REQUEST['other_group']]
132+
other = orgs_dict[args['other_group']]
130133
q_objs += [orl(
131134
[Q(filename__istartswith="draft-%s-" % p)|
132135
Q(filename__istartswith="draft-ietf-%s-" % p)

ietf/idtracker/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from ietf.idtracker.models import InternetDraft, IDInternal, IDState, IDSubState, Rfc, DocumentWrapper
1212
from ietf.idtracker.forms import IDSearch, EmailFeedback
1313
from ietf.utils.mail import send_mail_text
14+
from ietf.utils import normalize_draftname
1415
import re
1516

1617
# Override default form field mappings
@@ -34,6 +35,8 @@ def search(request):
3435
# "job_owner" of "0" means "All/Any"
3536
if args.get('search_job_owner', '') == '0':
3637
args['search_job_owner'] = ''
38+
if args.has_key('search_filename'):
39+
args['search_filename'] = normalize_draftname(args['search_filename'])
3740
form = IDSearch(args)
3841
# if there's a post, do the search and supply results to the template
3942
searching = False

0 commit comments

Comments
 (0)