|
1 | 1 | from collections import OrderedDict |
2 | 2 | from typing import TYPE_CHECKING, Any |
3 | 3 |
|
4 | | -from constance import config |
5 | 4 | from django.conf import settings |
6 | 5 | from django.contrib import messages |
7 | 6 | from django.contrib.admin.models import LogEntry |
@@ -29,43 +28,6 @@ def dashboard_callback(request: Any, context: dict[str, Any]) -> dict[str, Any]: |
29 | 28 | return context |
30 | 29 |
|
31 | 30 |
|
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 | | - |
69 | 31 | # admin view |
70 | 32 | def clear_cache_view(request: "HttpRequest") -> "HttpResponse": |
71 | 33 | template = "admin/clear_cache.html" |
|
0 commit comments