comparison getan/template.py @ 536:a59622c06936

Fix generating reports if no week given unix_week() cannot handle week being None but does so for year. It just assumes the current year in this case, although this only duplicates the initialisation of year with c_year in this context. week being None gives TypeError: unsupported operand type(s) for -: 'NoneType' and 'int' load_entries() handles the case with no week given, thus call it anyhow. This fix makes it possible to invoke scripts/getan-report with a year given but no week and seeing the expected result (data for a whole year) instead of a traceback.
author Tom Gottfried <tom@intevation.de>
date Thu, 09 Jan 2020 11:32:34 +0100
parents 31ea48bf8a7c
children 28b1c18c900f
comparison
equal deleted inserted replaced
535:d5acadeef0f8 536:a59622c06936
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 # 2 #
3 # (c) 2014 by Björn Ricks <bjoern.ricks@intevation.de> 3 # (c) 2014 by Björn Ricks <bjoern.ricks@intevation.de>
4 # 2017, 2018, 2020 Intevation GmbH
4 # 5 #
5 # This is Free Software licensed under the terms of GPLv3 or later. 6 # This is Free Software licensed under the terms of GPLv3 or later.
6 # For details see LICENSE coming with the source of 'getan'. 7 # For details see LICENSE coming with the source of 'getan'.
7 8
8 # import logging 9 # import logging
106 projects = backend.load_projects() 107 projects = backend.load_projects()
107 else: 108 else:
108 project = backend.load_project(project) 109 project = backend.load_project(project)
109 projects = [project] 110 projects = [project]
110 111
111 if year is not None or week is not None: 112 if week is not None:
112 u_week = "%02d" % unix_week(week, year) 113 u_week = "%02d" % unix_week(week, year)
113 for project in projects: 114
114 project.load_entries(year, u_week) 115 for project in projects:
116 project.load_entries(year, u_week)
115 117
116 if not empty_projects: 118 if not empty_projects:
117 projects = [project for project in projects if project.entries] 119 projects = [project for project in projects if project.entries]
118 120
119 entries = [] 121 entries = []
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)