# HG changeset patch # User Bernhard Reiter # Date 1493811358 -7200 # Node ID a499441249af134177b1d1d2d4f8bd9d84861451 # Parent cc56bc1fd56b481eb49a4f9cbb4b22e00c0ff7b1 Fixes sorting by day for templates. * Adds a string attribute 'startisoday' to the Entry object, so it can be used by jinja2's sort and groupby filters. diff -r cc56bc1fd56b -r a499441249af TODO --- a/TODO Wed May 03 12:59:37 2017 +0200 +++ b/TODO Wed May 03 13:35:58 2017 +0200 @@ -7,9 +7,6 @@ 20160912 BER: Better code: states.py: classes EditEntryState and AdjustEntryState have same methods exit() and set_focus(), maybe join them? -20151130 BER: templates/zeiterfassung2: Really sort by date, right now the - sorting it sometimes skewed if the week wraps around the end of the month. - Older: - Create a 'Help-Widget' to give the user an information about all possible diff -r cc56bc1fd56b -r a499441249af getan/project.py --- a/getan/project.py Wed May 03 12:59:37 2017 +0200 +++ b/getan/project.py Wed May 03 13:35:58 2017 +0200 @@ -4,6 +4,11 @@ # (c) 2008, 2009, 2010 by # Sascha L. Teichmann # Ingo Weinzierl +# (c) 2017 by Intevation GmbH +# Authors: +# * Sascha L. Teichmann +# * Ingo Weinzierl +# ' Bernhard Reiter # # This is Free Software licensed unter the terms of GPLv3 or later. # For details see LICENSE coming with the source of 'getan'. @@ -92,6 +97,11 @@ self.desc = desc self.workpackage = "-" + # we add this attribute for use in jinja2 templates, + # as filters like sort() or groupby() work only on attributes + # and sorting or grouping by day is common for reporting + self.startisoday = start.date().isoformat() + # carefully handle non unicode string # urwid seems to have some issue with plain str if self.desc and not isinstance(self.desc, unicode): diff -r cc56bc1fd56b -r a499441249af getan/templates/zeiterfassung2 --- a/getan/templates/zeiterfassung2 Wed May 03 12:59:37 2017 +0200 +++ b/getan/templates/zeiterfassung2 Wed May 03 13:35:58 2017 +0200 @@ -1,7 +1,7 @@ {% for proj in projects %} {%- if proj.entries %} ## category: {{ proj.key }} ({{ proj.desc }}) -{% for grouper, gentries in proj.entries|sort(attribute='start')|groupby('start.day') %} +{% for grouper, gentries in proj.entries|sort(attribute='startisoday')|groupby('startisoday') %} {#- grouper will contain the attribute used for groupby() -#} {% for ggrouper, ggentries in gentries|groupby('workpackage') %}