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

Update built-in date filters. #781

Merged
merged 1 commit into from
Sep 28, 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
15 changes: 14 additions & 1 deletion openfecwebapp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def date_ranges():
"""
today = datetime.date.today()
quarter = math.floor((today.month - 1) / 3)
cycle = current_cycle()
return {
'month': (
today.replace(day=1),
Expand All @@ -91,5 +92,17 @@ def date_ranges():
day=calendar.monthrange(today.year, 12)[1],
month=12,
),
)
),
'cycle': (
datetime.date(
year=cycle - 1,
month=1,
day=1,
),
datetime.date(
year=cycle,
month=12,
day=calendar.monthrange(cycle, 12)[1],
),
),
}
16 changes: 6 additions & 10 deletions templates/macros/filters/date.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@
<legend for="{{ name }}" class="label">{{ label }}</legend>
Copy link
Contributor

Choose a reason for hiding this comment

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

This would change all the date filters, and not just the receipts and disbursements. This filter works well for filings. (If it is too annoying to have both filters now, it can wait until after launch)

<ul>
<li>
<input id="radio-2" name="{{ name }}" type="radio" data-min-date={{ dates['month'][0] | date(fmt='%m-%d-%Y') }} data-max-date={{ dates['month'][1] | date(fmt='%m-%d-%Y') }}>
<label for="radio-2">This month</label>
<input id="radio-1" name="{{ name }}" type="radio" data-min-date={{ dates['year'][0] | date(fmt='%m-%d-%Y') }} data-max-date={{ dates['year'][1] | date(fmt='%m-%d-%Y') }}>
<label for="radio-1">This year</label>
</li>
<li>
<input id="radio-3" name="{{ name }}" type="radio" data-min-date={{ dates['quarter'][0] | date(fmt='%m-%d-%Y') }} data-max-date={{ dates['quarter'][1] | date(fmt='%m-%d-%Y') }}>
<label for="radio-3">This quarter</label>
<input id="radio-2" name="{{ name }}" type="radio" data-min-date={{ dates['cycle'][0] | date(fmt='%m-%d-%Y') }} data-max-date={{ dates['cycle'][1] | date(fmt='%m-%d-%Y') }}>
<label for="radio-2">This cycle</label>
</li>
<li>
<input id="radio-4" name="{{ name }}" type="radio" data-min-date={{ dates['year'][0] | date(fmt='%m-%d-%Y') }} data-max-date={{ dates['year'][1] | date(fmt='%m-%d-%Y') }}>
<label for="radio-4">This year</label>
</li>
<li>
<input id="radio-5" name="{{ name }}" type="radio">
<label for="radio-5">Custom</label>
<input id="radio-3" name="{{ name }}" type="radio">
<label for="radio-3">Custom</label>
</li>
</ul>
<div class="date-range-input">
Expand Down