ositah 25.6.dev1__py3-none-any.whl → 25.9.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ositah might be problematic. Click here for more details.
- ositah/app.py +17 -17
- ositah/apps/analysis.py +785 -785
- ositah/apps/configuration/callbacks.py +916 -916
- ositah/apps/configuration/main.py +546 -546
- ositah/apps/configuration/parameters.py +74 -74
- ositah/apps/configuration/tools.py +112 -112
- ositah/apps/export.py +1209 -1191
- ositah/apps/validation/callbacks.py +240 -240
- ositah/apps/validation/main.py +89 -89
- ositah/apps/validation/parameters.py +25 -25
- ositah/apps/validation/tables.py +646 -646
- ositah/apps/validation/tools.py +552 -552
- ositah/assets/arrow_down_up.svg +3 -3
- ositah/assets/ositah.css +53 -53
- ositah/assets/sort_ascending.svg +4 -4
- ositah/assets/sort_descending.svg +5 -5
- ositah/assets/sorttable.js +499 -499
- ositah/main.py +449 -449
- ositah/ositah.example.cfg +229 -229
- ositah/static/style.css +53 -53
- ositah/templates/base.html +22 -22
- ositah/templates/bootstrap_login.html +38 -38
- ositah/templates/login_form.html +26 -26
- ositah/utils/agents.py +124 -124
- ositah/utils/authentication.py +287 -287
- ositah/utils/cache.py +19 -19
- ositah/utils/core.py +13 -13
- ositah/utils/exceptions.py +64 -64
- ositah/utils/hito_db.py +51 -51
- ositah/utils/hito_db_model.py +253 -253
- ositah/utils/menus.py +339 -339
- ositah/utils/period.py +139 -139
- ositah/utils/projects.py +1179 -1178
- ositah/utils/teams.py +42 -42
- ositah/utils/utils.py +474 -474
- {ositah-25.6.dev1.dist-info → ositah-25.9.dev2.dist-info}/METADATA +149 -150
- ositah-25.9.dev2.dist-info/RECORD +46 -0
- {ositah-25.6.dev1.dist-info → ositah-25.9.dev2.dist-info}/licenses/LICENSE +29 -29
- ositah-25.6.dev1.dist-info/RECORD +0 -46
- {ositah-25.6.dev1.dist-info → ositah-25.9.dev2.dist-info}/WHEEL +0 -0
- {ositah-25.6.dev1.dist-info → ositah-25.9.dev2.dist-info}/entry_points.txt +0 -0
- {ositah-25.6.dev1.dist-info → ositah-25.9.dev2.dist-info}/top_level.txt +0 -0
ositah/utils/period.py
CHANGED
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
# Module providing functions related to declaration period
|
|
2
|
-
|
|
3
|
-
from datetime import datetime
|
|
4
|
-
from typing import List
|
|
5
|
-
|
|
6
|
-
from ositah.utils.exceptions import ValidationPeriodAmbiguous, ValidationPeriodMissing
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class OSITAHDeclarationPeriod:
|
|
10
|
-
def __init__(self, name: str, start_date: str, end_date: str, validation_date: str):
|
|
11
|
-
self._name = name
|
|
12
|
-
self._start_date = start_date
|
|
13
|
-
self._end_date = end_date
|
|
14
|
-
self._validation_date = validation_date
|
|
15
|
-
|
|
16
|
-
@property
|
|
17
|
-
def name(self):
|
|
18
|
-
return self._name
|
|
19
|
-
|
|
20
|
-
@property
|
|
21
|
-
def dates(self):
|
|
22
|
-
return self.start_date, self.end_date
|
|
23
|
-
|
|
24
|
-
@property
|
|
25
|
-
def label(self):
|
|
26
|
-
return f"{self.name} ({' au '.join(self.dates)})"
|
|
27
|
-
|
|
28
|
-
@property
|
|
29
|
-
def end_date(self):
|
|
30
|
-
return self._end_date
|
|
31
|
-
|
|
32
|
-
@property
|
|
33
|
-
def start_date(self):
|
|
34
|
-
return self._start_date
|
|
35
|
-
|
|
36
|
-
@property
|
|
37
|
-
def validation_date(self):
|
|
38
|
-
return self._validation_date
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def get_validation_period_data(period_date: str):
|
|
42
|
-
"""
|
|
43
|
-
Return the current declaration period object.
|
|
44
|
-
|
|
45
|
-
:param period_date: a date that must be inside the declaration period
|
|
46
|
-
:return: declaration period object (OSITAHValidationPeriod)
|
|
47
|
-
"""
|
|
48
|
-
|
|
49
|
-
from ositah.utils.hito_db_model import OSITAHValidationPeriod
|
|
50
|
-
|
|
51
|
-
selection_date = datetime.fromisoformat(period_date)
|
|
52
|
-
period_id = OSITAHValidationPeriod.query.filter(
|
|
53
|
-
OSITAHValidationPeriod.start_date <= selection_date,
|
|
54
|
-
OSITAHValidationPeriod.end_date >= selection_date,
|
|
55
|
-
).all()
|
|
56
|
-
if len(period_id) == 1:
|
|
57
|
-
return period_id[0]
|
|
58
|
-
elif len(period_id) > 1:
|
|
59
|
-
raise ValidationPeriodAmbiguous(selection_date)
|
|
60
|
-
else:
|
|
61
|
-
raise ValidationPeriodMissing(selection_date)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def get_validation_period_dates(period_date: str):
|
|
65
|
-
"""
|
|
66
|
-
Return the start and end date of the current declaration period.
|
|
67
|
-
|
|
68
|
-
:param period_date: a date that must be inside the declaration period
|
|
69
|
-
:return: UUID
|
|
70
|
-
"""
|
|
71
|
-
|
|
72
|
-
validation_period = get_validation_period_data(period_date)
|
|
73
|
-
return validation_period.start_date, validation_period.end_date
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def get_validation_period_id(period_date: str):
|
|
77
|
-
"""
|
|
78
|
-
Return the current declaration period ID.
|
|
79
|
-
|
|
80
|
-
:param period_date: a date that must be inside the declaration period
|
|
81
|
-
:return: UUID
|
|
82
|
-
"""
|
|
83
|
-
|
|
84
|
-
return get_validation_period_data(period_date).id
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def get_declaration_periods(descending: bool = True) -> List[OSITAHDeclarationPeriod]:
|
|
88
|
-
"""
|
|
89
|
-
Return a list of declaration period name and dates, sorted by start date in descending order.
|
|
90
|
-
Dates are strings, without the time information.
|
|
91
|
-
|
|
92
|
-
:param descending: if True, sort in descending order (default), else in ascending order
|
|
93
|
-
:return: list of OSITAHDeclarationPeriod
|
|
94
|
-
"""
|
|
95
|
-
|
|
96
|
-
from ositah.utils.hito_db_model import OSITAHValidationPeriod
|
|
97
|
-
|
|
98
|
-
periods = []
|
|
99
|
-
|
|
100
|
-
periods_data = OSITAHValidationPeriod.query.order_by(
|
|
101
|
-
OSITAHValidationPeriod.start_date.desc()
|
|
102
|
-
if descending
|
|
103
|
-
else OSITAHValidationPeriod.start_date.asc()
|
|
104
|
-
).all()
|
|
105
|
-
|
|
106
|
-
for row in periods_data:
|
|
107
|
-
periods.append(
|
|
108
|
-
OSITAHDeclarationPeriod(
|
|
109
|
-
row.name,
|
|
110
|
-
row.start_date.date().isoformat(),
|
|
111
|
-
row.end_date.date().isoformat(),
|
|
112
|
-
row.validation_date.date().isoformat(),
|
|
113
|
-
)
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
return periods
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def get_default_period_date(periods: List[OSITAHDeclarationPeriod], date: datetime.date):
|
|
120
|
-
"""
|
|
121
|
-
Return the start date of the default period. The default period is selected by passing a date
|
|
122
|
-
that must be between period start and end dates (included). If none matches, select the last
|
|
123
|
-
period.
|
|
124
|
-
|
|
125
|
-
:param periods: period list
|
|
126
|
-
:param date: date that must be inside the period (string)
|
|
127
|
-
:return: period start date (string) or None if not found
|
|
128
|
-
"""
|
|
129
|
-
|
|
130
|
-
period_date = date.isoformat()
|
|
131
|
-
last_start_date = None
|
|
132
|
-
|
|
133
|
-
for p in periods:
|
|
134
|
-
if period_date >= p.start_date and period_date <= p.end_date:
|
|
135
|
-
return p.start_date
|
|
136
|
-
if last_start_date is None or p.start_date > last_start_date:
|
|
137
|
-
last_start_date = p.start_date
|
|
138
|
-
|
|
139
|
-
return last_start_date
|
|
1
|
+
# Module providing functions related to declaration period
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from typing import List
|
|
5
|
+
|
|
6
|
+
from ositah.utils.exceptions import ValidationPeriodAmbiguous, ValidationPeriodMissing
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class OSITAHDeclarationPeriod:
|
|
10
|
+
def __init__(self, name: str, start_date: str, end_date: str, validation_date: str):
|
|
11
|
+
self._name = name
|
|
12
|
+
self._start_date = start_date
|
|
13
|
+
self._end_date = end_date
|
|
14
|
+
self._validation_date = validation_date
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def name(self):
|
|
18
|
+
return self._name
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def dates(self):
|
|
22
|
+
return self.start_date, self.end_date
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def label(self):
|
|
26
|
+
return f"{self.name} ({' au '.join(self.dates)})"
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def end_date(self):
|
|
30
|
+
return self._end_date
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def start_date(self):
|
|
34
|
+
return self._start_date
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def validation_date(self):
|
|
38
|
+
return self._validation_date
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def get_validation_period_data(period_date: str):
|
|
42
|
+
"""
|
|
43
|
+
Return the current declaration period object.
|
|
44
|
+
|
|
45
|
+
:param period_date: a date that must be inside the declaration period
|
|
46
|
+
:return: declaration period object (OSITAHValidationPeriod)
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
from ositah.utils.hito_db_model import OSITAHValidationPeriod
|
|
50
|
+
|
|
51
|
+
selection_date = datetime.fromisoformat(period_date)
|
|
52
|
+
period_id = OSITAHValidationPeriod.query.filter(
|
|
53
|
+
OSITAHValidationPeriod.start_date <= selection_date,
|
|
54
|
+
OSITAHValidationPeriod.end_date >= selection_date,
|
|
55
|
+
).all()
|
|
56
|
+
if len(period_id) == 1:
|
|
57
|
+
return period_id[0]
|
|
58
|
+
elif len(period_id) > 1:
|
|
59
|
+
raise ValidationPeriodAmbiguous(selection_date)
|
|
60
|
+
else:
|
|
61
|
+
raise ValidationPeriodMissing(selection_date)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def get_validation_period_dates(period_date: str):
|
|
65
|
+
"""
|
|
66
|
+
Return the start and end date of the current declaration period.
|
|
67
|
+
|
|
68
|
+
:param period_date: a date that must be inside the declaration period
|
|
69
|
+
:return: UUID
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
validation_period = get_validation_period_data(period_date)
|
|
73
|
+
return validation_period.start_date, validation_period.end_date
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def get_validation_period_id(period_date: str):
|
|
77
|
+
"""
|
|
78
|
+
Return the current declaration period ID.
|
|
79
|
+
|
|
80
|
+
:param period_date: a date that must be inside the declaration period
|
|
81
|
+
:return: UUID
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
return get_validation_period_data(period_date).id
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def get_declaration_periods(descending: bool = True) -> List[OSITAHDeclarationPeriod]:
|
|
88
|
+
"""
|
|
89
|
+
Return a list of declaration period name and dates, sorted by start date in descending order.
|
|
90
|
+
Dates are strings, without the time information.
|
|
91
|
+
|
|
92
|
+
:param descending: if True, sort in descending order (default), else in ascending order
|
|
93
|
+
:return: list of OSITAHDeclarationPeriod
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
from ositah.utils.hito_db_model import OSITAHValidationPeriod
|
|
97
|
+
|
|
98
|
+
periods = []
|
|
99
|
+
|
|
100
|
+
periods_data = OSITAHValidationPeriod.query.order_by(
|
|
101
|
+
OSITAHValidationPeriod.start_date.desc()
|
|
102
|
+
if descending
|
|
103
|
+
else OSITAHValidationPeriod.start_date.asc()
|
|
104
|
+
).all()
|
|
105
|
+
|
|
106
|
+
for row in periods_data:
|
|
107
|
+
periods.append(
|
|
108
|
+
OSITAHDeclarationPeriod(
|
|
109
|
+
row.name,
|
|
110
|
+
row.start_date.date().isoformat(),
|
|
111
|
+
row.end_date.date().isoformat(),
|
|
112
|
+
row.validation_date.date().isoformat(),
|
|
113
|
+
)
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
return periods
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def get_default_period_date(periods: List[OSITAHDeclarationPeriod], date: datetime.date):
|
|
120
|
+
"""
|
|
121
|
+
Return the start date of the default period. The default period is selected by passing a date
|
|
122
|
+
that must be between period start and end dates (included). If none matches, select the last
|
|
123
|
+
period.
|
|
124
|
+
|
|
125
|
+
:param periods: period list
|
|
126
|
+
:param date: date that must be inside the period (string)
|
|
127
|
+
:return: period start date (string) or None if not found
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
period_date = date.isoformat()
|
|
131
|
+
last_start_date = None
|
|
132
|
+
|
|
133
|
+
for p in periods:
|
|
134
|
+
if period_date >= p.start_date and period_date <= p.end_date:
|
|
135
|
+
return p.start_date
|
|
136
|
+
if last_start_date is None or p.start_date > last_start_date:
|
|
137
|
+
last_start_date = p.start_date
|
|
138
|
+
|
|
139
|
+
return last_start_date
|