month selector for total spend per month section in reports

This commit is contained in:
dandds 2018-09-20 10:38:29 -04:00
parent b2984bc86b
commit 9f7284070e
2 changed files with 21 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import re
import datetime
from flask import current_app as app
from werkzeug.datastructures import FileStorage
@ -72,6 +73,10 @@ def formattedDate(value, formatter="%m/%d/%Y"):
return "-"
def dateFromString(value, formatter="%m/%Y"):
return datetime.datetime.strptime(value, formatter)
def register_filters(app):
app.jinja_env.filters["iconSvg"] = iconSvg
app.jinja_env.filters["dollars"] = dollars
@ -82,3 +87,4 @@ def register_filters(app):
app.jinja_env.filters["findFilter"] = findFilter
app.jinja_env.filters["renderList"] = renderList
app.jinja_env.filters["formattedDate"] = formattedDate
app.jinja_env.filters["dateFromString"] = dateFromString

View File

@ -301,8 +301,21 @@
<div class='spend-table__header'>
<h2 class='spend-table__title'>Total spend per month </h2>
<select name='month' id='month' class='spend-table__month-select'>
<option value='03/2019'>{{ current_month.strftime('%B %Y') }}</option>
<select name='month' id='month' onchange='location = this.value' class='spend-table__month-select'>
{% for m in cumulative_budget["months"] %}
{% set month = m | dateFromString %}
<option
{% if month.month == current_month.month and month.year == current_month.year %}
selected='selected'
{% endif %}
value='{{ url_for("workspaces.workspace_reports",
workspace_id=workspace.id,
month=month.month,
year=month.year) }}'
>
{{ month.strftime('%B %Y') }}
</option>
{% endfor %}
</select>
</div>