summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2013-04-15 00:59:59 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2013-04-15 00:59:59 +0200
commitbcc2e4fcec619078059102dbd5c8172010390a46 (patch)
treed4ad2f8883c090ff57294515852b4d02df8c38a1
parenta5fdb04dca0c88822192b4b5f08b11aa55bb6d7b (diff)
downloadkosten-bcc2e4fcec619078059102dbd5c8172010390a46.tar.gz
kosten-bcc2e4fcec619078059102dbd5c8172010390a46.tar.bz2
kosten-bcc2e4fcec619078059102dbd5c8172010390a46.zip
Some reorganizing
Diffstat (limited to '')
-rw-r--r--app/views/categories.py7
-rw-r--r--app/views/consts.py16
-rw-r--r--app/views/expenses.py9
-rw-r--r--templates/categories/manage.jinja (renamed from templates/pages/cats.jinja)2
-rw-r--r--templates/consts/add.jinja (renamed from templates/pages/constadd.jinja)3
-rw-r--r--templates/consts/edit.jinja (renamed from templates/pages/constedit.jinja)3
-rw-r--r--templates/consts/list.jinja (renamed from templates/pages/constlist.jinja)2
-rw-r--r--templates/consts/show.jinja (renamed from templates/pages/const.jinja)4
-rw-r--r--templates/expenses/add.jinja (renamed from templates/pages/add.jinja)7
-rw-r--r--templates/expenses/edit.jinja14
-rw-r--r--templates/expenses/show.jinja (renamed from templates/pages/show.jinja)4
-rw-r--r--templates/layout.jinja (renamed from templates/root.jinja)0
-rw-r--r--templates/macros.jinja (renamed from templates/page.jinja)2
-rw-r--r--templates/menu.jinja4
-rw-r--r--templates/pages/edit.jinja10
15 files changed, 49 insertions, 38 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)
diff --git a/templates/pages/cats.jinja b/templates/categories/manage.jinja
index 1a3d88e..efa91b6 100644
--- a/templates/pages/cats.jinja
+++ b/templates/categories/manage.jinja
@@ -1,4 +1,4 @@
-{% extends "page.jinja" %}
+{% extends "layout.jinja" %}
{% block heading %} Kategorien {% endblock %}
diff --git a/templates/pages/constadd.jinja b/templates/consts/add.jinja
index 8f878b4..1ddad4a 100644
--- a/templates/pages/constadd.jinja
+++ b/templates/consts/add.jinja
@@ -1,4 +1,5 @@
-{% extends "page.jinja" %}
+{% extends "layout.jinja" %}
+{% from "macros.jinja" import render_form %}
{% block heading %}
Füge neue konstante Ausgabe hinzu
diff --git a/templates/pages/constedit.jinja b/templates/consts/edit.jinja
index c440ecb..b313704 100644
--- a/templates/pages/constedit.jinja
+++ b/templates/consts/edit.jinja
@@ -1,4 +1,5 @@
-{% extends "page.jinja" %}
+{% extends "layout.jinja" %}
+{% from "macros.jinja" import render_form %}
{% block heading %}
Konstante Ausgabe bearbeiten
diff --git a/templates/pages/constlist.jinja b/templates/consts/list.jinja
index ffe121f..68fa1e1 100644
--- a/templates/pages/constlist.jinja
+++ b/templates/consts/list.jinja
@@ -1,4 +1,4 @@
-{% extends "page.jinja" %}
+{% extends "layout.jinja" %}
{% block heading %}
Konstante Kosten
diff --git a/templates/pages/const.jinja b/templates/consts/show.jinja
index 13e8008..c09fc3b 100644
--- a/templates/pages/const.jinja
+++ b/templates/consts/show.jinja
@@ -1,5 +1,5 @@
-{% extends "page.jinja" %}
-
+{% extends "layout.jinja" %}
+{% from "macros.jinja" import left_arrow, right_arrow %}
{% set fmt="%m.%Y" %}
{% block heading %}
diff --git a/templates/pages/add.jinja b/templates/expenses/add.jinja
index 4728e99..de54de3 100644
--- a/templates/pages/add.jinja
+++ b/templates/expenses/add.jinja
@@ -1,4 +1,5 @@
-{% extends "page.jinja" %}
+{% extends "layout.jinja" %}
+{% from "macros.jinja" import render_form %}
{% block heading %}
Neue Ausgabe hinzufügen
@@ -18,8 +19,6 @@
{% block content %}
<form name="add_expense" method="post">
{{ render_form(form) }}
- {% block form_buttons %}
- <input type="submit" name="changeB">
- {% endblock %}
+ <input type="submit" name="changeB">
</form>
{% endblock %}
diff --git a/templates/expenses/edit.jinja b/templates/expenses/edit.jinja
new file mode 100644
index 0000000..c871eb1
--- /dev/null
+++ b/templates/expenses/edit.jinja
@@ -0,0 +1,14 @@
+{% extends "expenses/add.jinja" %}
+{% from "macros.jinja" import render_form %}
+
+{% block heading %}
+ Bearbeite Kosteneintrag
+{% endblock %}
+
+{% block content %}
+ <form name="edit_expense" method="post">
+ {{ render_form(form) }}
+ <input type="submit" name="changeB">
+ <input type="submit" name="deleteB" value="Eintrag löschen" />
+ </form>
+{% endblock %}
diff --git a/templates/pages/show.jinja b/templates/expenses/show.jinja
index 4b5170f..2643ac4 100644
--- a/templates/pages/show.jinja
+++ b/templates/expenses/show.jinja
@@ -1,4 +1,5 @@
-{% extends "page.jinja" %}
+{% extends "layout.jinja" %}
+{% from "macros.jinja" import left_arrow, right_arrow, colorize %}
{% block heading %}
{% if exps | length > 1 %}
@@ -59,4 +60,3 @@
</div>
</div>
{% endmacro %}
-
diff --git a/templates/root.jinja b/templates/layout.jinja
index dcddc33..dcddc33 100644
--- a/templates/root.jinja
+++ b/templates/layout.jinja
diff --git a/templates/page.jinja b/templates/macros.jinja
index c09dcde..9a9f9af 100644
--- a/templates/page.jinja
+++ b/templates/macros.jinja
@@ -1,5 +1,3 @@
-{% extends "root.jinja" %}
-
{# functions #}
{% macro left_arrow(target,label) %}
<a id="left" href="{{target}}">
diff --git a/templates/menu.jinja b/templates/menu.jinja
index bf7045a..9950c96 100644
--- a/templates/menu.jinja
+++ b/templates/menu.jinja
@@ -1,7 +1,7 @@
{% set menu = [
("index", "Kosten"),
("expenses.add", "Neu"),
- ("consts.all", "Konstante Kosten"),
- ("categories.all", "Kategorien")
+ ("consts.list", "Konstante Kosten"),
+ ("categories.manage", "Kategorien")
]
%}
diff --git a/templates/pages/edit.jinja b/templates/pages/edit.jinja
deleted file mode 100644
index c1f4d5b..0000000
--- a/templates/pages/edit.jinja
+++ /dev/null
@@ -1,10 +0,0 @@
-{% extends "pages/add.jinja" %}
-
-{% block heading %}
- Bearbeite Kosteneintrag
-{% endblock %}
-
-{% block form_buttons %}
- <input type="submit" name="changeB" />
- <input type="submit" name="deleteB" value="Eintrag löschen" />
-{% endblock %}