Merged in [15012] from ford@isoc.org:

Add IRTF State option to Additional Search Criteria pulldown.
 - Legacy-Id: 15016
Note: SVN reference [15012] has been migrated to Git commit cd912600e6
This commit is contained in:
Henrik Levkowetz 2018-04-05 14:50:40 +00:00
commit 6a32a363cc
2 changed files with 19 additions and 2 deletions

View file

@ -64,7 +64,7 @@ class SearchForm(forms.Form):
activedrafts = forms.BooleanField(required=False, initial=True)
olddrafts = forms.BooleanField(required=False, initial=False)
by = forms.ChoiceField(choices=[(x,x) for x in ('author','group','area','ad','state','stream')], required=False, initial='group')
by = forms.ChoiceField(choices=[(x,x) for x in ('author','group','area','ad','state','irtfstate','stream')], required=False, initial='group')
author = forms.CharField(required=False)
group = forms.CharField(required=False)
stream = forms.ModelChoiceField(StreamName.objects.all().order_by('name'), empty_label="any stream", required=False)
@ -72,6 +72,7 @@ class SearchForm(forms.Form):
ad = forms.ChoiceField(choices=(), required=False)
state = forms.ModelChoiceField(State.objects.filter(type="draft-iesg"), empty_label="any state", required=False)
substate = forms.ChoiceField(choices=(), required=False)
irtfstate = forms.ModelChoiceField(State.objects.filter(type="draft-stream-irtf"), empty_label="any state", required=False)
sort = forms.ChoiceField(
choices= (
@ -111,7 +112,9 @@ class SearchForm(forms.Form):
for k in ('author', 'group', 'area', 'ad'):
if q['by'] == k and not q.get(k):
q['by'] = None
if q['by'] == 'state' and not (q.get("state") or q.get('substate')):
if q['by'] == 'state' and not (q.get('state') or q.get('substate')):
q['by'] = None
if q['by'] == 'irtfstate' and not (q.get('irtfstate')):
q['by'] = None
else:
q['by'] = None
@ -121,6 +124,8 @@ class SearchForm(forms.Form):
q[k] = ""
if q['by'] != 'state':
q['state'] = q['substate'] = None
if q['by'] != 'irtfstate':
q['irtfstate'] = None
return q
def retrieve_search_results(form, all_types=False):
@ -183,6 +188,8 @@ def retrieve_search_results(form, all_types=False):
docs = docs.filter(states=query["state"])
if query["substate"]:
docs = docs.filter(tags=query["substate"])
elif by == "irtfstate":
docs = docs.filter(states=query["irtfstate"])
elif by == "stream":
docs = docs.filter(stream=query["stream"])

View file

@ -106,6 +106,16 @@
</div>
</div>
<div class="form-group search_field">
<div class="col-sm-4">
<input type="radio" name="by" value="irtfstate" {% if form.by.value == "irtfstate" %}checked{% endif %} id="irtfstate"/>
<label for="irtfstate" class="control-label">IRTF State</label>
</div>
<div class="col-sm-8">
{{ form.irtfstate|add_class:"form-control" }}
</div>
</div>
<div class="form-group search_field">
<div class="col-sm-4">
<input type="radio" name="by" value="stream" {% if form.by.value == "stream" %}checked{% endif %} id="stream"/>