Skip to content

Commit da743c2

Browse files
committed
Remove the dropdown with quick links, fix formatting
1 parent 4d13bd7 commit da743c2

4 files changed

Lines changed: 6 additions & 53 deletions

File tree

src/hope/apps/administration/admin_site.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from collections import OrderedDict
22
from typing import TYPE_CHECKING, Any
33

4-
from constance import config
54
from django.conf import settings
65
from django.contrib import messages
76
from django.contrib.admin.models import LogEntry
@@ -29,43 +28,6 @@ def dashboard_callback(request: Any, context: dict[str, Any]) -> dict[str, Any]:
2928
return context
3029

3130

32-
def clean(v: str) -> str:
33-
return v.replace(r"\n", "").strip()
34-
35-
36-
def site_dropdown_callback(request: Any) -> list[dict[str, Any]]:
37-
"""Return Constance QUICK_LINKS as Unfold SITE_DROPDOWN items.
38-
39-
Replaces the smart_admin SMART_ADMIN_BOOKMARKS mechanism. Each non-empty
40-
line in `QUICK_LINKS` becomes a dropdown entry. Supported formats:
41-
42-
title,url → entry rendered as a link
43-
url → entry where title and url are the same
44-
-- → ignored (smart_admin used this as a separator;
45-
Unfold's dropdown does not support separators)
46-
"""
47-
items: list[dict[str, Any]] = []
48-
for raw in config.QUICK_LINKS.split("\n"):
49-
entry = clean(raw)
50-
if not entry or entry == "--":
51-
continue
52-
parts = [p.strip() for p in entry.split(",") if p.strip()]
53-
if not parts:
54-
continue
55-
if len(parts) == 1:
56-
title = link = parts[0]
57-
else:
58-
title, link = parts[0], parts[1]
59-
items.append(
60-
{
61-
"title": title,
62-
"link": link,
63-
"attrs": {"target": "_blank", "rel": "noopener"},
64-
}
65-
)
66-
return items
67-
68-
6931
# admin view
7032
def clear_cache_view(request: "HttpRequest") -> "HttpResponse":
7133
template = "admin/clear_cache.html"
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
{% load unfold %}
22

3-
<div class="border-b border-base-200 flex gap-3 items-center h-[65px] mb-6 dark:border-base-800 px-3 {% element_classes 'navigation_header' %}" {% if site_dropdown %}x-data="{ openDropdown: false }"{% endif %}>
4-
<a href="{% url 'admin:index' %}" class="bg-transparent flex font-semibold gap-3 grow min-w-0 h-[64px] items-center px-3 transition-all hover:bg-base-100 dark:hover:bg-white/[.06] {% if site_dropdown %}-mx-3 px-6{% endif %}">
3+
<div class="border-b border-base-200 flex gap-3 items-center h-[65px] mb-6 dark:border-base-800 px-3 {% element_classes 'navigation_header' %}">
4+
<a href="{% url 'admin:index' %}" class="bg-transparent flex font-semibold gap-3 grow min-w-0 h-[64px] items-center -mx-3 px-6 transition-all hover:bg-base-100 dark:hover:bg-white/[.06]">
55
{% if site_logo %}
66
{% include "unfold/helpers/site_logo.html" %}
77
{% elif branding %}
88
{% include "unfold/helpers/site_icon.html" %}
99
{% endif %}
1010
</a>
1111

12-
{% if site_dropdown %}
13-
<span class="material-symbols-outlined cursor-pointer select-none text-font-default-light dark:text-font-default-dark hover:text-base-700 dark:hover:text-base-200"
14-
x-on:click="openDropdown = !openDropdown">
15-
unfold_more
16-
</span>
17-
{% endif %}
18-
1912
<span class="material-symbols-outlined block cursor-pointer h-[18px] xl:hidden! hover:text-base-700 dark:hover:text-base-200" x-on:click="sidebarMobileOpen = !sidebarMobileOpen">
2013
close
2114
</span>
22-
23-
{% include "unfold/helpers/site_dropdown.html" %}
2415
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div id="site-name">
2+
{{ site_header|default:_('Django administration') }}
3+
</div>

src/hope/config/fragments/unfold.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"SHOW_HISTORY": True,
2121
"SHOW_VIEW_ON_SITE": True,
2222
"ENVIRONMENT": "hope.config.fragments.unfold.environment_callback",
23-
"SITE_DROPDOWN": "hope.apps.administration.admin_site.site_dropdown_callback",
2423
"STYLES": [
2524
lambda request: static("admin/css/hope_admin.css"),
2625
],
@@ -772,9 +771,7 @@
772771
"items": [
773772
{
774773
"title": _("Universal updates"),
775-
"link": reverse_lazy(
776-
"admin:universal_update_script_universalupdate_changelist"
777-
),
774+
"link": reverse_lazy("admin:universal_update_script_universalupdate_changelist"),
778775
"icon": "update",
779776
},
780777
],

0 commit comments

Comments
 (0)