Coverage for cc_modules/cc_reportschema.py: 76%
33 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-08 23:14 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-08 23:14 +0000
1#!/usr/bin/env python
3"""
4camcops_server/cc_modules/cc_reportschema.py
6===============================================================================
8 Copyright (C) 2012, University of Cambridge, Department of Psychiatry.
9 Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
11 This file is part of CamCOPS.
13 CamCOPS is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
18 CamCOPS is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
26===============================================================================
28**Common reports schema nodes.**
30"""
32from typing import Any, Dict
34from cardinal_pythonlib.colander_utils import BooleanNode
35from colander import SchemaNode
37from camcops_server.cc_modules.cc_forms import RequestAwareMixin
40DEFAULT_BY_YEAR = True
41DEFAULT_BY_MONTH = True
42DEFAULT_BY_TASK = True
43DEFAULT_BY_USER = False
46class ByYearSelector(BooleanNode, RequestAwareMixin):
47 """
48 Split report by year?
49 """
51 def __init__(self, *args, **kwargs) -> None:
52 super().__init__(*args, default=DEFAULT_BY_YEAR, **kwargs)
54 # noinspection PyUnusedLocal
55 def after_bind(self, node: SchemaNode, kw: Dict[str, Any]) -> None:
56 _ = self.gettext
57 self.title = self.label = _("Split by year?")
60class ByMonthSelector(BooleanNode, RequestAwareMixin):
61 """
62 Split report by month?
63 """
65 def __init__(self, *args, **kwargs) -> None:
66 super().__init__(*args, default=DEFAULT_BY_MONTH, **kwargs)
68 # noinspection PyUnusedLocal
69 def after_bind(self, node: SchemaNode, kw: Dict[str, Any]) -> None:
70 _ = self.gettext
71 self.title = self.label = _("Split by month?")
74class ByTaskSelector(BooleanNode, RequestAwareMixin):
75 """
76 Split report by task type?
77 """
79 def __init__(self, *args, **kwargs) -> None:
80 super().__init__(*args, default=DEFAULT_BY_TASK, **kwargs)
82 # noinspection PyUnusedLocal
83 def after_bind(self, node: SchemaNode, kw: Dict[str, Any]) -> None:
84 _ = self.gettext
85 self.title = self.label = _("Split by task type?")
88class ByUserSelector(BooleanNode, RequestAwareMixin):
89 """
90 Split report by user?
91 """
93 def __init__(self, *args, **kwargs) -> None:
94 super().__init__(*args, default=DEFAULT_BY_USER, **kwargs)
96 # noinspection PyUnusedLocal
97 def after_bind(self, node: SchemaNode, kw: Dict[str, Any]) -> None:
98 _ = self.gettext
99 self.title = self.label = _("Split by user?")