changeset 360:1b190fa27482

Allow to render only projects with entries in templates
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 03 Mar 2014 14:59:42 +0100
parents 5df363bba5cb
children 2373618e787d
files getan/contrib/getan-eval.py getan/contrib/zeiterfassung.py getan/template.py
diffstat 3 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/getan/contrib/getan-eval.py	Mon Mar 03 14:42:43 2014 +0100
+++ b/getan/contrib/getan-eval.py	Mon Mar 03 14:59:42 2014 +0100
@@ -27,6 +27,9 @@
     parser.add_option("-c", "--lastweek", dest="lastweek",
                       help="entries of last working week",
                       action="store_true")
+    parser.add_option("-m", "--empty", dest="empty",
+                      help="show projects without an entries",
+                      action="store_true")
 
     (options, args) = parser.parse_args()
 
@@ -41,7 +44,7 @@
 
     print render(database=options.database, user=options.user,
                  template=template_name, year=year, week=week,
-                 project=options.project)
+                 project=options.project, empty_projects=options.empty)
 
 
 if __name__ == '__main__':
--- a/getan/contrib/zeiterfassung.py	Mon Mar 03 14:42:43 2014 +0100
+++ b/getan/contrib/zeiterfassung.py	Mon Mar 03 14:59:42 2014 +0100
@@ -91,7 +91,7 @@
     sys.stdout = Writer(sys.stdout)
 
     print render(user=user, database=database, week=week, year=year,
-                 template=template, project=project)
+                 template=template, project=project, empty_projects=empty_proj)
 
 
 if __name__ == '__main__':
--- a/getan/template.py	Mon Mar 03 14:42:43 2014 +0100
+++ b/getan/template.py	Mon Mar 03 14:59:42 2014 +0100
@@ -58,7 +58,7 @@
 
 
 def render(template, database=None, year=None, week=None, project=None,
-           user=None):
+           user=None, empty_projects=True):
     if not user:
         user = os.getenv("USER")
 
@@ -108,6 +108,9 @@
         for project in projects:
             project.load_entries(year, u_week)
 
+    if not empty_projects:
+        projects = [project for project in projects if project.entries]
+
     context = dict()
     context["project"] = project
     context["projects"] = projects
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)