From abfc1005db0f256ca60823f61b8a904304eb9a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Fri, 12 Apr 2013 01:32:37 +0200 Subject: In Flask/Jinja: Show / Categories --- templates/404.jinja | 3 +- templates/menu.jinja | 8 ++--- templates/page.jinja | 16 +++++----- templates/pages/cats.jinja | 22 ++++++++++++++ templates/pages/cats.mako | 22 -------------- templates/pages/show.jinja | 59 +++++++++++++++++++++++++++++++++++++ templates/pages/show.mako | 73 ---------------------------------------------- templates/root.jinja | 2 +- 8 files changed, 96 insertions(+), 109 deletions(-) create mode 100644 templates/pages/cats.jinja delete mode 100644 templates/pages/cats.mako create mode 100644 templates/pages/show.jinja delete mode 100644 templates/pages/show.mako (limited to 'templates') diff --git a/templates/404.jinja b/templates/404.jinja index c802610..aeab58d 100644 --- a/templates/404.jinja +++ b/templates/404.jinja @@ -1,6 +1,7 @@ {% extends "page.jinja" %} {% set title = "404 -- Seite konnte nicht gefunden werden!" %} -{% set heading = "404 -- Seite nicht gefunden" %} + +{% block heading %}404 -- Seite nicht gefunden{% endblock %} {% block content %}

diff --git a/templates/menu.jinja b/templates/menu.jinja index b96d542..bf7045a 100644 --- a/templates/menu.jinja +++ b/templates/menu.jinja @@ -1,7 +1,7 @@ {% set menu = [ ("index", "Kosten"), - ("addExp", "Neu"),] %} - {# ("/const", "Konstante Kosten"), - ("/categories", "Kategorien") + ("expenses.add", "Neu"), + ("consts.all", "Konstante Kosten"), + ("categories.all", "Kategorien") ] -#} +%} diff --git a/templates/page.jinja b/templates/page.jinja index e1f8af7..671f3b2 100644 --- a/templates/page.jinja +++ b/templates/page.jinja @@ -1,27 +1,27 @@ {% extends "root.jinja" %} {# functions #} -{% macro left_arrow(target,label) -%} - +{% macro left_arrow(target,label) %} + {{label}} -{%- endmacro %} +{% endmacro %} -{% macro right_arrow(target,label) -%} - +{% macro right_arrow(target,label) %} + {{label}} -{%- endmacro %} +{% endmacro %} {% macro colorize(fgcolor=None, bgcolor=None, tag='span') -%} {% if not fgcolor and not bgcolor %} {{ caller() }} {% else %} {% set style = "" %} - {% if fgcolor: %}{% set style = style + " color: " + fgcolor %}{% endif %} - {% if bgcolor: %}{% set style = style + " background: " + bgcolor %}{% endif %} + {% if fgcolor: %}{% set style = style ~ " color: " ~ fgcolor %}{% endif %} + {% if bgcolor: %}{% set style = style ~ " background: " ~ bgcolor %}{% endif %} <{{tag}} style="{{style}}">{{caller()}} {% endif %} {% endmacro %} diff --git a/templates/pages/cats.jinja b/templates/pages/cats.jinja new file mode 100644 index 0000000..1a3d88e --- /dev/null +++ b/templates/pages/cats.jinja @@ -0,0 +1,22 @@ +{% extends "page.jinja" %} + +{% block heading %} Kategorien {% endblock %} + +{% block js %} + {{ super() }} + +{% endblock %} + +{% block content %} +

+ + +
+ +{% endblock %} + diff --git a/templates/pages/cats.mako b/templates/pages/cats.mako deleted file mode 100644 index 0f71921..0000000 --- a/templates/pages/cats.mako +++ /dev/null @@ -1,22 +0,0 @@ -<%inherit file="/page.mako" /> - -
- - - -
- - -<%block name="heading"> - Kategorien - - -<%block name="js"> - ${parent.js()} - - diff --git a/templates/pages/show.jinja b/templates/pages/show.jinja new file mode 100644 index 0000000..e7d340e --- /dev/null +++ b/templates/pages/show.jinja @@ -0,0 +1,59 @@ +{% extends "page.jinja" %} + +{% block heading %} + {% if exps | length > 1 %} + Aktuelle Kosten + {% else %} + Kosten für {{exps[0]|date}} + {% endif %} +{% endblock %} + +{% block js %} + {{ super() }} + +{% endblock %} + +{% block content %} + {% for e in exps %} + {% if exps | length > 1 %}

{{e|date}}

{% endif %} + {% for c in e.catexps | sort(attribute="cat.name") %} + {% call(exp) detail(name=c.cat.name, sum=c.expense, set=c.all) %} + {{exp.day}}.{{exp.month}}. -- {{exp.description}}: {{exp.expense | eur }} + {% endcall %} + {% endfor %} + + {% call(exp) detail(name="Constant", sum=e.constsum, set=e.consts) %} + {{exp.monthly}} -- {{exp.description}} + {% endcall %} + + {% call(exp) detail(name="In Summa", sum=e.sum, set=e.all, color="#ff2d2d") %} + {{exp.day}}.{{exp.month}}. -- {{exp.description}}: {{exp.expense | eur}} + {% endcall %} +
+ {% endfor %} + + {% set d = prev_date(exps | last) %} + {{ left_arrow(url_for(".show_date", **d), d | date) }} + + {% if not is_last %} + {% set d = next_date(exps | last) %} + {{ right_arrow(url_for(".show_date", **d), d | date) }} + {% endif %} +{% endblock content %} + +{% macro detail(name, sum, set, color=None) %} +
+ + {% call colorize(fgcolor=color) %} + {{name}}: {{sum | eur}}
+ {% endcall %} +
+
    + {% for exp in set %} +
  • {{ caller(exp) }}
  • + {% endfor %} +
+
+
+{% endmacro %} + diff --git a/templates/pages/show.mako b/templates/pages/show.mako deleted file mode 100644 index 06a9915..0000000 --- a/templates/pages/show.mako +++ /dev/null @@ -1,73 +0,0 @@ -<%inherit file="/page.mako" /> - -% for e in exps: - % if len(exps) > 1: -

${get_d(e)}

- % endif - % for c in sorted(e.catexps, key = lambda c: c.cat.name): - <%self:detail name="${c.cat.name}" sum="${c.expense}" set="${c.all}" args="exp"> - ${exp.day}.${exp.month}. -- ${exp.description}: ${exp.expense | eur} - - % endfor - - <%self:detail name="Constant" sum="${e.constsum}" set="${e.consts}" args="exp"> - ${exp.monthly} -- ${exp.description} - - - <%self:detail name="In Summa" sum="${e.sum}" set="${e.all}" args="exp" color="#ff2d2d"> - ${exp.day}.${exp.month}. -- ${exp.description}: ${exp.expense | eur} - -
-% endfor - -<% - if e.date.month == 1: - date = "%s/12" % (e.date.year - 1) - else: - date = "%s/%s" % (e.date.year, e.date.month - 1) -%> -${self.left_arrow(date, date)} - -% if not is_last: - <% - if e.date.month == 13 - len(exps): - date = "%s/1" % (e.date.year + 1) - else: - date = "%s/%s" % (e.date.year, e.date.month + len(exps)) - %> - ${self.right_arrow(date, date)} -% endif - -<%block name="heading"> - % if len(exps) > 1: - Aktuelle Kosten - % else: - Kosten für ${get_d(exps[0])} - % endif - - -<%def name="get_d(e)"> - ${e.date.year}/${e.date.month} - - -<%block name="js"> - ${parent.js()} - - - -<%def name="detail(name, sum, set, color=None)"> -
- - <%self:colorize fgcolor="${color}"> - ${name}: ${sum | eur}
- -
-
    - % for exp in set: -
  • ${caller.body(exp)}
  • - % endfor -
-
-
- - diff --git a/templates/root.jinja b/templates/root.jinja index b17ac92..dcddc33 100644 --- a/templates/root.jinja +++ b/templates/root.jinja @@ -39,7 +39,7 @@
-

{{ heading }}

+

{% block heading -%}{%- endblock %}

{% block content %}{% endblock %}
-- cgit v1.2.3