django-unfold 0.41.0__py3-none-any.whl → 0.43.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.
- {django_unfold-0.41.0.dist-info → django_unfold-0.43.0.dist-info}/METADATA +1 -1
- {django_unfold-0.41.0.dist-info → django_unfold-0.43.0.dist-info}/RECORD +63 -55
- unfold/admin.py +8 -1
- unfold/components.py +47 -0
- unfold/contrib/filters/admin.py +23 -33
- unfold/contrib/guardian/templates/admin/guardian/model/obj_perms_manage.html +1 -1
- unfold/contrib/guardian/templates/admin/guardian/model/obj_perms_manage_group.html +1 -1
- unfold/contrib/guardian/templates/admin/guardian/model/obj_perms_manage_user.html +1 -1
- unfold/contrib/import_export/templates/admin/import_export/export.html +1 -1
- unfold/contrib/import_export/templates/admin/import_export/import.html +1 -1
- unfold/contrib/import_export/templates/admin/import_export/import_validation.html +26 -21
- unfold/contrib/import_export/templates/admin/import_export/resource_fields_list.html +5 -3
- unfold/contrib/simple_history/templates/simple_history/object_history_form.html +1 -1
- unfold/contrib/simple_history/templates/simple_history/submit_line.html +1 -1
- unfold/settings.py +1 -0
- unfold/sites.py +25 -5
- unfold/static/unfold/css/styles.css +1 -1
- unfold/static/unfold/js/app.js +21 -15
- unfold/styles.css +14 -1
- unfold/templates/admin/base.html +3 -3
- unfold/templates/admin/change_form.html +9 -1
- unfold/templates/admin/change_list.html +1 -1
- unfold/templates/admin/date_hierarchy.html +5 -5
- unfold/templates/admin/delete_confirmation.html +1 -1
- unfold/templates/admin/delete_selected_confirmation.html +1 -1
- unfold/templates/admin/edit_inline/stacked.html +8 -2
- unfold/templates/admin/edit_inline/tabular.html +8 -2
- unfold/templates/admin/nav_sidebar.html +1 -10
- unfold/templates/admin/object_history.html +1 -1
- unfold/templates/admin/submit_line.html +2 -2
- unfold/templates/unfold/change_list_filter.html +5 -13
- unfold/templates/unfold/components/card.html +1 -1
- unfold/templates/unfold/components/chart/cohort.html +59 -0
- unfold/templates/unfold/components/navigation.html +1 -1
- unfold/templates/unfold/components/tracker.html +5 -0
- unfold/templates/unfold/helpers/account_links.html +1 -1
- unfold/templates/unfold/helpers/actions_row.html +9 -7
- unfold/templates/unfold/helpers/field_readonly.html +1 -1
- unfold/templates/unfold/helpers/form_label.html +1 -1
- unfold/templates/unfold/helpers/header.html +1 -1
- unfold/templates/unfold/helpers/label.html +1 -1
- unfold/templates/unfold/helpers/language_switch.html +27 -0
- unfold/templates/unfold/helpers/messages/debug.html +3 -0
- unfold/templates/unfold/helpers/messages/error.html +5 -3
- unfold/templates/unfold/helpers/messages/info.html +2 -2
- unfold/templates/unfold/helpers/messages/success.html +3 -0
- unfold/templates/unfold/helpers/messages/warning.html +3 -0
- unfold/templates/unfold/helpers/messages.html +13 -14
- unfold/templates/unfold/helpers/tab_list.html +3 -3
- unfold/templates/unfold/helpers/theme_switch.html +1 -1
- unfold/templates/unfold/helpers/userlinks.html +4 -0
- unfold/templates/unfold/helpers/welcomemsg.html +9 -1
- unfold/templates/unfold/layouts/base_simple.html +1 -1
- unfold/templates/unfold/layouts/skeleton.html +1 -1
- unfold/templates/unfold/templatetags/preserve_changelist_filters.html +3 -0
- unfold/templates/unfold/widgets/clearable_file_input.html +1 -1
- unfold/templates/unfold/widgets/clearable_file_input_small.html +1 -1
- unfold/templates/unfold/widgets/split_datetime_vertical.html +1 -1
- unfold/templatetags/unfold.py +55 -9
- unfold/utils.py +17 -0
- unfold/widgets.py +6 -2
- {django_unfold-0.41.0.dist-info → django_unfold-0.43.0.dist-info}/LICENSE.md +0 -0
- {django_unfold-0.41.0.dist-info → django_unfold-0.43.0.dist-info}/WHEEL +0 -0
unfold/settings.py
CHANGED
unfold/sites.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
from http import HTTPStatus
|
2
2
|
from typing import Any, Callable, Dict, List, Optional, Union
|
3
|
+
from urllib.parse import parse_qs, urlparse
|
3
4
|
|
4
5
|
from django.contrib.admin import AdminSite
|
5
6
|
from django.contrib.auth import REDIRECT_FIELD_NAME
|
@@ -84,6 +85,7 @@ class UnfoldAdminSite(AdminSite):
|
|
84
85
|
"show_view_on_site": get_config(self.settings_name)[
|
85
86
|
"SHOW_VIEW_ON_SITE"
|
86
87
|
],
|
88
|
+
"show_languages": get_config(self.settings_name)["SHOW_LANGUAGES"],
|
87
89
|
"colors": self._process_colors(
|
88
90
|
get_config(self.settings_name)["COLORS"]
|
89
91
|
),
|
@@ -234,6 +236,7 @@ class UnfoldAdminSite(AdminSite):
|
|
234
236
|
|
235
237
|
def get_sidebar_list(self, request: HttpRequest) -> List[Dict[str, Any]]:
|
236
238
|
navigation = get_config(self.settings_name)["SIDEBAR"].get("navigation", [])
|
239
|
+
tabs = get_config(self.settings_name)["TABS"]
|
237
240
|
results = []
|
238
241
|
|
239
242
|
for group in navigation:
|
@@ -245,7 +248,8 @@ class UnfoldAdminSite(AdminSite):
|
|
245
248
|
request, item.get("link_callback") or item["link"]
|
246
249
|
)
|
247
250
|
|
248
|
-
|
251
|
+
# Checks if any tab item is active and then marks the sidebar link as active
|
252
|
+
for tab in tabs:
|
249
253
|
has_primary_link = False
|
250
254
|
has_tab_link_active = False
|
251
255
|
|
@@ -302,7 +306,7 @@ class UnfoldAdminSite(AdminSite):
|
|
302
306
|
item["link_callback"] = lazy(item["link"])(request)
|
303
307
|
|
304
308
|
item["active"] = self._get_is_active(
|
305
|
-
request, item.get("link_callback") or item["link"]
|
309
|
+
request, item.get("link_callback") or item["link"], True
|
306
310
|
)
|
307
311
|
allowed_items.append(item)
|
308
312
|
|
@@ -391,13 +395,29 @@ class UnfoldAdminSite(AdminSite):
|
|
391
395
|
|
392
396
|
return colors
|
393
397
|
|
394
|
-
def _get_is_active(
|
398
|
+
def _get_is_active(
|
399
|
+
self, request: HttpRequest, link: str, is_tab: bool = False
|
400
|
+
) -> bool:
|
395
401
|
if not isinstance(link, str):
|
396
402
|
link = str(link)
|
397
403
|
|
398
|
-
|
404
|
+
index_path = reverse_lazy(f"{self.name}:index")
|
405
|
+
link_path = urlparse(link).path
|
406
|
+
|
407
|
+
# Dashboard
|
408
|
+
if link_path == request.path == index_path:
|
399
409
|
return True
|
400
|
-
|
410
|
+
|
411
|
+
if link_path in request.path and link_path != index_path:
|
412
|
+
query_params = parse_qs(urlparse(link).query)
|
413
|
+
request_params = parse_qs(request.GET.urlencode())
|
414
|
+
|
415
|
+
# In case of tabs, we need to check if the query params are the same
|
416
|
+
if is_tab and not all(
|
417
|
+
request_params.get(k) == v for k, v in query_params.items()
|
418
|
+
):
|
419
|
+
return False
|
420
|
+
|
401
421
|
return True
|
402
422
|
|
403
423
|
return False
|