Skip to content
This repository has been archived by the owner on Dec 23, 2017. It is now read-only.

Commit

Permalink
Merge branch 'develop' into feature/pac-arty-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LindsayYoung committed Jun 2, 2015
2 parents 33b1392 + eb24015 commit 07adeb6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 25 deletions.
12 changes: 0 additions & 12 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,6 @@ def date_filter_md(date_str):
return ''
return parse_date(date_str).strftime('%b %Y')

@app.template_filter('last_n_characters')
def last_n_characters(value, nchar=3):
if type(value) == int:
return str(value % (10 ** nchar)).rjust(nchar, '0')
return ''

@app.template_filter()
def fmt_year_range(year):
Expand Down Expand Up @@ -250,13 +245,6 @@ def next_cycle(value, cycles):
)


@app.template_filter()
def url_to_fec_pdf(report):
beg_img_num = report['beginning_image_number']
beg_img_num_last_n = last_n_characters(beg_img_num)
return "http://docquery.fec.gov/pdf/{0}/{1}/{1}.pdf".format(beg_img_num_last_n, beg_img_num)


# If HTTPS is on, apply full HSTS as well, to all subdomains.
# Only use when you're sure. 31536000 = 1 year.
if config.force_https:
Expand Down
1 change: 1 addition & 0 deletions openfecwebapp/api_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def load_nested_type(parent_type, c_id, nested_type, *path, **filters):
def load_cmte_financials(committee_id, **filters):
filters.update({
'per_page': MAX_FINANCIALS_COUNT,
'report_type': filters.get('report_type', []) + ['-TER']
})

reports = _call_api('committee', committee_id, 'reports', **filters)
Expand Down
15 changes: 11 additions & 4 deletions templates/committees-single.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h5 class="entity__term__label">Treasurer</h5>
</li>
{% if candidates %}
<li class="entity__term">
<h5 class="entity__term__label">Related
<h5 class="entity__term__label">Related
{% if candidates|length > 1 %}
Candidates
{% else %}
Expand Down Expand Up @@ -140,17 +140,24 @@ <h5>{{ pretty_name }}</h5>

<section class="page-section" id="section-1" role="tabpanel" aria-hidden="false" aria-labelledby="section-1-header">
<div class="container committee-summary">
{% if totals %}
{% if reports and totals %}
<h2 id="section-1-header" tabindex="0">Financial Summary</h2>
<p class="text--lead">Get the full picture of all of the money received and spent by this committee.</p>
<div class="page-subsection page-subsection--noline">
<div class="row js-accordion meta-box recent-report">
{% with committee=context() %}
<div class="meta-box__bar">
<h4>Most Recent Report:
<a href="{{ committee.reports.0|url_to_fec_pdf }}">{{ committee.reports.0.report_year }} {{committee.reports.0.report_type_full|fmt_report_desc}}</a>
{% if committee.reports.0.pdf_url %}
<a href="{{ committee.reports.0.pdf_url }}">{{ committee.reports.0.report_year }} {{committee.reports.0.report_type_full|fmt_report_desc}}</a>
{% else %}
{{ committee.reports.0.report_year }} {{committee.reports.0.report_type_full|fmt_report_desc}}
{% endif %}
</h4>
<span>Report coverage: {{ committee.reports.0.coverage_start_date|date_md }} - {{ committee.reports.0.coverage_end_date|date_md }} | <a href="http://docquery.fec.gov/pdf/{{ committee.reports[0].beginning_image_number|last_n_characters }}/{{ committee.reports[0].beginning_image_number }}/{{ committee.reports[0].beginning_image_number }}.pdf">View PDF &raquo;</a></span>
<span>Report coverage: {{ committee.reports.0.coverage_start_date|date_md }} - {{ committee.reports.0.coverage_end_date|date_md }}
{% if committee.reports.0.pdf_url %}
| <a href="{{ committee.reports.0.pdf_url }}">View PDF &raquo;</a></span>
{% endif %}
</div>

{% if committee_type == 'P' %}
Expand Down
8 changes: 5 additions & 3 deletions templates/partials/committee-summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ <h4 class="figure__title">Totals for {{totals.cycle|fmt_year_range|default("unav
<div class="table__cell">{{report.debts_owed_by_committee|currency|default("unavailable")}}</div>
</div>
<div class="table__row--note">
{% if report %}
Source: <a href="{{ report|url_to_fec_pdf }}">{{report.report_type_full|fmt_report_desc|default("Report")}} {{ report.report_year }}</a>
{% if report.pdf_url %}
Source: <a href="{{ report.pdf_url }}">{{report.report_type_full|fmt_report_desc|default("Report")}} {{ report.report_year }}</a>
{% elif report %}
Source: {{report.report_type_full|fmt_report_desc|default("Report")}} {{ report.report_year }}
{% else %}
Source: None
Source: Unknown
{% endif %}
</div>
</div>
Expand Down
6 changes: 0 additions & 6 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ def test_date_filter_empty():
assert app.date_filter_md(None) == ''


def test_last_n_characters():
value = 123456789
assert app.last_n_characters(value) == '789'
assert app.last_n_characters(5) == '005'


def test_fmt_year_range_int():
assert app.fmt_year_range(1985) == '1984 - 1985'

Expand Down

0 comments on commit 07adeb6

Please sign in to comment.