Coverage for cc_modules/cc_reportschema.py: 74%
39 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-15 14:23 +0100
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-15 14:23 +0100
1"""
2camcops_server/cc_modules/cc_reportschema.py
4===============================================================================
6 Copyright (C) 2012, University of Cambridge, Department of Psychiatry.
7 Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
9 This file is part of CamCOPS.
11 CamCOPS is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 CamCOPS is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
24===============================================================================
26**Common reports schema nodes.**
28"""
30from typing import Any, Dict
32from cardinal_pythonlib.colander_utils import BooleanNode
33from colander import SchemaNode
35from camcops_server.cc_modules.cc_forms import RequestAwareMixin
38DEFAULT_BY_YEAR = True
39DEFAULT_BY_MONTH = True
40DEFAULT_BY_DAY_OF_MONTH = False
41DEFAULT_BY_TASK = True
42DEFAULT_BY_USER = False
45class ByYearSelector(BooleanNode, RequestAwareMixin):
46 """
47 Split report by year?
48 """
50 def __init__(self, *args: Any, **kwargs: Any) -> None:
51 super().__init__(*args, default=DEFAULT_BY_YEAR, **kwargs)
53 # noinspection PyUnusedLocal
54 def after_bind(self, node: SchemaNode, kw: Dict[str, Any]) -> None:
55 _ = self.gettext
56 self.title = self.label = _("Split by year?")
59class ByMonthSelector(BooleanNode, RequestAwareMixin):
60 """
61 Split report by month?
62 """
64 def __init__(self, *args: Any, **kwargs: Any) -> None:
65 super().__init__(*args, default=DEFAULT_BY_MONTH, **kwargs)
67 # noinspection PyUnusedLocal
68 def after_bind(self, node: SchemaNode, kw: Dict[str, Any]) -> None:
69 _ = self.gettext
70 self.title = self.label = _("Split by month?")
73class ByDayOfMonthSelector(BooleanNode, RequestAwareMixin):
74 """
75 Split report by day of month?
76 """
78 def __init__(self, *args: Any, **kwargs: Any) -> None:
79 super().__init__(*args, default=DEFAULT_BY_DAY_OF_MONTH, **kwargs)
81 # noinspection PyUnusedLocal
82 def after_bind(self, node: SchemaNode, kw: Dict[str, Any]) -> None:
83 _ = self.gettext
84 self.title = self.label = _("Split by day of month?")
87class ByTaskSelector(BooleanNode, RequestAwareMixin):
88 """
89 Split report by task type?
90 """
92 def __init__(self, *args: Any, **kwargs: Any) -> None:
93 super().__init__(*args, default=DEFAULT_BY_TASK, **kwargs)
95 # noinspection PyUnusedLocal
96 def after_bind(self, node: SchemaNode, kw: Dict[str, Any]) -> None:
97 _ = self.gettext
98 self.title = self.label = _("Split by task type?")
101class ByUserSelector(BooleanNode, RequestAwareMixin):
102 """
103 Split report by user?
104 """
106 def __init__(self, *args: Any, **kwargs: Any) -> None:
107 super().__init__(*args, default=DEFAULT_BY_USER, **kwargs)
109 # noinspection PyUnusedLocal
110 def after_bind(self, node: SchemaNode, kw: Dict[str, Any]) -> None:
111 _ = self.gettext
112 self.title = self.label = _("Split by user?")