Skip to content

Commit

Permalink
Add IRTF State option to Additional Search Criteria pulldown. Commit …
Browse files Browse the repository at this point in the history
…ready for merge.

 - Legacy-Id: 15012
  • Loading branch information
madofo committed Apr 5, 2018
1 parent 56869d9 commit cd91260
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ietf/doc/views_search.py
Expand Up @@ -63,14 +63,15 @@ 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)
area = forms.ModelChoiceField(Group.objects.filter(type="area", state="active").order_by('name'), empty_label="any area", required=False)
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= (
Expand Down Expand Up @@ -112,7 +113,9 @@ def clean(self):
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
Expand All @@ -122,6 +125,8 @@ def clean(self):
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):
Expand Down Expand Up @@ -184,6 +189,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"])

Expand Down
10 changes: 10 additions & 0 deletions ietf/templates/doc/search/search_form.html
Expand Up @@ -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"/>
Expand Down

0 comments on commit cd91260

Please sign in to comment.