Skip to content

Commit

Permalink
added sort by cosponsorships to /person/ view
Browse files Browse the repository at this point in the history
  • Loading branch information
Young Kim committed Mar 22, 2015
1 parent 180f1e6 commit 257a66c
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 24 deletions.
26 changes: 17 additions & 9 deletions pokr/messages.pot
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Translations template for PROJECT.
# Copyright (C) 2014 ORGANIZATION
# Copyright (C) 2015 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2014.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2015.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2014-09-26 15:38+0900\n"
"POT-Creation-Date: 2015-03-21 19:55-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"
"Generated-By: Babel 1.3\n"

#: pokr/models/meeting.py:49
#, python-format
Expand Down Expand Up @@ -317,10 +317,10 @@ msgstr ""
msgid "Easier to understand difficult words"
msgstr ""

#: pokr/templates/meeting-dialogue.html:36
#: pokr/templates/meeting-dialogue.html:55
#: pokr/templates/meeting-dialogue.html:58
#: pokr/templates/meeting-dialogue.html:61
#: pokr/templates/meeting-dialogue.html:43
#: pokr/templates/meeting-dialogue.html:62
#: pokr/templates/meeting-dialogue.html:65
#: pokr/templates/meeting-dialogue.html:68
msgid "link"
msgstr ""

Expand Down Expand Up @@ -383,7 +383,7 @@ msgstr ""
msgid "meetings"
msgstr ""

#: pokr/templates/meetings.html:23 pokr/views/meeting.py:25
#: pokr/templates/meetings.html:23 pokr/views/meeting.py:33
msgid "meeting"
msgstr ""

Expand Down Expand Up @@ -501,6 +501,14 @@ msgstr ""
msgid "people"
msgstr ""

#: pokr/templates/people.html:45
msgid "Sort by name"
msgstr ""

#: pokr/templates/people.html:46
msgid "Sort by cosponsorship"
msgstr ""

#: pokr/templates/person-elections.html:4
msgid "By-election results are coming soon!"
msgstr ""
Expand Down
6 changes: 5 additions & 1 deletion pokr/static/less/submain.less
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ div.party-card {
font-size: 13pt;
text-align: center;
margin: 0 auto;
display: inline-block;
display: inline-block;
vertical-align: middle;
line-height: 20px;
}
Expand All @@ -77,6 +77,10 @@ div.party-card {
border-bottom: 1px solid @layout_border_color;
}

#sort-tabs {
position: relative;
}

///// meetings.html
#year-num {
position: absolute;
Expand Down
8 changes: 7 additions & 1 deletion pokr/templates/people.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<li {% if assembly_id_ == assembly_id %}class="active"{% endif %}><a href="{{ url_for('person_main', assembly_id=assembly_id_) }}">{{ assembly_id_ }}{{ gettext('th') }}</a></li>
{% endfor %}
</ul>
</div>
</div>
</div>
{% if mobile %}
<div class="float-list">
Expand All @@ -40,6 +40,12 @@
</div>
{% else %}
{{ macro.list_count(officials, type='people') }}
<div id="sort-tabs">
<ul class="nav nav-tiles">
<li><a href="{{ url_for('person_main', sort='name') }}">{{ gettext('Sort by name') }}</a></li>
<li><a href="{{ url_for('person_main', sort='cosponsorship') }}">{{ gettext('Sort by cosponsorship') }}</a></li>
</ul>
</div>
<td class="float-list">
{{ macro.people_list_pagenav(officials, pagesize=72) }}
</td>
Expand Down
Binary file modified pokr/translations/ko/LC_MESSAGES/messages.mo
Binary file not shown.
23 changes: 15 additions & 8 deletions pokr/translations/ko/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2014-09-26 15:38+0900\n"
"POT-Creation-Date: 2015-03-21 19:55-0700\n"
"PO-Revision-Date: 2012-08-06 12:48+0900\n"
"Last-Translator: Cheol KANG <[email protected]>\n"
"Language-Team: ko <[email protected]>\n"
"Plural-Forms: nplurals=1; plural=0\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"
"Generated-By: Babel 1.3\n"

#: pokr/models/meeting.py:49
#, python-format
Expand Down Expand Up @@ -317,10 +317,10 @@ msgstr "용어 풀이"
msgid "Easier to understand difficult words"
msgstr "어려운 용어에는 용어 풀이가 부착되어 있습니다"

#: pokr/templates/meeting-dialogue.html:36
#: pokr/templates/meeting-dialogue.html:55
#: pokr/templates/meeting-dialogue.html:58
#: pokr/templates/meeting-dialogue.html:61
#: pokr/templates/meeting-dialogue.html:43
#: pokr/templates/meeting-dialogue.html:62
#: pokr/templates/meeting-dialogue.html:65
#: pokr/templates/meeting-dialogue.html:68
msgid "link"
msgstr "링크"

Expand Down Expand Up @@ -383,7 +383,7 @@ msgstr "참석자 중 의원만 표기되어 있음."
msgid "meetings"
msgstr "회의"

#: pokr/templates/meetings.html:23 pokr/views/meeting.py:25
#: pokr/templates/meetings.html:23 pokr/views/meeting.py:33
msgid "meeting"
msgstr "회의"

Expand Down Expand Up @@ -501,6 +501,14 @@ msgstr "대 %(election_type)s 선거"
msgid "people"
msgstr "인물"

#: pokr/templates/people.html:45
msgid "Sort by name"
msgstr "이름순 정렬"

#: pokr/templates/people.html:46
msgid "Sort by cosponsorship"
msgstr "의안활동순 정렬"

#: pokr/templates/person-elections.html:4
msgid "By-election results are coming soon!"
msgstr "보궐선거 데이터는 곧 추가될 예정입니다!"
Expand Down Expand Up @@ -806,4 +814,3 @@ msgstr ""
"%(assembly_id)d대\n"
"%(election_type)s\n"
"낙선"

33 changes: 28 additions & 5 deletions pokr/views/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,36 @@ def register(app):
@app.route('/person/', methods=['GET'])
@breadcrumb(app)
def person_main():
sort = request.args.get('sort', 'name')
election_type = request.args.get('election_type', 'assembly')
assembly_id = int(request.args.get('assembly_id', current_parliament_id(election_type)) or 0)
officials = Person.query.order_by(Person.name)\
.join(Candidacy)\
.filter(and_(Candidacy.type == election_type,
Candidacy.assembly_id == assembly_id,
Candidacy.is_elected == True))

if sort == 'cosponsorship':
bill_t = Bill.__table__
cosponsorship_count = db_session.query(
cosponsorship.c.person_id,
func.count(cosponsorship.c.id).label('cosponsorship_count')
)\
.outerjoin(bill_t)\
.filter(bill_t.c.assembly_id == assembly_id)\
.group_by(cosponsorship.c.person_id)\
.subquery('cosponsorship_count')

officials = Person.query.order_by(
desc(func.coalesce(func.sum(cosponsorship_count.c.cosponsorship_count), 0))
)\
.join(Candidacy)\
.outerjoin(cosponsorship_count)\
.filter(and_(Candidacy.type == election_type,
Candidacy.assembly_id == assembly_id,
Candidacy.is_elected == True))\
.group_by(Person.id)
else:
officials = Person.query.order_by(Person.name)\
.join(Candidacy)\
.filter(and_(Candidacy.type == election_type,
Candidacy.assembly_id == assembly_id,
Candidacy.is_elected == True))

return render_template('people.html',
officials=officials,
Expand Down

0 comments on commit 257a66c

Please sign in to comment.