edupsyadmin 10.2.1__tar.gz → 10.2.2__tar.gz
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.
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/PKG-INFO +1 -1
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/pyproject.toml +4 -1
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/pyproject.toml.orig +4 -1
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/__version__.py +1 -1
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/fill_form.py +1 -1
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/new_client.py +128 -91
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/README.md +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/__init__.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/__main__.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic/README +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic/env.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic/script.py.mako +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic/versions/2026_02_21_0453-4087c43f0c7c_initial_migration.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic/versions/2026_03_02_1222-635a9d68fbe8_add_case_active_column_to_clients.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic/versions/2026_03_13_0545-ea4c3f900604_encrypt_class_columns.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic/versions/2026_03_13_0620-515a72d06f10_encrypt_derived_dates.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic/versions/2026_03_16_0900-d7e8f9a0b1c2_add_metadata_table.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic/versions/2026_03_23_1030-e2b4c6d8f0a1_encrypt_sensitive_text_fields.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic/versions/2026_04_10_1200-f3a5b7c9d1e2_set_encrypted_text_fields_non_nullable.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic/versions/2026_06_12_0509-0f1497df963e_add_class_int_override.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic/versions/2026_09_09_1057-91edbee23274_add_record_academic_year.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/alembic.ini +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/__init__.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/cft_report.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/client_view.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/display_client_details.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/exceptions.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/flatten_pdf.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/flattening/__init__.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/flattening/api.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/flattening/base.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/flattening/pypdf_backend.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/lgvt.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/managers.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/migration.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/migration_fs.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/reports.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/setup_demo.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/taetigkeitsbericht_from_db.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/api/types.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/__init__.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/__main__.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/check_shredding.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/copy_client.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/create_documentation.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/delete_client.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/edit_config.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/flatten_pdfs.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/get_clients.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/info.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/mk_report.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/rotate_key.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/set_client.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/setup_demo.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/taetigkeitsbericht.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/tui.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/utils.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/core/__init__.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/core/config.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/core/encrypt.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/core/enums.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/core/logger.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/core/paths.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/data/Faecher_BfsEV.txt +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/data/Faecher_BfsKi.txt +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/data/Faecher_Faks.txt +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/data/LiberationSans-Bold.ttf +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/data/LiberationSans-Regular.ttf +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/data/OFL.txt +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/data/sampleconfig.yml +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/data/taetigkeitsbericht_categories.csv +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/db/__init__.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/db/clients.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/db/column_types.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/db/converters.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/info.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/py.typed +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/__init__.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/clients_overview.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/clients_overview_app.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/dialogs.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/edit_client.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/edit_client_app.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/editconfig.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/editconfig.tcss +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/editconfig_app.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/edupsyadmintui.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/edupsyadmintui.tcss +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/fill_form_app.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/fill_form_widget.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/tui/suggesters.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/utils/__init__.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/utils/academic_year.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/utils/convert_measures.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/utils/datediff.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/utils/int_from_str.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/utils/path_utils.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/utils/python_type.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/utils/rounding.py +0 -0
- {edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/utils/taetigkeitsbericht_check_key.py +0 -0
|
@@ -4,7 +4,7 @@ requires = ["uv-build>=0.13.6,<0.14"]
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "edupsyadmin"
|
|
7
|
-
version = "10.2.
|
|
7
|
+
version = "10.2.2"
|
|
8
8
|
description = "edupsyadmin provides tools to help school psychologists with their documentation"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.15"
|
|
@@ -73,6 +73,9 @@ dev = [
|
|
|
73
73
|
[tool.uv]
|
|
74
74
|
exclude-newer = "3d"
|
|
75
75
|
|
|
76
|
+
[tool.uv.extra-build-variables.pyyaml]
|
|
77
|
+
PYYAML_FORCE_LIBYAML = "0"
|
|
78
|
+
|
|
76
79
|
[tool.ruff.lint]
|
|
77
80
|
select = [
|
|
78
81
|
"A",
|
|
@@ -4,7 +4,7 @@ requires = [ "uv-build>=0.13.6,<0.14" ]
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "edupsyadmin"
|
|
7
|
-
version = "10.2.
|
|
7
|
+
version = "10.2.2"
|
|
8
8
|
description = "edupsyadmin provides tools to help school psychologists with their documentation"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -62,6 +62,9 @@ dev = [
|
|
|
62
62
|
|
|
63
63
|
[tool.uv]
|
|
64
64
|
exclude-newer = "3d"
|
|
65
|
+
# TODO: remove this workaround when pyyaml wheels for 3.15 are released
|
|
66
|
+
# This line is still necessary for commitizen which depends on pyyaml
|
|
67
|
+
extra-build-variables.pyyaml = { PYYAML_FORCE_LIBYAML = "0" }
|
|
65
68
|
|
|
66
69
|
[tool.ruff]
|
|
67
70
|
lint.select = [
|
|
@@ -243,7 +243,7 @@ def write_form_md(fn: Path, out_fn: Path, data: Mapping[str, Any]) -> None:
|
|
|
243
243
|
raise
|
|
244
244
|
|
|
245
245
|
try:
|
|
246
|
-
msg = template.render(
|
|
246
|
+
msg = template.render(data)
|
|
247
247
|
except LiquidError as e:
|
|
248
248
|
e.add_note(
|
|
249
249
|
"The template could be parsed, but there was an issue with "
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import textwrap
|
|
3
3
|
from argparse import ArgumentParser, Namespace
|
|
4
|
-
from datetime import datetime
|
|
5
4
|
from inspect import signature
|
|
6
|
-
from typing import TYPE_CHECKING, Any
|
|
7
5
|
|
|
8
6
|
from sqlalchemy import inspect as sa_inspect
|
|
9
7
|
lazy import pandas as pd
|
|
@@ -12,10 +10,6 @@ from edupsyadmin.core.config import config
|
|
|
12
10
|
from edupsyadmin.core.logger import logger
|
|
13
11
|
from edupsyadmin.db import clients
|
|
14
12
|
from edupsyadmin.utils.path_utils import normalize_path
|
|
15
|
-
|
|
16
|
-
if TYPE_CHECKING:
|
|
17
|
-
from edupsyadmin.api.managers import ClientsManager
|
|
18
|
-
|
|
19
13
|
lazy from edupsyadmin.api.managers import ClientsManager
|
|
20
14
|
lazy from edupsyadmin.tui.edit_client_app import EditClientApp
|
|
21
15
|
|
|
@@ -36,29 +30,10 @@ COMMAND_EPILOG = textwrap.dedent(
|
|
|
36
30
|
--names "Client1Name" "Client2Name" --school MySchool --keep-file
|
|
37
31
|
""",
|
|
38
32
|
)
|
|
33
|
+
_CITY_COLUMNS = frozenset({"postCode", "city"})
|
|
39
34
|
|
|
40
35
|
|
|
41
|
-
def
|
|
42
|
-
clients_manager: ClientsManager,
|
|
43
|
-
csv_path: str | os.PathLike[str],
|
|
44
|
-
school: str | None,
|
|
45
|
-
name: list[str],
|
|
46
|
-
import_config_name: str | None = None,
|
|
47
|
-
) -> int:
|
|
48
|
-
"""
|
|
49
|
-
Read client(s) from a csv file and add them to the database.
|
|
50
|
-
|
|
51
|
-
:param clients_manager: a ClientsManager instance used to add the client to the db
|
|
52
|
-
:param csv_path: path to a csv file
|
|
53
|
-
:param school: short name of the school as set in the config file
|
|
54
|
-
:param name: name(s) of the client(s) as specified in the "name" column of the csv
|
|
55
|
-
:param import_config_name: name of the csv import configuration from the config
|
|
56
|
-
:raises ValueError: if the import config is unknown, the lookup column is
|
|
57
|
-
missing, a name is not found, or no school/name is available
|
|
58
|
-
:return: client_id of the last client that was created
|
|
59
|
-
"""
|
|
60
|
-
client_cls = clients.Client
|
|
61
|
-
|
|
36
|
+
def _get_import_config(import_config_name: str | None) -> tuple[str, dict[str, str]]:
|
|
62
37
|
if import_config_name:
|
|
63
38
|
try:
|
|
64
39
|
import_conf = config.csv_import[import_config_name]
|
|
@@ -86,6 +61,22 @@ def _enter_client_csv(
|
|
|
86
61
|
"address.phone": "telephone2_encr",
|
|
87
62
|
"address.email": "email_encr",
|
|
88
63
|
}
|
|
64
|
+
return separator, column_mapping
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _allowed_client_keys() -> set[str]:
|
|
68
|
+
client_cls = clients.Client
|
|
69
|
+
valid_keys = {c.key for c in sa_inspect(client_cls).column_attrs}
|
|
70
|
+
valid_init_keys = set(signature(client_cls.__init__).parameters)
|
|
71
|
+
return valid_keys | valid_init_keys
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _read_clients_csv(
|
|
75
|
+
csv_path: str | os.PathLike[str],
|
|
76
|
+
import_config_name: str | None,
|
|
77
|
+
) -> tuple[str, pd.DataFrame]:
|
|
78
|
+
"""Read a client csv and apply the column mapping."""
|
|
79
|
+
separator, column_mapping = _get_import_config(import_config_name)
|
|
89
80
|
|
|
90
81
|
# keep_default_na: Empty cells become "" (the defaults used by
|
|
91
82
|
# Client.__init__), and values like "NA" or "Null" stay strings.
|
|
@@ -107,15 +98,6 @@ def _enter_client_csv(
|
|
|
107
98
|
|
|
108
99
|
df = raw_df.rename(columns=column_mapping)
|
|
109
100
|
|
|
110
|
-
# Telephone numbers must be strings so that they can be encrypted.
|
|
111
|
-
for phone_col in ("telephone1_encr", "telephone2_encr"):
|
|
112
|
-
if phone_col in df.columns:
|
|
113
|
-
df[phone_col] = df[phone_col].fillna("").astype(str)
|
|
114
|
-
else:
|
|
115
|
-
logger.warning(
|
|
116
|
-
"No column was mapped to '%s'; it will be left empty.", phone_col
|
|
117
|
-
)
|
|
118
|
-
|
|
119
101
|
# The 'name' column is used for lookup; it may itself have been renamed.
|
|
120
102
|
lookup_col = "name" if "name" in df.columns else column_mapping.get("name", "name")
|
|
121
103
|
if lookup_col not in df.columns:
|
|
@@ -124,24 +106,14 @@ def _enter_client_csv(
|
|
|
124
106
|
f"the column mapping. Available columns: {list(df.columns)}",
|
|
125
107
|
)
|
|
126
108
|
|
|
127
|
-
|
|
128
|
-
if school is None:
|
|
129
|
-
try:
|
|
130
|
-
school = next(iter(config.school))
|
|
131
|
-
except StopIteration:
|
|
132
|
-
raise ValueError(
|
|
133
|
-
"No school passed and none defined in the config."
|
|
134
|
-
) from None
|
|
109
|
+
allowed_keys = _allowed_client_keys()
|
|
135
110
|
|
|
136
|
-
#
|
|
137
|
-
|
|
138
|
-
valid_init_keys = set(signature(client_cls.__init__).parameters)
|
|
139
|
-
allowed_keys = valid_keys | valid_init_keys
|
|
140
|
-
# postCode/city are merged into city_encr below, so they are valid targets.
|
|
111
|
+
# postCode/city (_CITY_COLUMNS) are merged into city_encr later, so
|
|
112
|
+
# they are valid targets.
|
|
141
113
|
unknown_targets = sorted(
|
|
142
114
|
target
|
|
143
115
|
for target in set(column_mapping.values())
|
|
144
|
-
if target not in allowed_keys and target not in
|
|
116
|
+
if target not in allowed_keys and target not in _CITY_COLUMNS
|
|
145
117
|
)
|
|
146
118
|
if unknown_targets:
|
|
147
119
|
logger.debug(
|
|
@@ -149,53 +121,118 @@ def _enter_client_csv(
|
|
|
149
121
|
unknown_targets,
|
|
150
122
|
)
|
|
151
123
|
|
|
152
|
-
|
|
153
|
-
for
|
|
154
|
-
client_series = df[df[lookup_col] == this_name]
|
|
124
|
+
keep = allowed_keys | _CITY_COLUMNS | {lookup_col}
|
|
125
|
+
return lookup_col, df[[col for col in df.columns if col in keep]]
|
|
155
126
|
|
|
156
|
-
if client_series.empty:
|
|
157
|
-
raise ValueError(
|
|
158
|
-
f"The name '{this_name}' was not found in column '{lookup_col}' "
|
|
159
|
-
f"of the CSV file '{csv_path}'.",
|
|
160
|
-
)
|
|
161
127
|
|
|
162
|
-
|
|
128
|
+
def _resolve_school(school: str | None) -> str:
|
|
129
|
+
"""Return the specified school or the first one defined in the config."""
|
|
130
|
+
if school is not None:
|
|
131
|
+
return school
|
|
132
|
+
try:
|
|
133
|
+
return next(iter(config.school))
|
|
134
|
+
except StopIteration:
|
|
135
|
+
raise ValueError("No school passed and none defined in the config.") from None
|
|
163
136
|
|
|
164
|
-
# Combine address fields if they exist
|
|
165
|
-
if "postCode" in client_data and "city" in client_data:
|
|
166
|
-
client_data["city_encr"] = (
|
|
167
|
-
str(client_data.pop("postCode", ""))
|
|
168
|
-
+ " "
|
|
169
|
-
+ str(client_data.pop("city", ""))
|
|
170
|
-
)
|
|
171
137
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
logger.error(
|
|
182
|
-
"Could not parse date '%s' for column '%s'. "
|
|
183
|
-
"Please ensure the format is DD.MM.YYYY.",
|
|
184
|
-
client_data[date_col],
|
|
185
|
-
date_col,
|
|
186
|
-
)
|
|
187
|
-
client_data[date_col] = None
|
|
188
|
-
|
|
189
|
-
client_data["school"] = school
|
|
190
|
-
|
|
191
|
-
final_client_data: dict[str, Any] = {
|
|
192
|
-
str(k): v for k, v in client_data.items() if k in allowed_keys
|
|
193
|
-
}
|
|
194
|
-
client_id = clients_manager.add_client(**final_client_data)
|
|
138
|
+
def _enter_client_csv(
|
|
139
|
+
clients_manager: ClientsManager,
|
|
140
|
+
csv_path: str | os.PathLike[str],
|
|
141
|
+
school: str | None,
|
|
142
|
+
name: list[str],
|
|
143
|
+
import_config_name: str | None = None,
|
|
144
|
+
) -> list[int]:
|
|
145
|
+
"""
|
|
146
|
+
Read client(s) from a csv file and add them to the database.
|
|
195
147
|
|
|
196
|
-
|
|
148
|
+
:param clients_manager: a ClientsManager instance used to add the client to the db
|
|
149
|
+
:param csv_path: path to a csv file
|
|
150
|
+
:param school: short name of the school as set in the config file
|
|
151
|
+
:param name: name(s) of the client(s) as specified in the "name" column of the csv
|
|
152
|
+
:param import_config_name: name of the csv import configuration from the config
|
|
153
|
+
:raises ValueError: if the import config is unknown, the lookup column is
|
|
154
|
+
missing, a name is not found, or no school/name is available
|
|
155
|
+
:return: list of client_ids that were created
|
|
156
|
+
"""
|
|
157
|
+
if not name:
|
|
197
158
|
raise ValueError("No client names were given; nothing was added.")
|
|
198
|
-
|
|
159
|
+
|
|
160
|
+
lookup_col, df = _read_clients_csv(csv_path, import_config_name)
|
|
161
|
+
|
|
162
|
+
# Telephone numbers must be strings so that they can be encrypted.
|
|
163
|
+
for phone_col in ("telephone1_encr", "telephone2_encr"):
|
|
164
|
+
if phone_col in df.columns:
|
|
165
|
+
df[phone_col] = df[phone_col].fillna("").astype(str)
|
|
166
|
+
else:
|
|
167
|
+
logger.warning(
|
|
168
|
+
"No column was mapped to '%s'; it will be left empty.", phone_col
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
school_name = _resolve_school(school)
|
|
172
|
+
|
|
173
|
+
# Resolve every name first so a typo in the last name does not leave
|
|
174
|
+
# the earlier clients half-imported.
|
|
175
|
+
available = set(df[lookup_col])
|
|
176
|
+
missing = [this_name for this_name in name if this_name not in available]
|
|
177
|
+
if missing:
|
|
178
|
+
raise ValueError(
|
|
179
|
+
f"The name(s) {missing} were not found in column '{lookup_col}' "
|
|
180
|
+
f"of the CSV file '{csv_path}'.",
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
# drop_duplicates keeps the first match per name;
|
|
184
|
+
# .loc[name] returns the rows in the order the names were given.
|
|
185
|
+
selected = (
|
|
186
|
+
df.drop_duplicates(subset=lookup_col)
|
|
187
|
+
.set_index(lookup_col, drop=False)
|
|
188
|
+
.loc[name]
|
|
189
|
+
)
|
|
190
|
+
records = _preprocess_client_csv_data(selected, school_name).to_dict(
|
|
191
|
+
orient="records"
|
|
192
|
+
)
|
|
193
|
+
return [
|
|
194
|
+
clients_manager.add_client(**{str(k): v for k, v in record.items()})
|
|
195
|
+
for record in records
|
|
196
|
+
]
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def _preprocess_client_csv_data(df: pd.DataFrame, school: str) -> pd.DataFrame:
|
|
200
|
+
"""Prepare the selected csv rows for ``ClientsManager.add_client``.
|
|
201
|
+
|
|
202
|
+
Merges ``postCode`` and ``city`` into ``city_encr``, parses dates
|
|
203
|
+
(``DD.MM.YYYY``, unparsable values become None), sets the school and drops
|
|
204
|
+
all columns that are not ``Client`` fields.
|
|
205
|
+
|
|
206
|
+
:param df: the selected rows of the csv dataframe
|
|
207
|
+
:param school: short name of the school
|
|
208
|
+
:return: dataframe whose columns are valid ``add_client`` keyword arguments
|
|
209
|
+
"""
|
|
210
|
+
df = df.copy()
|
|
211
|
+
|
|
212
|
+
# Combine address fields if they exist
|
|
213
|
+
if {"postCode", "city"} <= set(df.columns):
|
|
214
|
+
df["city_encr"] = df.pop("postCode") + " " + df.pop("city")
|
|
215
|
+
|
|
216
|
+
# Handle date formatting
|
|
217
|
+
for date_col in ("entry_date_encr", "birthday_encr"):
|
|
218
|
+
if date_col not in df.columns:
|
|
219
|
+
continue
|
|
220
|
+
parsed = pd.to_datetime(df[date_col], format="%d.%m.%Y", errors="coerce")
|
|
221
|
+
failed = parsed.isna()
|
|
222
|
+
for bad_value in df.loc[failed, date_col]:
|
|
223
|
+
if bad_value:
|
|
224
|
+
logger.error(
|
|
225
|
+
"Could not parse date '%s' for column '%s'. "
|
|
226
|
+
"Please ensure the format is DD.MM.YYYY.",
|
|
227
|
+
bad_value,
|
|
228
|
+
date_col,
|
|
229
|
+
)
|
|
230
|
+
df[date_col] = parsed.dt.date.where(~failed, None)
|
|
231
|
+
|
|
232
|
+
df["school"] = school
|
|
233
|
+
|
|
234
|
+
allowed_keys = _allowed_client_keys()
|
|
235
|
+
return df[[col for col in df.columns if col in allowed_keys]]
|
|
199
236
|
|
|
200
237
|
|
|
201
238
|
def add_arguments(parser: ArgumentParser) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/create_documentation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/cli/commands/taetigkeitsbericht.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/data/taetigkeitsbericht_categories.csv
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{edupsyadmin-10.2.1 → edupsyadmin-10.2.2}/src/edupsyadmin/utils/taetigkeitsbericht_check_key.py
RENAMED
|
File without changes
|