educommon 3.16.0__py3-none-any.whl → 3.17.0__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.
- educommon/audit_log/utils/__init__.py +32 -0
- {educommon-3.16.0.dist-info → educommon-3.17.0.dist-info}/METADATA +1 -1
- {educommon-3.16.0.dist-info → educommon-3.17.0.dist-info}/RECORD +5 -5
- {educommon-3.16.0.dist-info → educommon-3.17.0.dist-info}/WHEEL +0 -0
- {educommon-3.16.0.dist-info → educommon-3.17.0.dist-info}/top_level.txt +0 -0
@@ -40,6 +40,7 @@ from django.db.transaction import (
|
|
40
40
|
from django.http import (
|
41
41
|
HttpRequest,
|
42
42
|
)
|
43
|
+
|
43
44
|
from m3_django_compat import (
|
44
45
|
get_related,
|
45
46
|
)
|
@@ -52,6 +53,9 @@ from educommon.audit_log.constants import (
|
|
52
53
|
PG_LOCK_ID,
|
53
54
|
SQL_FILES_DIR,
|
54
55
|
)
|
56
|
+
from educommon.logger import (
|
57
|
+
error as logger_error,
|
58
|
+
)
|
55
59
|
from educommon.utils.misc import (
|
56
60
|
cached_property,
|
57
61
|
)
|
@@ -99,6 +103,19 @@ def get_need_to_log_table_names() -> Set[str]:
|
|
99
103
|
return table_names
|
100
104
|
|
101
105
|
|
106
|
+
def get_table_names_for_app_labels(app_labels: Iterable[str]) -> Set[str]:
|
107
|
+
"""Возвращает множество с именами таблиц для указанных приложений."""
|
108
|
+
tables = set()
|
109
|
+
for app_label in app_labels:
|
110
|
+
try:
|
111
|
+
app_config = apps.get_app_config(app_label)
|
112
|
+
tables.update(model._meta.db_table for model in app_config.get_models())
|
113
|
+
except LookupError:
|
114
|
+
continue
|
115
|
+
|
116
|
+
return tables
|
117
|
+
|
118
|
+
|
102
119
|
def update_or_create_tables(need_to_log_table_names: Iterable[str]) -> bool:
|
103
120
|
"""Создаёт записи Table для отслеживаемых таблиц, либо меняет флаг logged.
|
104
121
|
|
@@ -109,6 +126,21 @@ def update_or_create_tables(need_to_log_table_names: Iterable[str]) -> bool:
|
|
109
126
|
need_to_log_table_names = set(need_to_log_table_names)
|
110
127
|
existed_table_names = set(Table.objects.filter(schema='public').values_list('name', flat=True))
|
111
128
|
|
129
|
+
# Таблицы сервисных приложений, которые не должны отслеживаться аудит-логом
|
130
|
+
allowed_service_apps_labels = getattr(settings, 'ALLOWED_SERVICE_APPS_LABELS', [])
|
131
|
+
service_table_names = get_table_names_for_app_labels(allowed_service_apps_labels)
|
132
|
+
|
133
|
+
# Проверка конфликтных таблиц: должны логироваться, но находятся в сервисных приложениях
|
134
|
+
conflicting_tables = need_to_log_table_names & service_table_names
|
135
|
+
if conflicting_tables:
|
136
|
+
tables = ', '.join(sorted(conflicting_tables))
|
137
|
+
error_msg = (
|
138
|
+
f'Невозможно включить логирование для сервисных таблиц: {tables}. '
|
139
|
+
'Исключите их из отслеживания или перенесите таблицы в основную БД.'
|
140
|
+
)
|
141
|
+
logger_error(error_msg)
|
142
|
+
raise ValueError(error_msg)
|
143
|
+
|
112
144
|
to_create_table_names = need_to_log_table_names - existed_table_names
|
113
145
|
to_disable_table_names = existed_table_names - need_to_log_table_names
|
114
146
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: educommon
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.17.0
|
4
4
|
Summary: Общая кодовая база для проектов БЦ Образование
|
5
5
|
Author-email: BARS Group <education_dev@bars-open.ru>
|
6
6
|
Project-URL: Homepage, https://stash.bars-open.ru/projects/EDUBASE/repos/educommon/browse
|
@@ -70,7 +70,7 @@ educommon/audit_log/migrations/0009_reinstall_audit_log.py,sha256=c95H2yamWyrCoG
|
|
70
70
|
educommon/audit_log/migrations/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
71
71
|
educommon/audit_log/sql/configure_audit_log.sql,sha256=M3QxNKTZbn-uNRxGDvNxE9iJh1EOQUTIho7rvc3yhlY,1511
|
72
72
|
educommon/audit_log/sql/install_audit_log.sql,sha256=SHrZ7WaYxawUKQEpZnj9k4HTU25NvBlxX_POqZ95HU0,14107
|
73
|
-
educommon/audit_log/utils/__init__.py,sha256=
|
73
|
+
educommon/audit_log/utils/__init__.py,sha256=14BHRbKdnvHNgomM-R__GqLk1N32ww_GN2xy81Ph_gs,16388
|
74
74
|
educommon/audit_log/utils/operations.py,sha256=skxL7wE4Jx1XlNdPx-Pl3SfiZ1G9jBmcZrXKSQDUGzw,2555
|
75
75
|
educommon/auth/__init__.py,sha256=xkGJgqQ5QaEU86n6tJV77ux-2bMTAKbjpVYBCDhcS0E,79
|
76
76
|
educommon/auth/rbac/__init__.py,sha256=guO7sOX6e1Z-dqptsqXjbnMdgbSdKp2suDKJa5_pdVU,317
|
@@ -349,7 +349,7 @@ educommon/ws_log/smev/exceptions.py,sha256=VNfzNHlj5Pz8D4979d_msTkxC-RQVoMctsgoJ
|
|
349
349
|
educommon/ws_log/templates/report/smev_logs.xlsx,sha256=nnYgB0Z_ix8HoxsRICjsZfFRQBdra-5Gd8nWhCxTjYg,10439
|
350
350
|
educommon/ws_log/templates/ui-js/smev-logs-list-window.js,sha256=AGup3D8GTJSY9WdDPj0zBJeYQBFOmGgcbxPOJbKK-nY,513
|
351
351
|
educommon/ws_log/templates/ui-js/smev-logs-report-setting-window.js,sha256=nQ7QYK9frJcE7g7kIt6INg9TlEEJAPPayBJgRaoTePA,1103
|
352
|
-
educommon-3.
|
353
|
-
educommon-3.
|
354
|
-
educommon-3.
|
355
|
-
educommon-3.
|
352
|
+
educommon-3.17.0.dist-info/METADATA,sha256=XU8hoY7CgSTjP2GH8wgaRb1EHhjRQYyCdI69uYHmmk8,2380
|
353
|
+
educommon-3.17.0.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
354
|
+
educommon-3.17.0.dist-info/top_level.txt,sha256=z5fbW7bz_0V1foUm_FGcZ9_MTpW3N1dBN7-kEmMowl4,10
|
355
|
+
educommon-3.17.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|