django-smartbase-admin 0.2.47__py3-none-any.whl → 1.0.38__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.
- django_smartbase_admin/actions/admin_action_list.py +80 -51
- django_smartbase_admin/actions/advanced_filters.py +55 -20
- django_smartbase_admin/admin/admin_base.py +477 -89
- django_smartbase_admin/admin/site.py +104 -34
- django_smartbase_admin/admin/widgets.py +598 -26
- django_smartbase_admin/apps.py +2 -0
- django_smartbase_admin/engine/actions.py +34 -16
- django_smartbase_admin/engine/admin_base_view.py +253 -115
- django_smartbase_admin/engine/configuration.py +186 -4
- django_smartbase_admin/engine/const.py +7 -0
- django_smartbase_admin/engine/dashboard.py +44 -23
- django_smartbase_admin/engine/fake_inline.py +44 -7
- django_smartbase_admin/engine/field.py +54 -10
- django_smartbase_admin/engine/field_formatter.py +32 -9
- django_smartbase_admin/engine/filter_widgets.py +356 -21
- django_smartbase_admin/engine/menu_item.py +8 -5
- django_smartbase_admin/engine/modal_view.py +12 -7
- django_smartbase_admin/engine/request.py +2 -0
- django_smartbase_admin/integration/__init__.py +0 -0
- django_smartbase_admin/integration/django_cms.py +43 -0
- django_smartbase_admin/locale/sk/LC_MESSAGES/django.mo +0 -0
- django_smartbase_admin/locale/sk/LC_MESSAGES/django.po +268 -37
- django_smartbase_admin/migrations/0005_sbadminuserconfiguration.py +26 -0
- django_smartbase_admin/migrations/0006_alter_sbadminuserconfiguration_color_scheme.py +18 -0
- django_smartbase_admin/models.py +22 -0
- django_smartbase_admin/monkeypatch/admin_readonly_field_monkeypatch.py +96 -0
- django_smartbase_admin/monkeypatch/fake_inline_monkeypatch.py +1 -1
- django_smartbase_admin/querysets.py +3 -0
- django_smartbase_admin/services/configuration.py +30 -0
- django_smartbase_admin/services/thread_local.py +6 -19
- django_smartbase_admin/services/views.py +82 -27
- django_smartbase_admin/services/xlsx_export.py +6 -0
- django_smartbase_admin/static/sb_admin/build/tailwind.config.js +1 -0
- django_smartbase_admin/static/sb_admin/build/tailwind_config_partials/colors.js +4 -0
- django_smartbase_admin/static/sb_admin/build/tailwind_config_partials/spacing.js +1 -0
- django_smartbase_admin/static/sb_admin/build/webpack.common.js +11 -8
- django_smartbase_admin/static/sb_admin/css/ckeditor/ckeditor_content_dark.css +208 -0
- django_smartbase_admin/static/sb_admin/css/coloris/coloris.min.css +1 -0
- django_smartbase_admin/static/sb_admin/dist/calendar.js +1 -0
- django_smartbase_admin/static/sb_admin/dist/calendar_style.css +1 -0
- django_smartbase_admin/static/sb_admin/dist/calendar_style.js +0 -0
- django_smartbase_admin/static/sb_admin/dist/chart.js +1 -1
- django_smartbase_admin/static/sb_admin/dist/main.js +1 -1
- django_smartbase_admin/static/sb_admin/dist/main_style.css +1 -1
- django_smartbase_admin/static/sb_admin/dist/table.js +1 -1
- django_smartbase_admin/static/sb_admin/dist/table.js.LICENSE.txt +9 -0
- django_smartbase_admin/static/sb_admin/dist/tree_widget.js +1 -0
- django_smartbase_admin/static/sb_admin/dist/tree_widget_style.css +1 -0
- django_smartbase_admin/static/sb_admin/dist/tree_widget_style.js +0 -0
- django_smartbase_admin/static/sb_admin/fancytree/jquery.fancytree-all-deps.min.js +1 -0
- django_smartbase_admin/static/sb_admin/images/file_types/file-csv.svg +11 -0
- django_smartbase_admin/static/sb_admin/images/file_types/file-doc.svg +11 -0
- django_smartbase_admin/static/sb_admin/images/file_types/file-docx.svg +11 -0
- django_smartbase_admin/static/sb_admin/images/file_types/file-other.svg +13 -0
- django_smartbase_admin/static/sb_admin/images/file_types/file-pdf.svg +11 -0
- django_smartbase_admin/static/sb_admin/images/file_types/file-ppt.svg +11 -0
- django_smartbase_admin/static/sb_admin/images/file_types/file-xls.svg +11 -0
- django_smartbase_admin/static/sb_admin/images/file_types/file-xlsx.svg +11 -0
- django_smartbase_admin/static/sb_admin/images/file_types/file-zip.svg +18 -0
- django_smartbase_admin/static/sb_admin/images/flags/de-at.png +0 -0
- django_smartbase_admin/static/sb_admin/images/flags/de-ch.png +0 -0
- django_smartbase_admin/static/sb_admin/images/logo_light.svg +21 -0
- django_smartbase_admin/static/sb_admin/js/coloris/coloris.min.js +6 -0
- django_smartbase_admin/static/sb_admin/js/fullcalendar.min.js +14804 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Bolt-one.svg +3 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Calendar.svg +3 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Caution.svg +3 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Electric-drill.svg +3 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Fire-extinguisher.svg +3 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Gas.svg +3 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Lightning-fill.svg +3 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Moon.svg +3 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Phone-telephone.svg +3 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Printer.svg +3 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Pull.svg +3 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Sun-one.svg +3 -0
- django_smartbase_admin/static/sb_admin/sprites/sb_admin/Time.svg +3 -0
- django_smartbase_admin/static/sb_admin/src/css/_base.css +5 -1
- django_smartbase_admin/static/sb_admin/src/css/_colors.css +257 -82
- django_smartbase_admin/static/sb_admin/src/css/_components.css +66 -13
- django_smartbase_admin/static/sb_admin/src/css/_datepicker.css +8 -1
- django_smartbase_admin/static/sb_admin/src/css/_filer.css +60 -0
- django_smartbase_admin/static/sb_admin/src/css/_inlines.css +51 -10
- django_smartbase_admin/static/sb_admin/src/css/_tabulator.css +8 -2
- django_smartbase_admin/static/sb_admin/src/css/calendar.css +162 -0
- django_smartbase_admin/static/sb_admin/src/css/components/_button.css +41 -1
- django_smartbase_admin/static/sb_admin/src/css/components/_dropdown.css +26 -8
- django_smartbase_admin/static/sb_admin/src/css/components/_input.css +62 -20
- django_smartbase_admin/static/sb_admin/src/css/components/_modal.css +1 -1
- django_smartbase_admin/static/sb_admin/src/css/components/_query-builder.css +21 -2
- django_smartbase_admin/static/sb_admin/src/css/components/_toggle.css +12 -1
- django_smartbase_admin/static/sb_admin/src/css/components/_tooltip.css +8 -22
- django_smartbase_admin/static/sb_admin/src/css/style.css +17 -0
- django_smartbase_admin/static/sb_admin/src/css/tree_widget.css +411 -0
- django_smartbase_admin/static/sb_admin/src/js/autocomplete.js +63 -5
- django_smartbase_admin/static/sb_admin/src/js/calendar.js +56 -0
- django_smartbase_admin/static/sb_admin/src/js/chart.js +8 -22
- django_smartbase_admin/static/sb_admin/src/js/choices.js +18 -8
- django_smartbase_admin/static/sb_admin/src/js/datepicker.js +97 -336
- django_smartbase_admin/static/sb_admin/src/js/datepicker_plugins.js +357 -0
- django_smartbase_admin/static/sb_admin/src/js/main.js +307 -26
- django_smartbase_admin/static/sb_admin/src/js/multiselect.js +50 -41
- django_smartbase_admin/static/sb_admin/src/js/range.js +3 -2
- django_smartbase_admin/static/sb_admin/src/js/sb_ajax_params_tabulator_modifier.js +21 -0
- django_smartbase_admin/static/sb_admin/src/js/table.js +38 -13
- django_smartbase_admin/static/sb_admin/src/js/table_modules/advanced_filter_module.js +43 -20
- django_smartbase_admin/static/sb_admin/src/js/table_modules/data_edit_module.js +8 -10
- django_smartbase_admin/static/sb_admin/src/js/table_modules/filter_module.js +3 -3
- django_smartbase_admin/static/sb_admin/src/js/table_modules/header_tabs_module.js +11 -11
- django_smartbase_admin/static/sb_admin/src/js/table_modules/selection_module.js +28 -8
- django_smartbase_admin/static/sb_admin/src/js/table_modules/table_params_module.js +6 -0
- django_smartbase_admin/static/sb_admin/src/js/table_modules/views_module.js +19 -3
- django_smartbase_admin/static/sb_admin/src/js/tree_widget.js +406 -0
- django_smartbase_admin/static/sb_admin/src/js/utils.js +56 -21
- django_smartbase_admin/templates/sb_admin/actions/change_form.html +169 -117
- django_smartbase_admin/templates/sb_admin/actions/dashboard.html +2 -2
- django_smartbase_admin/templates/sb_admin/actions/delete_selected_confirmation.html +56 -32
- django_smartbase_admin/templates/sb_admin/actions/list.html +79 -42
- django_smartbase_admin/templates/sb_admin/actions/object_history.html +2 -2
- django_smartbase_admin/templates/sb_admin/actions/partials/action_link.html +14 -0
- django_smartbase_admin/templates/sb_admin/actions/partials/selected_rows_actions.html +2 -2
- django_smartbase_admin/templates/sb_admin/actions/partials/tabulator_header_v2.html +2 -2
- django_smartbase_admin/templates/sb_admin/actions/tree_list.html +63 -0
- django_smartbase_admin/templates/sb_admin/authentification/login_base.html +5 -1
- django_smartbase_admin/templates/sb_admin/components/columns.html +1 -1
- django_smartbase_admin/templates/sb_admin/components/filters_v2.html +99 -85
- django_smartbase_admin/templates/sb_admin/config/view.html +0 -1
- django_smartbase_admin/templates/sb_admin/dashboard/calendar_widget.html +69 -0
- django_smartbase_admin/templates/sb_admin/dashboard/chart_widget.html +21 -2
- django_smartbase_admin/templates/sb_admin/dashboard/list_widget.html +6 -0
- django_smartbase_admin/templates/sb_admin/dashboard/widget_base.html +1 -1
- django_smartbase_admin/templates/sb_admin/filter_widgets/advanced_filters/date_field.html +18 -8
- django_smartbase_admin/templates/sb_admin/filter_widgets/advanced_filters/multiple_choice_field.html +1 -1
- django_smartbase_admin/templates/sb_admin/filter_widgets/advanced_filters/tree_select_filter.html +2 -0
- django_smartbase_admin/templates/sb_admin/filter_widgets/date_field.html +18 -4
- django_smartbase_admin/templates/sb_admin/filter_widgets/multiple_choice_field.html +14 -0
- django_smartbase_admin/templates/sb_admin/filter_widgets/partials/clear.html +10 -5
- django_smartbase_admin/templates/sb_admin/filter_widgets/radio_choice_field.html +2 -2
- django_smartbase_admin/templates/sb_admin/filter_widgets/tree_select_filter.html +16 -0
- django_smartbase_admin/templates/sb_admin/includes/change_form_title.html +3 -1
- django_smartbase_admin/templates/sb_admin/includes/components.html +5 -1
- django_smartbase_admin/templates/sb_admin/includes/inline_fieldset.html +48 -39
- django_smartbase_admin/templates/sb_admin/includes/notifications.html +2 -1
- django_smartbase_admin/templates/sb_admin/includes/readonly_boolean_field.html +9 -0
- django_smartbase_admin/templates/sb_admin/includes/readonly_field.html +12 -0
- django_smartbase_admin/templates/sb_admin/includes/table_inline_delete_button.html +4 -5
- django_smartbase_admin/templates/sb_admin/inlines/stacked_inline.html +68 -40
- django_smartbase_admin/templates/sb_admin/inlines/table_inline.html +78 -36
- django_smartbase_admin/templates/sb_admin/integrations/filer/folder_list.html +18 -0
- django_smartbase_admin/templates/sb_admin/navigation.html +166 -158
- django_smartbase_admin/templates/sb_admin/partials/modal/modal_content.html +2 -6
- django_smartbase_admin/templates/sb_admin/sb_admin_base.html +49 -4
- django_smartbase_admin/templates/sb_admin/sb_admin_base_no_sidebar.html +35 -11
- django_smartbase_admin/templates/sb_admin/sb_admin_js_trans.html +3 -0
- django_smartbase_admin/templates/sb_admin/sprites/sb_admin.svg +1 -1
- django_smartbase_admin/templates/sb_admin/tailwind_whitelist.html +6 -3
- django_smartbase_admin/templates/sb_admin/widgets/array.html +0 -1
- django_smartbase_admin/templates/sb_admin/widgets/attributes.html +68 -0
- django_smartbase_admin/templates/sb_admin/widgets/autocomplete.html +13 -2
- django_smartbase_admin/templates/sb_admin/widgets/{checkbox_select.html → checkbox_dropdown.html} +2 -2
- django_smartbase_admin/templates/sb_admin/widgets/checkbox_group.html +15 -0
- django_smartbase_admin/templates/sb_admin/widgets/clearable_file_input.html +2 -2
- django_smartbase_admin/templates/sb_admin/widgets/color_field.html +30 -0
- django_smartbase_admin/templates/sb_admin/widgets/date.html +8 -1
- django_smartbase_admin/templates/sb_admin/widgets/filer_file.html +84 -0
- django_smartbase_admin/templates/sb_admin/widgets/html_read_only.html +1 -0
- django_smartbase_admin/templates/sb_admin/widgets/includes/related_item_buttons.html +38 -0
- django_smartbase_admin/templates/sb_admin/widgets/multiwidget.html +1 -1
- django_smartbase_admin/templates/sb_admin/widgets/radio.html +3 -2
- django_smartbase_admin/templates/sb_admin/widgets/radio_dropdown.html +30 -0
- django_smartbase_admin/templates/sb_admin/widgets/read_only_password_hash.html +3 -0
- django_smartbase_admin/templates/sb_admin/widgets/time.html +8 -1
- django_smartbase_admin/templates/sb_admin/widgets/toggle.html +1 -1
- django_smartbase_admin/templates/sb_admin/widgets/tree_base.html +59 -0
- django_smartbase_admin/templates/sb_admin/widgets/tree_select.html +24 -0
- django_smartbase_admin/templates/sb_admin/widgets/tree_select_inline.html +12 -0
- django_smartbase_admin/templatetags/sb_admin_tags.py +163 -4
- django_smartbase_admin/utils.py +22 -3
- django_smartbase_admin/views/dashboard_view.py +6 -0
- django_smartbase_admin/views/global_filter_view.py +8 -2
- django_smartbase_admin/views/translations_view.py +12 -5
- django_smartbase_admin/views/user_config_view.py +52 -0
- django_smartbase_admin-1.0.38.dist-info/METADATA +166 -0
- {django_smartbase_admin-0.2.47.dist-info → django_smartbase_admin-1.0.38.dist-info}/RECORD +186 -121
- {django_smartbase_admin-0.2.47.dist-info → django_smartbase_admin-1.0.38.dist-info}/WHEEL +1 -1
- django_smartbase_admin/templates/sb_admin/integrations/sorting/change_list.html +0 -401
- django_smartbase_admin-0.2.47.dist-info/METADATA +0 -25
- {django_smartbase_admin-0.2.47.dist-info → django_smartbase_admin-1.0.38.dist-info}/LICENSE.md +0 -0
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
1
2
|
from functools import update_wrapper
|
|
3
|
+
from typing import Any
|
|
2
4
|
|
|
5
|
+
from django.conf import settings
|
|
3
6
|
from django.contrib import admin
|
|
4
|
-
from django.
|
|
7
|
+
from django.contrib.auth import REDIRECT_FIELD_NAME
|
|
8
|
+
from django.contrib.auth.decorators import login_not_required
|
|
9
|
+
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
|
|
10
|
+
from django.urls import path, reverse_lazy, URLPattern, URLResolver, reverse
|
|
11
|
+
from django.utils.decorators import method_decorator
|
|
12
|
+
from django.utils.translation import gettext_lazy as _
|
|
13
|
+
from django.views.decorators.cache import never_cache
|
|
14
|
+
from django.views.decorators.csrf import csrf_protect
|
|
15
|
+
from django.views.generic import TemplateView
|
|
5
16
|
|
|
6
17
|
from django_smartbase_admin.engine.admin_entrypoint_view import SBAdminEntrypointView
|
|
7
18
|
from django_smartbase_admin.engine.request import SBAdminViewRequestData
|
|
@@ -18,56 +29,69 @@ class SBAdminSite(admin.AdminSite):
|
|
|
18
29
|
"sb_admin/authentification/password_change_done.html"
|
|
19
30
|
)
|
|
20
31
|
|
|
21
|
-
def initialize_admin_view(
|
|
32
|
+
def initialize_admin_view(
|
|
33
|
+
self, view_func: Callable[..., HttpResponse], request: HttpRequest, **kwargs
|
|
34
|
+
) -> None:
|
|
22
35
|
request.current_app = "sb_admin"
|
|
23
36
|
selected_view = None
|
|
24
37
|
try:
|
|
25
|
-
selected_view =
|
|
38
|
+
selected_view = view_func.__self__
|
|
26
39
|
from django_smartbase_admin.admin.admin_base import SBAdminBaseView
|
|
27
40
|
|
|
28
41
|
if not isinstance(selected_view, SBAdminBaseView):
|
|
29
42
|
selected_view = None
|
|
30
|
-
except:
|
|
43
|
+
except Exception:
|
|
31
44
|
pass
|
|
32
45
|
request.sbadmin_selected_view = selected_view
|
|
33
46
|
kwargs["view"] = selected_view.get_id() if selected_view else None
|
|
47
|
+
SBAdminThreadLocalService.set_request(request)
|
|
34
48
|
request_data = SBAdminViewRequestData.from_request_and_kwargs(request, **kwargs)
|
|
35
|
-
SBAdminThreadLocalService.set_data("request", request)
|
|
36
49
|
if selected_view:
|
|
37
50
|
# Initialize SBAdmin, ModelAdmin instances, class-based SBAdminEntrypointView are initialized with request_data
|
|
38
51
|
selected_view.init_view_dynamic(
|
|
39
52
|
request, request_data=request_data, **kwargs
|
|
40
53
|
)
|
|
41
54
|
|
|
42
|
-
def admin_view_response_wrapper(
|
|
55
|
+
def admin_view_response_wrapper(
|
|
56
|
+
self, response: HttpResponse, request: HttpRequest, *args, **kwargs
|
|
57
|
+
) -> HttpResponse:
|
|
43
58
|
from django_smartbase_admin.admin.admin_base import SBAdminThirdParty
|
|
44
59
|
|
|
45
60
|
if isinstance(request.sbadmin_selected_view, SBAdminThirdParty):
|
|
46
61
|
response = SBAdminViewService.replace_legacy_admin_access_in_response(
|
|
47
62
|
response
|
|
48
63
|
)
|
|
49
|
-
|
|
50
|
-
SBAdminThreadLocalService.clear_data()
|
|
51
64
|
return response
|
|
52
65
|
|
|
53
|
-
def admin_view(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
def admin_view(
|
|
67
|
+
self,
|
|
68
|
+
view_func: Callable[..., HttpResponse],
|
|
69
|
+
cacheable: bool = False,
|
|
70
|
+
*,
|
|
71
|
+
public: bool = False
|
|
72
|
+
) -> Callable[[HttpRequest, ...], HttpResponse]:
|
|
73
|
+
def inner(request: HttpRequest, *args, **kwargs):
|
|
74
|
+
self.initialize_admin_view(view_func, request, **kwargs)
|
|
75
|
+
response = view_func(request, *args, **kwargs)
|
|
76
|
+
return self.admin_view_response_wrapper(response, request, *args, **kwargs)
|
|
77
|
+
|
|
78
|
+
if not public:
|
|
79
|
+
return super().admin_view(update_wrapper(inner, view_func), cacheable)
|
|
80
|
+
# standard Django admin behaviour, expect it skips staff/permission checks
|
|
81
|
+
if not cacheable:
|
|
82
|
+
inner = never_cache(inner)
|
|
83
|
+
if not getattr(view_func, "csrf_exempt", False):
|
|
84
|
+
inner = csrf_protect(inner)
|
|
85
|
+
inner = login_not_required(inner)
|
|
86
|
+
return update_wrapper(inner, view_func)
|
|
87
|
+
|
|
88
|
+
def each_context(self, request: HttpRequest) -> dict[str, Any]:
|
|
65
89
|
try:
|
|
66
90
|
return request.sbadmin_selected_view.get_global_context(request)
|
|
67
|
-
except:
|
|
91
|
+
except Exception:
|
|
68
92
|
return {}
|
|
69
93
|
|
|
70
|
-
def get_urls(self):
|
|
94
|
+
def get_urls(self) -> list[URLPattern | URLResolver]:
|
|
71
95
|
from django.contrib.auth.views import (
|
|
72
96
|
PasswordResetView,
|
|
73
97
|
PasswordResetDoneView,
|
|
@@ -76,8 +100,11 @@ class SBAdminSite(admin.AdminSite):
|
|
|
76
100
|
PasswordChangeView,
|
|
77
101
|
PasswordChangeDoneView,
|
|
78
102
|
)
|
|
103
|
+
from django_smartbase_admin.views.user_config_view import ColorSchemeView
|
|
79
104
|
|
|
80
105
|
urls = [
|
|
106
|
+
path("login/", self.admin_view(self.login, public=True), name="login"),
|
|
107
|
+
path("logout/", self.admin_view(self.logout), name="logout"),
|
|
81
108
|
path(
|
|
82
109
|
"password_change/",
|
|
83
110
|
self.admin_view(
|
|
@@ -129,19 +156,16 @@ class SBAdminSite(admin.AdminSite):
|
|
|
129
156
|
name="password_reset_complete",
|
|
130
157
|
),
|
|
131
158
|
]
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if not action_view:
|
|
135
|
-
continue
|
|
136
|
-
urls += [
|
|
159
|
+
if settings.DEBUG:
|
|
160
|
+
urls.append(
|
|
137
161
|
path(
|
|
138
|
-
"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
)
|
|
144
|
-
|
|
162
|
+
"components",
|
|
163
|
+
TemplateView.as_view(
|
|
164
|
+
template_name="sb_admin/includes/components.html"
|
|
165
|
+
),
|
|
166
|
+
name="components",
|
|
167
|
+
)
|
|
168
|
+
)
|
|
145
169
|
urls.extend(
|
|
146
170
|
[
|
|
147
171
|
path(
|
|
@@ -154,6 +178,11 @@ class SBAdminSite(admin.AdminSite):
|
|
|
154
178
|
self.admin_view(GlobalFilterView.as_view()),
|
|
155
179
|
name="global_filter",
|
|
156
180
|
),
|
|
181
|
+
path(
|
|
182
|
+
"color-scheme",
|
|
183
|
+
self.admin_view(ColorSchemeView.as_view()),
|
|
184
|
+
name="color_scheme",
|
|
185
|
+
),
|
|
157
186
|
path(
|
|
158
187
|
"<str:view>/<str:action>/<str:modifier>",
|
|
159
188
|
self.admin_view(SBAdminEntrypointView.as_view()),
|
|
@@ -169,5 +198,46 @@ class SBAdminSite(admin.AdminSite):
|
|
|
169
198
|
urls.extend(super().get_urls())
|
|
170
199
|
return urls
|
|
171
200
|
|
|
201
|
+
@method_decorator(never_cache)
|
|
202
|
+
@login_not_required
|
|
203
|
+
def login(self, request: HttpRequest, extra_context: dict[str, Any] | None = None):
|
|
204
|
+
"""
|
|
205
|
+
Same as Django's built-in AdminSite.login view, except it allows the
|
|
206
|
+
login view class to be overridden via configuration.
|
|
207
|
+
"""
|
|
208
|
+
if request.method == "GET" and self.has_permission(request):
|
|
209
|
+
# Already logged-in, redirect to admin index
|
|
210
|
+
index_path = reverse("admin:index", current_app=self.name)
|
|
211
|
+
return HttpResponseRedirect(index_path)
|
|
212
|
+
|
|
213
|
+
# Since this module gets imported in the application's root package,
|
|
214
|
+
# it cannot import models from other applications at the module level,
|
|
215
|
+
# and django.contrib.admin.forms eventually imports User.
|
|
216
|
+
from django.contrib.admin.forms import AdminAuthenticationForm
|
|
217
|
+
|
|
218
|
+
context = {
|
|
219
|
+
**self.each_context(request),
|
|
220
|
+
"title": _("Log in"),
|
|
221
|
+
"subtitle": None,
|
|
222
|
+
"app_path": request.get_full_path(),
|
|
223
|
+
"username": request.user.get_username(),
|
|
224
|
+
}
|
|
225
|
+
if (
|
|
226
|
+
REDIRECT_FIELD_NAME not in request.GET
|
|
227
|
+
and REDIRECT_FIELD_NAME not in request.POST
|
|
228
|
+
):
|
|
229
|
+
context[REDIRECT_FIELD_NAME] = reverse("admin:index", current_app=self.name)
|
|
230
|
+
context.update(extra_context or {})
|
|
231
|
+
|
|
232
|
+
defaults = {
|
|
233
|
+
"extra_context": context,
|
|
234
|
+
"authentication_form": self.login_form or AdminAuthenticationForm,
|
|
235
|
+
"template_name": self.login_template or "admin/login.html",
|
|
236
|
+
}
|
|
237
|
+
request.current_app = self.name
|
|
238
|
+
return request.request_data.configuration.login_view_class.as_view(**defaults)(
|
|
239
|
+
request
|
|
240
|
+
)
|
|
241
|
+
|
|
172
242
|
|
|
173
243
|
sb_admin_site = SBAdminSite(name="sb_admin")
|