diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2013-04-15 00:59:59 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2013-04-15 00:59:59 +0200 |
commit | bcc2e4fcec619078059102dbd5c8172010390a46 (patch) | |
tree | d4ad2f8883c090ff57294515852b4d02df8c38a1 /app/views | |
parent | a5fdb04dca0c88822192b4b5f08b11aa55bb6d7b (diff) | |
download | kosten-bcc2e4fcec619078059102dbd5c8172010390a46.tar.gz kosten-bcc2e4fcec619078059102dbd5c8172010390a46.tar.bz2 kosten-bcc2e4fcec619078059102dbd5c8172010390a46.zip |
Some reorganizing
Diffstat (limited to '')
-rw-r--r-- | app/views/categories.py | 7 | ||||
-rw-r--r-- | app/views/consts.py | 16 | ||||
-rw-r--r-- | app/views/expenses.py | 9 |
3 files changed, 20 insertions, 12 deletions
diff --git a/app/views/categories.py b/app/views/categories.py index 902959b..e020a11 100644 --- a/app/views/categories.py +++ b/app/views/categories.py @@ -5,8 +5,11 @@ from ..model import Category mod = Blueprint('categories', __name__) +def T(tpl): + return "categories/%s.jinja" % tpl + @mod.route("/") -def all (): +def manage (): categories = Category.query.order_by(Category.name).all() - return render_template("pages/cats.jinja", cats = categories) + return render_template(T("manage"), cats = categories) diff --git a/app/views/consts.py b/app/views/consts.py index f1e4ebd..a4980fb 100644 --- a/app/views/consts.py +++ b/app/views/consts.py @@ -9,6 +9,9 @@ from ..forms import ConstForm, today mod = Blueprint('consts', __name__) +def T(tpl): + return "consts/%s.jinja" % tpl + def const_form(cur=None, obj=None): obj = cur if obj is None else obj form = ConstForm(obj=obj) @@ -27,9 +30,8 @@ def const_form(cur=None, obj=None): return form - @mod.route("/") -def all (): +def list (): d = today() expenses = ConstExpense.query.order_by(ConstExpense.start).all() @@ -47,11 +49,11 @@ def all (): else: future.append(e) - return render_template("pages/constlist.jinja", current = current, old = old, future = future) + return render_template(T("list"), current = current, old = old, future = future) @mod.route("/<int:id>") def show(id): - return render_template("pages/const.jinja", exp = ConstExpense.get(id)) + return render_template(T("show"), exp = ConstExpense.get(id)) @mod.route("/edit/<int:id>", methods=("GET", "POST")) def edit(id): @@ -62,14 +64,14 @@ def edit(id): if "deleteB" in request.form: db.session.delete(exp) db.session.commit() - return redirect(url_for(".all")) + return redirect(url_for(".list")) elif form.validate(): # change form.populate_obj(exp) db.session.commit() return redirect(url_for(".show", id = exp.id)) - return render_template("pages/constedit.jinja", form=form) + return render_template(T("edit"), form=form) @mod.route("/add/from/<int:other>") def add_from(other): @@ -100,4 +102,4 @@ def add (form=None): db.session.commit() return redirect(url_for(".show", id = exp.id)) - return render_template("pages/constadd.jinja", form = form) + return render_template(T("add"), form = form) diff --git a/app/views/expenses.py b/app/views/expenses.py index 512c906..56b7452 100644 --- a/app/views/expenses.py +++ b/app/views/expenses.py @@ -10,6 +10,9 @@ from ..forms import ExpenseForm mod = Blueprint('expenses', __name__) +def T(tpl): + return "expenses/%s.jinja" % tpl + def expense_form(obj=None): form = ExpenseForm(obj=obj) form.category.query = Category.query.order_by(Category.name) @@ -61,14 +64,14 @@ def show(): else: second = calc_month_exp(d.year, d.month - 1) - return render_template("pages/show.jinja", exps = [first, second]) + return render_template(T("show"), exps = [first, second]) @mod.route("/edit/<int:id>", methods=("GET", "POST")) def edit(id): exp = SingleExpense.get(id) form = expense_form(exp) - ret = lambda: render_template("pages/edit.jinja", form=form) + ret = lambda: render_template(T("edit"), form=form) if request.method == "POST": if "deleteB" in request.form: @@ -99,4 +102,4 @@ def add(): return redirect(url_for("index")) - return render_template("pages/add.jinja", form=form) + return render_template(T("add"), form=form) |