Skip to content

Commit

Permalink
added section to alder page with table for campaign contributions
Browse files Browse the repository at this point in the history
  • Loading branch information
derekeder committed Jun 4, 2024
1 parent 1f27802 commit 8e1be59
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions chicago/templates/person.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ <h4>Contact info</h4>
</a>
</li>
{% endif %}
<li role="presentation" {% if request.GET.view == 'donations' %}class='active' {% endif %}>
<a href="/person/{{person.slug}}/?view=donations">
<span class="small-pill">
<i class='fa fa-fw fa-money'></i>
<span class="desktop-only">Campaign </span>
Donations
</span>
</a>
</li>
</ul>

{% if request.GET.view == 'bills' or request.GET.view == None %}
Expand Down Expand Up @@ -197,6 +206,40 @@ <h2>{{person.name}} has {{ attendance_percent }} attendance</h2>

{% endif %}

{% if request.GET.view == 'donations' %}
<h3>Campaign Donations</h3>
<div class="table-responsive">
<table id="campaign-donations" class="table">
<thead>
<tr>
<th>Commitee Name</th>
<th>Received Date</th>
<th>Amount</th>
<th>Type</th>
<th>Donor Name</th>
<th>Occupation</th>
<th>Employer</th>
<th>City, State Zip</th>
<th>Filing</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Commitee Name</th>
<th>Received Date</th>
<th>Amount</th>
<th>Type</th>
<th>Donor Name</th>
<th>Occupation</th>
<th>Employer</th>
<th>City, State Zip</th>
<th>Filing</th>
</tr>
</tfoot>
</table>
</div>
{% endif %}

<br />
<h3>Tools</h3>
<div class="modal-links">
Expand Down Expand Up @@ -231,6 +274,9 @@ <h3>Tools</h3>
{% endblock %}

{% block extra_js %}
<script src="{% static 'js/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'js/jquery.dataTables.sorting.js' %}"></script>
<script src="{% static 'js/dataTables.bootstrap.js' %}"></script>

{% if map_geojson %}

Expand Down Expand Up @@ -282,4 +328,53 @@ <h3>Tools</h3>

{% endif %}

<!-- Campaign Donations table -->
<script type="text/javascript" language="javascript" class="init">
$(document).ready(function () {

$("#campaign-donations").DataTable({
columns: [
{ data: "committee_name" },
{ data: "received_date" },
{
data: "amount",
render: $.fn.dataTable.render.number(",", ".", 0, "$"),
className: "dt-body-right",
},
{ data: "type" },
{ data: "name" },
{ data: "occupation" },
{ data: "employer" },
{ data: "city_state_zip" },
{
data: "filed_doc_id",
defaultContent: "",
render: function (data, type, row, meta) {
if (type === "display") {
const encoded_doc_id = encodeURIComponent(row.filed_doc_id);
let path = "";
switch (row.doc_name) {
case "A-1":
path = `A1List.aspx?FiledDocID=${encoded_doc_id}&ContributionType=wOGh3QTPfKqV2YWjeRmjTeStk426RfVK&Archived=Gl5sibpnFrQ%3d`;
break;
case "Final":
path = `D2Semiannual.aspx?id=${encoded_doc_id}`;
break;
default:
path = `D2Quarterly.aspx?id=${encoded_doc_id}`;
}
return `<a href="https://www.elections.il.gov/CampaignDisclosure/${path}">${row.filed_doc_id}</a>`;
}
},
},
],
order: [[1, "desc"]],
processing: true,
serverSide: true,
searching: true,
ajax: "https://puddle.bunkum.us/il_campaign_disclosure.datatable?sql=select%0D%0A++committees.name+AS+committee_name%2C%0D%0A++strftime+(%27%25Y-%25m-%25d%27%2C+received_date)+AS+received_date%2C%0D%0A++amount%2C%0D%0A++CASE%0D%0A++++WHEN+d2_part+%3D+%271A%27+THEN+%27individual+contribution%27%0D%0A++++WHEN+d2_part+%3D+%272A%27+THEN+%27transfer%27%0D%0A++++WHEN+d2_part+%3D+%273A%27+THEN+%27loan%27%0D%0A++++WHEN+d2_part+%3D+%274A%27+THEN+%27other+receipts%27%0D%0A++++WHEN+d2_part+%3D+%275A%27+THEN+%27in-kind%27%0D%0A++END+AS+type%2C%0D%0A++CASE%0D%0A++++WHEN+first_name+IS+NOT+NULL+THEN+first_name+||+%27+%27+||+last_name%0D%0A++++ELSE+last_name%0D%0A++END+AS+name%2C%0D%0A++occupation%2C%0D%0A++employer%2C%0D%0A++receipts.city+||+%27%2C+%27+||+receipts.state+||+%27+%27+||+receipts.zipcode+AS+city_state_zip%2C%0D%0A++filed_doc_id%2C%0D%0A++doc_name%0D%0Afrom%0D%0A++committee_candidate_links%0D%0A++inner+join+committees+on+committee_candidate_links.committee_id+%3D+committees.id%0D%0A++inner+join+receipts+using+(committee_id)%0D%0A++INNER+JOIN+filed_docs+ON+filed_doc_id+%3D+filed_docs.id%0D%0Awhere%0D%0A++candidate_id+%3D+25264%0D%0A++and+type+!%3D+%27Political+Action%27%0D%0A++and+receipts.archived+%3D+0"
});
});
</script>

{% endblock %}

0 comments on commit 8e1be59

Please sign in to comment.