summaryrefslogtreecommitdiff
path: root/app/views/expenses.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/expenses.py')
-rw-r--r--app/views/expenses.py34
1 files changed, 16 insertions, 18 deletions
diff --git a/app/views/expenses.py b/app/views/expenses.py
index 400876c..269d9bb 100644
--- a/app/views/expenses.py
+++ b/app/views/expenses.py
@@ -1,4 +1,4 @@
-from flask import Blueprint
+from ..flask_extend import Blueprint
from flask import render_template, request, url_for, redirect
import datetime, decimal
@@ -26,25 +26,23 @@ def calc_month_exp(year, month):
return MonthExpense(datetime.date(year, month, 1), exps)
-@mod.context_processor
-def inject_funs():
- def prev_date(exp):
- if exp.date.month == 1:
- return { "year": exp.date.year - 1, "month": 12 }
- else:
- return { "year": exp.date.year, "month": exp.date.month - 1 }
-
- def next_date(exp):
- if exp.date.month == 12:
- return { "year": exp.date.year + 1, "month": 1 }
- else:
- return { "year": exp.date.year, "month": exp.date.month + 1}
-
- def is_last(exp):
- return exp.date >= datetime.date.today().replace(day = 1)
+@mod.app_template_filter()
+def prev_date(exp):
+ if exp.date.month == 1:
+ return { "year": exp.date.year - 1, "month": 12 }
+ else:
+ return { "year": exp.date.year, "month": exp.date.month - 1 }
+@mod.app_template_filter()
+def next_date(exp):
+ if exp.date.month == 12:
+ return { "year": exp.date.year + 1, "month": 1 }
+ else:
+ return { "year": exp.date.year, "month": exp.date.month + 1}
- return { 'prev_date' : prev_date, 'next_date' : next_date, 'is_last': is_last }
+@mod.app_template_test("last_date")
+def is_last(exp):
+ return exp.date >= datetime.date.today().replace(day = 1)
@mod.app_template_filter("date")
def format_date(s):