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

Changed FEC PDF links to be built by a filter #194

Merged
merged 2 commits into from
May 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ def fmt_report_desc(report_full_description):
return re.sub('{.+}', '', report_full_description)


@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 force_https:
Expand Down
2 changes: 1 addition & 1 deletion templates/committees-single.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ <h2 id="section-1-header" tabindex="0">Financial Summary</h2>
{% with committee=context() %}
<div class="meta-box__bar">
<h4>Most Recent Report:
<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">{{ committee.reports[0].report_year }} {{committee.reports[0].report_type_full|fmt_report_desc}}</a>
<a href="{{ committee.reports.0|url_to_fec_pdf }}">{{ committee.reports.0.report_year }} {{committee.reports.0.report_type_full|fmt_report_desc}}</a>
</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>
</div>
Expand Down
12 changes: 8 additions & 4 deletions templates/partials/committee-summary.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% with %}
{% set reports = committee.reports.0 if committee.reports else {} %}
{% set report = committee.reports.0 if committee.reports else {} %}
{% set totals = committee.totals.0 if committee.totals else {} %}

<figure class="table--simple reports-table">
Expand All @@ -20,14 +20,18 @@ <h4 class="figure__title">Totals for {{totals.cycle|fmt_year_range|default("unav
<div class="table__half">
<div class="table__row">
<div class="table__cell"><span class="term" data-term="Cash on Hand">Cash on hand</span></div>
<div class="table__cell">{{reports.cash_on_hand_end_period|currency|default("unavailable")}}</div>
<div class="table__cell">{{report.cash_on_hand_end_period|currency|default("unavailable")}}</div>
</div>
<div class="table__row">
<div class="table__cell"><span class="term" data-term="Debt">Debt</span></div>
<div class="table__cell">{{reports.debts_owed_by_committee|currency|default("unavailable")}}</div>
<div class="table__cell">{{report.debts_owed_by_committee|currency|default("unavailable")}}</div>
</div>
<div class="table__row--note">
Source: <a href="http://docquery.fec.gov/pdf/{{ reports.beginning_image_number|last_n_characters }}/{{ reports.beginning_image_number }}/{{ reports.beginning_image_number }}.pdf">{{reports.report_type_full|fmt_report_desc|default("unavailable")}} {{ reports.report_year }}</a>
{% if report %}
Source: <a href="{{ report|url_to_fec_pdf }}">{{report.report_type_full|fmt_report_desc|default("Report")}} {{ report.report_year }}</a>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmcarp I went ahead and changed the default report text to read just "Report" in the case that we have a report but for some reason the report_type_full is not filled in. Does that work, do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

{% else %}
Source: None
{% endif %}
</div>
</div>
</figure>
Expand Down