summaryrefslogtreecommitdiff
path: root/app/views/consts.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/views/consts.py16
1 files changed, 9 insertions, 7 deletions
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)