Skip to content

Commit

Permalink
Undo removing statement searches
Browse files Browse the repository at this point in the history
  • Loading branch information
e9t committed Apr 19, 2016
1 parent 340f7e0 commit a1653ed
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pokr/templates/search-results.html
Expand Up @@ -175,6 +175,24 @@
</td>
</tr>
{% endif %}
{% if target == 'statements' %}
<tr>
<th>
{{ gettext('Statement') }}
<br>{{ macro.list_count(statements) }}
</th>
<td>{% if target %}
{% call(statement) macro.list_pagenav(statements, layout='table') %}
{{ macro.meeting_statement(statement) }}
{% endcall %}
{% else %}
{% call(statement) macro.list_more(statements, url_for_query(target='statements'), layout='table', pagesize=5) %}
{{ macro.meeting_statement(statement) }}
{% endcall %}
{% endif %}
</td>
</tr>
{% endif %}
</tbody>
</table>
<script>
Expand Down
22 changes: 22 additions & 0 deletions pokr/views/search.py
Expand Up @@ -21,6 +21,7 @@
from pokr.models.person import Person
from pokr.models.region import Region
from pokr.models.school import School
from pokr.models.statement import Statement
from pokr.models.query_log import log_query
from utils.jinja import breadcrumb

Expand All @@ -45,6 +46,7 @@ def search():
results['bills'] , options['bills'] = search_bills()
results['regions'], options['regions'] = search_regions()
results['meetings'], options['meetings'] = search_meetings()
results['statements'], options['statements'] = search_statements()

options = dict(chain(*(d.iteritems() for d in options.itervalues())))
response = render_template('search-results.html',
Expand Down Expand Up @@ -191,6 +193,26 @@ def search_meetings():
.group_by(Meeting.id).order_by(desc(Meeting.date))
return (meetings, options)

@if_target('statements')
def search_statements():
options = {}
person_id = request.args.get('person_id')

statements = Statement.query.join(Meeting)\
.order_by(Meeting.date.desc().nullslast(),\
Statement.sequence)

if query:
statements = statements\
.filter(Statement.content.like(u'%{0}%'.format(query)))

if person_id:
statements = statements.filter(Statement.person_id==person_id)
options['person_id'] =\
Person.query.filter_by(id=person_id).one().name

return (statements, options)


def if_target(target_):
def deco(f):
Expand Down

0 comments on commit a1653ed

Please sign in to comment.