diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2013-04-14 21:00:24 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2013-04-14 21:00:24 +0200 |
commit | 18f0c3c367a4dd53aff163f717bb62fb661e8600 (patch) | |
tree | a9f28ed969d7332efe9ca281cde99a25d263bef6 /app/views/expenses.py | |
parent | a98445a75c3ac2a46540eee146129f7c77e005d5 (diff) | |
download | kosten-18f0c3c367a4dd53aff163f717bb62fb661e8600.tar.gz kosten-18f0c3c367a4dd53aff163f717bb62fb661e8600.tar.bz2 kosten-18f0c3c367a4dd53aff163f717bb62fb661e8600.zip |
Backport @app.template_test; make the functions in expenses filters/tests
Diffstat (limited to '')
-rw-r--r-- | app/views/expenses.py | 34 |
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): |