arthexis 0.1.13__py3-none-any.whl → 0.1.15__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.
- {arthexis-0.1.13.dist-info → arthexis-0.1.15.dist-info}/METADATA +224 -221
- arthexis-0.1.15.dist-info/RECORD +110 -0
- {arthexis-0.1.13.dist-info → arthexis-0.1.15.dist-info}/licenses/LICENSE +674 -674
- config/__init__.py +5 -5
- config/active_app.py +15 -15
- config/asgi.py +43 -43
- config/auth_app.py +7 -7
- config/celery.py +32 -32
- config/context_processors.py +67 -69
- config/horologia_app.py +7 -7
- config/loadenv.py +11 -11
- config/logging.py +59 -48
- config/middleware.py +25 -25
- config/offline.py +49 -49
- config/settings.py +691 -682
- config/settings_helpers.py +109 -109
- config/urls.py +171 -166
- config/wsgi.py +17 -17
- core/admin.py +3795 -2809
- core/admin_history.py +50 -50
- core/admindocs.py +151 -151
- core/apps.py +356 -272
- core/auto_upgrade.py +57 -57
- core/backends.py +265 -236
- core/changelog.py +342 -0
- core/entity.py +149 -133
- core/environment.py +61 -61
- core/fields.py +168 -168
- core/form_fields.py +75 -75
- core/github_helper.py +188 -25
- core/github_issues.py +178 -172
- core/github_repos.py +72 -0
- core/lcd_screen.py +78 -78
- core/liveupdate.py +25 -25
- core/log_paths.py +114 -100
- core/mailer.py +85 -85
- core/middleware.py +91 -91
- core/models.py +3637 -2795
- core/notifications.py +105 -105
- core/public_wifi.py +267 -227
- core/reference_utils.py +108 -108
- core/release.py +840 -368
- core/rfid_import_export.py +113 -0
- core/sigil_builder.py +149 -149
- core/sigil_context.py +20 -20
- core/sigil_resolver.py +315 -315
- core/system.py +952 -493
- core/tasks.py +408 -394
- core/temp_passwords.py +181 -181
- core/test_system_info.py +186 -139
- core/tests.py +2168 -1521
- core/tests_liveupdate.py +17 -17
- core/urls.py +11 -11
- core/user_data.py +641 -633
- core/views.py +2201 -1417
- core/widgets.py +213 -94
- core/workgroup_urls.py +17 -17
- core/workgroup_views.py +94 -94
- nodes/admin.py +1720 -1161
- nodes/apps.py +87 -85
- nodes/backends.py +160 -160
- nodes/dns.py +203 -203
- nodes/feature_checks.py +133 -133
- nodes/lcd.py +165 -165
- nodes/models.py +1764 -1597
- nodes/reports.py +411 -411
- nodes/rfid_sync.py +195 -0
- nodes/signals.py +18 -0
- nodes/tasks.py +46 -46
- nodes/tests.py +3830 -3116
- nodes/urls.py +15 -14
- nodes/utils.py +121 -105
- nodes/views.py +683 -619
- ocpp/admin.py +948 -948
- ocpp/apps.py +25 -25
- ocpp/consumers.py +1565 -1459
- ocpp/evcs.py +844 -844
- ocpp/evcs_discovery.py +158 -158
- ocpp/models.py +917 -917
- ocpp/reference_utils.py +42 -42
- ocpp/routing.py +11 -11
- ocpp/simulator.py +745 -745
- ocpp/status_display.py +26 -26
- ocpp/store.py +601 -541
- ocpp/tasks.py +31 -31
- ocpp/test_export_import.py +130 -130
- ocpp/test_rfid.py +913 -702
- ocpp/tests.py +4445 -4094
- ocpp/transactions_io.py +189 -189
- ocpp/urls.py +50 -50
- ocpp/views.py +1479 -1251
- pages/admin.py +769 -539
- pages/apps.py +10 -10
- pages/checks.py +40 -40
- pages/context_processors.py +127 -119
- pages/defaults.py +13 -13
- pages/forms.py +198 -198
- pages/middleware.py +209 -153
- pages/models.py +643 -426
- pages/tasks.py +74 -0
- pages/tests.py +3025 -2200
- pages/urls.py +26 -25
- pages/utils.py +23 -12
- pages/views.py +1176 -1128
- arthexis-0.1.13.dist-info/RECORD +0 -105
- nodes/actions.py +0 -70
- {arthexis-0.1.13.dist-info → arthexis-0.1.15.dist-info}/WHEEL +0 -0
- {arthexis-0.1.13.dist-info → arthexis-0.1.15.dist-info}/top_level.txt +0 -0
core/reference_utils.py
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
"""Utility helpers for working with Reference objects."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
from typing import Iterable, TYPE_CHECKING
|
|
6
|
-
|
|
7
|
-
from django.contrib.sites.models import Site
|
|
8
|
-
|
|
9
|
-
if TYPE_CHECKING: # pragma: no cover - imported only for type checking
|
|
10
|
-
from django.http import HttpRequest
|
|
11
|
-
from nodes.models import Node
|
|
12
|
-
from .models import Reference
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def filter_visible_references(
|
|
16
|
-
refs: Iterable["Reference"],
|
|
17
|
-
*,
|
|
18
|
-
request: "HttpRequest | None" = None,
|
|
19
|
-
site: Site | None = None,
|
|
20
|
-
node: "Node | None" = None,
|
|
21
|
-
respect_footer_visibility: bool = True,
|
|
22
|
-
) -> list["Reference"]:
|
|
23
|
-
"""Return references visible for the current context."""
|
|
24
|
-
|
|
25
|
-
if site is None and request is not None:
|
|
26
|
-
try:
|
|
27
|
-
host = request.get_host().split(":")[0]
|
|
28
|
-
except Exception:
|
|
29
|
-
host = ""
|
|
30
|
-
if host:
|
|
31
|
-
site = Site.objects.filter(domain__iexact=host).first()
|
|
32
|
-
|
|
33
|
-
site_id = getattr(site, "pk", None)
|
|
34
|
-
|
|
35
|
-
if node is None:
|
|
36
|
-
try:
|
|
37
|
-
from nodes.models import Node # imported lazily to avoid circular import
|
|
38
|
-
|
|
39
|
-
node = Node.get_local()
|
|
40
|
-
except Exception:
|
|
41
|
-
node = None
|
|
42
|
-
|
|
43
|
-
node_role_id = getattr(node, "role_id", None)
|
|
44
|
-
node_active_feature_ids: set[int] = set()
|
|
45
|
-
if node is not None:
|
|
46
|
-
assignments_manager = getattr(node, "feature_assignments", None)
|
|
47
|
-
if assignments_manager is not None:
|
|
48
|
-
try:
|
|
49
|
-
assignments = list(
|
|
50
|
-
assignments_manager.filter(is_deleted=False).select_related(
|
|
51
|
-
"feature"
|
|
52
|
-
)
|
|
53
|
-
)
|
|
54
|
-
except Exception:
|
|
55
|
-
assignments = []
|
|
56
|
-
for assignment in assignments:
|
|
57
|
-
feature = getattr(assignment, "feature", None)
|
|
58
|
-
if feature is None or getattr(feature, "is_deleted", False):
|
|
59
|
-
continue
|
|
60
|
-
try:
|
|
61
|
-
if feature.is_enabled:
|
|
62
|
-
node_active_feature_ids.add(feature.pk)
|
|
63
|
-
except Exception:
|
|
64
|
-
continue
|
|
65
|
-
|
|
66
|
-
visible_refs: list["Reference"] = []
|
|
67
|
-
for ref in refs:
|
|
68
|
-
required_roles = {role.pk for role in ref.roles.all()}
|
|
69
|
-
required_features = {feature.pk for feature in ref.features.all()}
|
|
70
|
-
required_sites = {current_site.pk for current_site in ref.sites.all()}
|
|
71
|
-
|
|
72
|
-
if required_roles or required_features or required_sites:
|
|
73
|
-
allowed = False
|
|
74
|
-
if required_roles and node_role_id and node_role_id in required_roles:
|
|
75
|
-
allowed = True
|
|
76
|
-
elif (
|
|
77
|
-
required_features
|
|
78
|
-
and node_active_feature_ids
|
|
79
|
-
and node_active_feature_ids.intersection(required_features)
|
|
80
|
-
):
|
|
81
|
-
allowed = True
|
|
82
|
-
elif required_sites and site_id and site_id in required_sites:
|
|
83
|
-
allowed = True
|
|
84
|
-
|
|
85
|
-
if not allowed:
|
|
86
|
-
continue
|
|
87
|
-
|
|
88
|
-
if respect_footer_visibility:
|
|
89
|
-
if ref.footer_visibility == ref.FOOTER_PUBLIC:
|
|
90
|
-
visible_refs.append(ref)
|
|
91
|
-
elif (
|
|
92
|
-
ref.footer_visibility == ref.FOOTER_PRIVATE
|
|
93
|
-
and request
|
|
94
|
-
and request.user.is_authenticated
|
|
95
|
-
):
|
|
96
|
-
visible_refs.append(ref)
|
|
97
|
-
elif (
|
|
98
|
-
ref.footer_visibility == ref.FOOTER_STAFF
|
|
99
|
-
and request
|
|
100
|
-
and request.user.is_authenticated
|
|
101
|
-
and request.user.is_staff
|
|
102
|
-
):
|
|
103
|
-
visible_refs.append(ref)
|
|
104
|
-
else:
|
|
105
|
-
visible_refs.append(ref)
|
|
106
|
-
|
|
107
|
-
return visible_refs
|
|
108
|
-
|
|
1
|
+
"""Utility helpers for working with Reference objects."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Iterable, TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from django.contrib.sites.models import Site
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING: # pragma: no cover - imported only for type checking
|
|
10
|
+
from django.http import HttpRequest
|
|
11
|
+
from nodes.models import Node
|
|
12
|
+
from .models import Reference
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def filter_visible_references(
|
|
16
|
+
refs: Iterable["Reference"],
|
|
17
|
+
*,
|
|
18
|
+
request: "HttpRequest | None" = None,
|
|
19
|
+
site: Site | None = None,
|
|
20
|
+
node: "Node | None" = None,
|
|
21
|
+
respect_footer_visibility: bool = True,
|
|
22
|
+
) -> list["Reference"]:
|
|
23
|
+
"""Return references visible for the current context."""
|
|
24
|
+
|
|
25
|
+
if site is None and request is not None:
|
|
26
|
+
try:
|
|
27
|
+
host = request.get_host().split(":")[0]
|
|
28
|
+
except Exception:
|
|
29
|
+
host = ""
|
|
30
|
+
if host:
|
|
31
|
+
site = Site.objects.filter(domain__iexact=host).first()
|
|
32
|
+
|
|
33
|
+
site_id = getattr(site, "pk", None)
|
|
34
|
+
|
|
35
|
+
if node is None:
|
|
36
|
+
try:
|
|
37
|
+
from nodes.models import Node # imported lazily to avoid circular import
|
|
38
|
+
|
|
39
|
+
node = Node.get_local()
|
|
40
|
+
except Exception:
|
|
41
|
+
node = None
|
|
42
|
+
|
|
43
|
+
node_role_id = getattr(node, "role_id", None)
|
|
44
|
+
node_active_feature_ids: set[int] = set()
|
|
45
|
+
if node is not None:
|
|
46
|
+
assignments_manager = getattr(node, "feature_assignments", None)
|
|
47
|
+
if assignments_manager is not None:
|
|
48
|
+
try:
|
|
49
|
+
assignments = list(
|
|
50
|
+
assignments_manager.filter(is_deleted=False).select_related(
|
|
51
|
+
"feature"
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
except Exception:
|
|
55
|
+
assignments = []
|
|
56
|
+
for assignment in assignments:
|
|
57
|
+
feature = getattr(assignment, "feature", None)
|
|
58
|
+
if feature is None or getattr(feature, "is_deleted", False):
|
|
59
|
+
continue
|
|
60
|
+
try:
|
|
61
|
+
if feature.is_enabled:
|
|
62
|
+
node_active_feature_ids.add(feature.pk)
|
|
63
|
+
except Exception:
|
|
64
|
+
continue
|
|
65
|
+
|
|
66
|
+
visible_refs: list["Reference"] = []
|
|
67
|
+
for ref in refs:
|
|
68
|
+
required_roles = {role.pk for role in ref.roles.all()}
|
|
69
|
+
required_features = {feature.pk for feature in ref.features.all()}
|
|
70
|
+
required_sites = {current_site.pk for current_site in ref.sites.all()}
|
|
71
|
+
|
|
72
|
+
if required_roles or required_features or required_sites:
|
|
73
|
+
allowed = False
|
|
74
|
+
if required_roles and node_role_id and node_role_id in required_roles:
|
|
75
|
+
allowed = True
|
|
76
|
+
elif (
|
|
77
|
+
required_features
|
|
78
|
+
and node_active_feature_ids
|
|
79
|
+
and node_active_feature_ids.intersection(required_features)
|
|
80
|
+
):
|
|
81
|
+
allowed = True
|
|
82
|
+
elif required_sites and site_id and site_id in required_sites:
|
|
83
|
+
allowed = True
|
|
84
|
+
|
|
85
|
+
if not allowed:
|
|
86
|
+
continue
|
|
87
|
+
|
|
88
|
+
if respect_footer_visibility:
|
|
89
|
+
if ref.footer_visibility == ref.FOOTER_PUBLIC:
|
|
90
|
+
visible_refs.append(ref)
|
|
91
|
+
elif (
|
|
92
|
+
ref.footer_visibility == ref.FOOTER_PRIVATE
|
|
93
|
+
and request
|
|
94
|
+
and request.user.is_authenticated
|
|
95
|
+
):
|
|
96
|
+
visible_refs.append(ref)
|
|
97
|
+
elif (
|
|
98
|
+
ref.footer_visibility == ref.FOOTER_STAFF
|
|
99
|
+
and request
|
|
100
|
+
and request.user.is_authenticated
|
|
101
|
+
and request.user.is_staff
|
|
102
|
+
):
|
|
103
|
+
visible_refs.append(ref)
|
|
104
|
+
else:
|
|
105
|
+
visible_refs.append(ref)
|
|
106
|
+
|
|
107
|
+
return visible_refs
|
|
108
|
+
|