Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin fines datatable page #2533

Closed
wants to merge 19 commits into from
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
5 changes: 4 additions & 1 deletion fec/data/api_caller.py
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ def load_search_results(query, query_type=None):
def load_legal_search_results(query, query_type='all', offset=0, limit=20, **kwargs):
filters = dict((key, value) for key, value in kwargs.items() if value)

if query or query_type in ['advisory_opinions', 'murs', 'adrs']:
if query or query_type in ['advisory_opinions', 'murs', 'adrs', 'admin_fines']:
filters['hits_returned'] = limit
filters['type'] = query_type
filters['from_hit'] = offset
@@ -96,6 +96,9 @@ def load_legal_search_results(query, query_type='all', offset=0, limit=20, **kwa
if 'adrs' in results:
results['adrs_returned'] = len(results['adrs'])

if 'admin_fines' in results:
results['admin_fines_returned'] = len(results['admin_fines'])

return results


1 change: 1 addition & 0 deletions fec/fec/settings/base.py
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@
'radform': bool(env.get_credential('FEC_FEATURE_RADFORM', '')),
'linecharts': bool(env.get_credential('FEC_FEATURE_LINECHARTS', '')),
'adrs': bool(env.get_credential('FEC_FEATURE_ADRS', '')),
'afs': bool(env.get_credential('FEC_FEATURE_AFS', '')),
}

ENVIRONMENTS = {
2 changes: 1 addition & 1 deletion fec/fec/tests/js/date-filter.js
Original file line number Diff line number Diff line change
@@ -175,7 +175,7 @@ describe('date filter', function() {
});

it('sets the min date to the first of the min year', function() {
expect(this.filter.$minDate.val()).to.equal('01/01/2017');
expect(this.filter.$minDate.val()).to.equal('01/01/2018');
});

it('sets the max date to today if max year is this year', function() {
47 changes: 47 additions & 0 deletions fec/legal/templates/legal-search-results-afs.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends "layouts/legal-doc-search-results.jinja" %}
{% import 'macros/legal.jinja' as legal %}
{% set document_type_display_name = 'Administrative fines' %}

{% block header %}
<header class="page-header slab slab--primary">
{{ breadcrumb.breadcrumbs('Search results', [('/legal-resources', 'Legal resources'), ('/legal-resources/enforcement', 'Enforcement')]) }}
</header>
{% endblock %}

{% block filters %}
{{ legal.keyword_search(result_type, query) }}
<div class="filter">
<label class="label" for="case_no">Administrative fine number</label>
<input id="case_no" name="case_no" type="text" value="{{ case_no }}">
</div>
<div class="filter">
<label class="label" for="name">Committee name</label>
<input id="af_name" name="af_name" type="text" value="{{ af_name }}">
</div>
<div class="filter">
<button type="submit" class="button button--cta">Apply filters</button>
</div>
{% endblock %}

{% block message %}
<div class="data-container__tags">
<div class="row">
<h3 class="tags__title">Viewing <span class="tags__count">{{ results.total_admin_fines }}</span> filtered results for:</h3>
</div>
</div>
<div class="message message--info u-no-margin-top">
<p>You can search all FEC administrative fine cases using keywords, administrative fine case numbers, names of respondents and more. For additional search filters, you can still search administrative fine cases using our legacy <a href="http://eqs.fec.gov">FEC Enforcement Query System</a>.</p>
</div>
{% endblock %}

{% block results %}
{% with results=results %}

{% include 'partials/legal-search-results-afs.jinja' %}
{% endwith %}

{% with results=results %}
{% include 'partials/legal-pagination.jinja' %}
{% endwith %}

{% endblock %}
44 changes: 44 additions & 0 deletions fec/legal/templates/partials/legal-search-results-afs.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<table class="simple-table simple-table--display">
<thead>
<tr class="simple-table__header">
<th class="simple-table__header-cell cell--50">Case</th>
<th class="simple-table__header-cell">Report year, type</th>
<th class="simple-table__header-cell">Closed date</th>
<th class="simple-table__header-cell">Final civil penalty or fine</th>
</tr>
</thead>
<tbody>
{% for admin_fine in results.admin_fines %}
<tr class="simple-table__row">
<td class="simple-table__cell">
<div class="t-sans">
<i class="icon i-folder icon--inline--left"></i>
<a class="t-bold" title="{{ admin_fine.name }}" href="/data/legal/administrative-fine/{{ admin_fine.no }}">AF #{{ admin_fine.no }}</a><br />
{{ admin_fine.name.upper() }}
{% if admin_fine.highlights %}
<div class="t-sans u-padding--top">Keyword match:</div>
<div class="legal-search-result__hit u-padding--left">
{% for highlight in admin_fine.highlights %}
<span class="t-serif">
{{ highlight|safe }} &hellip;
</span>
{% endfor %}
</div>
{% endif %}
</div>
</td>
<td class="simple-table__cell">
<div class="t-sans">
{{ admin_fine.report_year }}, {{ admin_fine.report_type }}
</div>
</td>
<td class="simple-table__cell">
<div class="t-sans">{{ admin_fine.final_determination_date | date(fmt='%m/%d/%Y') }}</div>
</td>
<td class="simple-table__cell">
<div class="t-sans">{{ "${:,.2f}".format(admin_fine.final_determination_amount) }}</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
5 changes: 5 additions & 0 deletions fec/legal/urls.py
Original file line number Diff line number Diff line change
@@ -28,3 +28,8 @@
r'^data/legal/search/adrs/$', views.legal_doc_search_adr
),

if settings.FEATURES['afs']:
urlpatterns += url(
r'^data/legal/search/admin_fines/$', views.legal_doc_search_af
),

18 changes: 18 additions & 0 deletions fec/legal/views.py
Original file line number Diff line number Diff line change
@@ -149,6 +149,24 @@ def legal_doc_search_adr(request):
'query': query
})

def legal_doc_search_af(request):
results = {}
query = request.GET.get('search', '')
offset = request.GET.get('offset', 0)
case_no = request.GET.get('case_no', '')
af_name = request.GET.get('af_name', '')
af_election_cycles = request.GET.get('af_election_cycles', '')

results = api_caller.load_legal_search_results(query, 'admin_fines', offset=offset, case_no=case_no, af_name=af_name)

return render(request, 'legal-search-results-afs.jinja', {
'parent': 'legal',
'results': results,
'result_type': 'admin_fines',
'case_no': case_no,
'af_name': af_name,
'query': query
})

def legal_doc_search_regulations(request):
results = {}