django-unfold 0.42.0__py3-none-any.whl → 0.43.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- {django_unfold-0.42.0.dist-info → django_unfold-0.43.0.dist-info}/METADATA +1 -1
- {django_unfold-0.42.0.dist-info → django_unfold-0.43.0.dist-info}/RECORD +27 -21
- unfold/admin.py +2 -0
- unfold/components.py +47 -0
- 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/static/unfold/css/styles.css +1 -1
- unfold/templates/admin/change_form.html +8 -0
- unfold/templates/admin/nav_sidebar.html +1 -10
- unfold/templates/unfold/change_list_filter.html +3 -5
- 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/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/welcomemsg.html +9 -1
- unfold/templates/unfold/layouts/skeleton.html +1 -1
- unfold/templates/unfold/widgets/clearable_file_input.html +1 -1
- unfold/templates/unfold/widgets/clearable_file_input_small.html +1 -1
- unfold/templatetags/unfold.py +26 -7
- {django_unfold-0.42.0.dist-info → django_unfold-0.43.0.dist-info}/LICENSE.md +0 -0
- {django_unfold-0.42.0.dist-info → django_unfold-0.43.0.dist-info}/WHEEL +0 -0
@@ -61,6 +61,10 @@
|
|
61
61
|
<div id="content-main">
|
62
62
|
{% block form_before %}{% endblock %}
|
63
63
|
|
64
|
+
{% if adminform.model_admin.change_form_outer_before_template %}
|
65
|
+
{% include adminform.model_admin.change_form_outer_before_template %}
|
66
|
+
{% endif %}
|
67
|
+
|
64
68
|
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}{% if form_url %}action="{{ form_url }}" {% endif %}method="post" id="{{ opts.model_name }}_form" {% if adminform.model_admin.warn_unsaved_form %}class="warn-unsaved-form"{% endif %} novalidate>
|
65
69
|
{% csrf_token %}
|
66
70
|
|
@@ -116,6 +120,10 @@
|
|
116
120
|
</div>
|
117
121
|
</form>
|
118
122
|
|
123
|
+
{% if adminform.model_admin.change_form_outer_after_template %}
|
124
|
+
{% include adminform.model_admin.change_form_outer_after_template %}
|
125
|
+
{% endif %}
|
126
|
+
|
119
127
|
{% block form_after %}{% endblock %}
|
120
128
|
</div>
|
121
129
|
{% endblock %}
|
@@ -1,22 +1,13 @@
|
|
1
1
|
{% load i18n %}
|
2
2
|
|
3
3
|
<div class="relative z-50">
|
4
|
-
<div @click="sidebarDesktopOpen = !sidebarDesktopOpen"
|
5
|
-
hx-get="{% url "admin:toggle_sidebar" %}"
|
6
|
-
hx-swap="none"
|
7
|
-
class="bg-white border cursor-pointer fixed h-6 hidden items-center justify-center rounded-full text-gray-500 top-5 -translate-x-1/2 w-6 z-50 xl:flex dark:bg-gray-800 dark:border-gray-700 dark:text-gray-200"
|
8
|
-
:class="{'ml-6 rotate-180': !sidebarDesktopOpen, 'ml-72': sidebarDesktopOpen}">
|
9
|
-
<span class="material-symbols-outlined md-16">
|
10
|
-
first_page
|
11
|
-
</span>
|
12
|
-
</div>
|
13
|
-
|
14
4
|
<div @click="sidebarMobileOpen = !sidebarMobileOpen"
|
15
5
|
class="fixed bottom-0 bg-gray-700 cursor-pointer flex items-center left-0 mb-2 ml-2 justify-center px-2 py-1 rounded-full shadow-sm text-xs text-white uppercase z-50 xl:hidden"
|
16
6
|
:class="{'ml-72 -translate-x-1/2': sidebarMobileOpen}">
|
17
7
|
{% trans "Menu" %}
|
18
8
|
</div>
|
19
9
|
|
10
|
+
|
20
11
|
<div :class="{'xl:block': sidebarDesktopOpen, 'xl:hidden': !sidebarDesktopOpen, 'max-xl:fixed': sidebarMobileOpen, 'hidden': !sidebarMobileOpen }">
|
21
12
|
{% include "unfold/helpers/navigation.html" %}
|
22
13
|
</div>
|
@@ -46,11 +46,9 @@
|
|
46
46
|
{% endfor %}
|
47
47
|
|
48
48
|
{% if cl.model_admin.list_filter_submit %}
|
49
|
-
<
|
50
|
-
|
51
|
-
|
52
|
-
</button>
|
53
|
-
</div>
|
49
|
+
<button type="submit" class="bg-primary-600 block border border-transparent font-medium mb-4 mt-8 px-3 py-2 rounded-md self-end text-sm text-white w-full">
|
50
|
+
{% trans "Apply Filters" %}
|
51
|
+
</button>
|
54
52
|
</form>
|
55
53
|
{% endif %}
|
56
54
|
</div>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<div class="border flex flex-col flex-grow overflow-hidden p-6 relative rounded-md shadow-sm dark:border-gray-800 {% if class %} {{ class }}{% endif %}">
|
2
2
|
{% if title %}
|
3
|
-
<h2 class="border-b font-semibold mb-6 -mt-
|
3
|
+
<h2 class="bg-gray-50 border-b font-semibold mb-6 -mt-6 -mx-6 py-4 px-6 text-font-important-light dark:text-font-important-dark dark:border-gray-800 dark:bg-white/[.02]">
|
4
4
|
{{ title }}
|
5
5
|
</h2>
|
6
6
|
{% endif %}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
<div class="overflow-auto w-full" data-simplebar>
|
2
|
+
<table class="w-full">
|
3
|
+
<thead>
|
4
|
+
<tr>
|
5
|
+
<th></th>
|
6
|
+
|
7
|
+
{% for header in data.headers %}
|
8
|
+
<th class="font-normal px-3 pb-2.5 text-left ">
|
9
|
+
<div class="font-semibold text-font-important-light truncate dark:text-font-important-dark">
|
10
|
+
{{ header.title }}
|
11
|
+
</div>
|
12
|
+
|
13
|
+
{% if header.subtitle %}
|
14
|
+
<div class="mt-0.5 text-xs truncate">
|
15
|
+
{{ header.subtitle }}
|
16
|
+
</div>
|
17
|
+
{% endif %}
|
18
|
+
</th>
|
19
|
+
{% endfor %}
|
20
|
+
</tr>
|
21
|
+
</thead>
|
22
|
+
|
23
|
+
<tbody>
|
24
|
+
{% for row in data.rows %}
|
25
|
+
<tr class="h-full">
|
26
|
+
<td>
|
27
|
+
<div class="pr-3 py-2.5">
|
28
|
+
<div class="font-semibold text-font-important-light dark:text-font-important-dark">
|
29
|
+
{{ row.header.title }}
|
30
|
+
</div>
|
31
|
+
|
32
|
+
{% if row.header.subtitle %}
|
33
|
+
<div class="mt-0.5 text-xs">
|
34
|
+
{{ row.header.subtitle }}
|
35
|
+
</div>
|
36
|
+
{% endif %}
|
37
|
+
</div>
|
38
|
+
</td>
|
39
|
+
|
40
|
+
{% for col in row.cols %}
|
41
|
+
<td class="h-full">
|
42
|
+
<div class="flex flex-col h-full justify-center px-3 py-2.5 rounded-md {% if col.color %}{{ col.color }}{% else %}bg-gray-50 border border-dashed dark:bg-gray-800 dark:border-gray-700{% endif %}">
|
43
|
+
<span>
|
44
|
+
{{ col.value }}
|
45
|
+
</span>
|
46
|
+
|
47
|
+
{% if col.subtitle %}
|
48
|
+
<span class="mt-0.5">
|
49
|
+
{{ col.subtitle }}
|
50
|
+
</span>
|
51
|
+
{% endif %}
|
52
|
+
</div>
|
53
|
+
</td>
|
54
|
+
{% endfor %}
|
55
|
+
</tr>
|
56
|
+
{% endfor %}
|
57
|
+
</tbody>
|
58
|
+
</table>
|
59
|
+
</div>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
{% if items %}
|
2
|
-
<nav class="bg-gray-100 flex gap-2
|
2
|
+
<nav class="bg-gray-100 flex gap-2 p-1 rounded text-sm dark:bg-white/[.04]{% if class %} {{ class }}{% endif %}">
|
3
3
|
{% for item in items %}
|
4
4
|
<a href="{{ item.link }}" class="flex flex-row font-medium items-center px-2.5 py-1 rounded {% if item.active %} bg-white shadow-sm text-font-important-light hover:bg-white dark:bg-gray-900 dark:hover:bg-gray-900 dark:text-font-important-dark{% else %}text-font-subtle-light dark:text-font-subtle-dark hover:bg-gray-700/[.04] dark:hover:bg-white/[.04]{% endif %}">
|
5
5
|
{% if item.icon %}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<ul class="flex flex-row gap-0.5 overflow-hidden rounded">
|
2
|
+
{% for item in data %}
|
3
|
+
<li class="h-8 px-px size-full {% if item.color %}{{ item.color }}{% else %}bg-gray-300 dark:bg-gray-400{% endif %} hover:opacity-50" title="{{ item.tooltip }}"></li>
|
4
|
+
{% endfor %}
|
5
|
+
</ul>
|
@@ -1,13 +1,15 @@
|
|
1
1
|
{% load i18n %}
|
2
2
|
|
3
|
-
{% if errors or error %}
|
4
|
-
<
|
3
|
+
{% if errors or error or message %}
|
4
|
+
<div class="errornote mb-3 px-3 py-3 rounded-md group-[.inline-tabular]:mb-0 group-[.inline-tabular]:mt-3 group-[.inline-tabular]:mx-3 group-[.inline-stacked]:mb-3 group-[.inline-stacked]:mt-3 group-[.inline-stacked]:mx-3 bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-400">
|
5
5
|
{% if error %}
|
6
6
|
{{ error }}
|
7
|
+
{% elif message %}
|
8
|
+
{{ message }}
|
7
9
|
{% else %}
|
8
10
|
{% for error in errors %}
|
9
11
|
{{ error }}
|
10
12
|
{% endfor %}
|
11
13
|
{% endif %}
|
12
|
-
</
|
14
|
+
</div>
|
13
15
|
{% endif %}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<p class="
|
2
|
-
{{ message
|
1
|
+
<p class="mb-3 px-3 py-3 rounded-md text-sm last:mb-8 bg-blue-100 text-blue-700 dark:bg-blue-500/20 dark:text-blue-400">
|
2
|
+
{{ message }}
|
3
3
|
</p>
|
@@ -1,19 +1,18 @@
|
|
1
1
|
{% if messages %}
|
2
|
-
<ul>
|
2
|
+
<ul class="flex flex-col gap-4 mb-8">
|
3
3
|
{% for message in messages %}
|
4
|
-
<li class="
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
{{ message|capfirst }}
|
4
|
+
<li class="*:!mb-0">
|
5
|
+
{% if message.tags == 'info' %}
|
6
|
+
{% include "unfold/helpers/messages/info.html" with message=message %}
|
7
|
+
{% elif message.tags == 'success' %}
|
8
|
+
{% include "unfold/helpers/messages/success.html" with message=message %}
|
9
|
+
{% elif message.tags == 'warning' %}
|
10
|
+
{% include "unfold/helpers/messages/warning.html" with message=message %}
|
11
|
+
{% elif message.tags == 'error' %}
|
12
|
+
{% include "unfold/helpers/messages/error.html" with message=message %}
|
13
|
+
{% else %}
|
14
|
+
{% include "unfold/helpers/messages/debug.html" with message=message %}
|
15
|
+
{% endif %}
|
17
16
|
</li>
|
18
17
|
{% endfor %}
|
19
18
|
</ul>
|
@@ -1,6 +1,14 @@
|
|
1
1
|
{% load i18n %}
|
2
2
|
|
3
|
-
<div class="flex-grow font-semibold min-w-0 mr-3">
|
3
|
+
<div class="flex flex-row flex-grow font-semibold items-center min-w-0 mr-3">
|
4
|
+
<span class="cursor-pointer hidden flex-row items-center text-sm xl:flex">
|
5
|
+
<span class="material-symbols-outlined" hx-get="{% url "admin:toggle_sidebar" %}" hx-swap="none" x-on:click="sidebarDesktopOpen = !sidebarDesktopOpen">
|
6
|
+
dock_to_right
|
7
|
+
</span>
|
8
|
+
</span>
|
9
|
+
|
10
|
+
<span class="hidden bg-gray-200 h-5 mx-3 w-px xl:block dark:bg-gray-700"></span>
|
11
|
+
|
4
12
|
<h1 class="overflow-hidden text-ellipsis text-sm whitespace-nowrap xl:text-base text-font-important-light dark:text-font-important-dark">
|
5
13
|
{% if content_title %}
|
6
14
|
<span class="tracking-tight">
|
@@ -21,7 +21,7 @@
|
|
21
21
|
</div>
|
22
22
|
{% endif %}
|
23
23
|
|
24
|
-
<input type="text" aria-label="{% trans 'Choose file to upload' %}" value="{% if widget.value %}{{ widget.value.url }}{% else %}{% trans 'Choose file to upload' %}{% endif %}" disabled class="bg-white flex-grow font-medium px-3 py-2 text-ellipsis dark:bg-gray-900">
|
24
|
+
<input type="text" aria-label="{% trans 'Choose file to upload' %}" value="{% if widget.value %}{{ widget.value.url }}{% else %}{% trans 'Choose file to upload' %}{% endif %}" disabled class="bg-white flex-grow font-medium min-w-0 px-3 py-2 text-ellipsis dark:bg-gray-900">
|
25
25
|
|
26
26
|
<div class="flex flex-none items-center leading-none self-stretch">
|
27
27
|
<div class="hidden">
|
@@ -14,7 +14,7 @@
|
|
14
14
|
</div>
|
15
15
|
{% endif %}
|
16
16
|
|
17
|
-
<input type="text" aria-label="{% trans 'Choose file to upload' %}" value="{% if widget.value %}{{ widget.value.url }}{% else %}{% trans 'Choose file to upload' %}{% endif %}" disabled class="bg-white flex-grow font-medium px-3 py-2 text-ellipsis dark:bg-gray-900">
|
17
|
+
<input type="text" aria-label="{% trans 'Choose file to upload' %}" value="{% if widget.value %}{{ widget.value.url }}{% else %}{% trans 'Choose file to upload' %}{% endif %}" disabled class="bg-white flex-grow font-medium min-w-0 px-3 py-2 text-ellipsis dark:bg-gray-900">
|
18
18
|
|
19
19
|
<div class="flex flex-none items-center leading-none self-stretch">
|
20
20
|
<div class="hidden">
|
unfold/templatetags/unfold.py
CHANGED
@@ -10,6 +10,8 @@ from django.template.base import NodeList, Parser, Token, token_kwargs
|
|
10
10
|
from django.template.loader import render_to_string
|
11
11
|
from django.utils.safestring import SafeText
|
12
12
|
|
13
|
+
from unfold.components import ComponentRegistry
|
14
|
+
|
13
15
|
register = Library()
|
14
16
|
|
15
17
|
|
@@ -154,24 +156,37 @@ class RenderComponentNode(template.Node):
|
|
154
156
|
template_name: str,
|
155
157
|
nodelist: NodeList,
|
156
158
|
extra_context: Optional[Dict] = None,
|
159
|
+
include_context: bool = False,
|
157
160
|
*args,
|
158
161
|
**kwargs,
|
159
162
|
):
|
160
163
|
self.template_name = template_name
|
161
164
|
self.nodelist = nodelist
|
162
165
|
self.extra_context = extra_context or {}
|
166
|
+
self.include_context = include_context
|
163
167
|
super().__init__(*args, **kwargs)
|
164
168
|
|
165
169
|
def render(self, context: RequestContext) -> str:
|
166
|
-
|
170
|
+
values = {
|
171
|
+
name: var.resolve(context) for name, var in self.extra_context.items()
|
172
|
+
}
|
173
|
+
|
174
|
+
values.update(
|
175
|
+
{
|
176
|
+
"children": self.nodelist.render(context),
|
177
|
+
}
|
178
|
+
)
|
167
179
|
|
168
|
-
|
169
|
-
|
180
|
+
if "component_class" in values:
|
181
|
+
values = ComponentRegistry.create_instance(
|
182
|
+
values["component_class"], request=context.request
|
183
|
+
).get_context_data(**values)
|
184
|
+
|
185
|
+
if self.include_context:
|
186
|
+
values.update(context.flatten())
|
170
187
|
|
171
188
|
return render_to_string(
|
172
|
-
self.template_name,
|
173
|
-
request=context.request,
|
174
|
-
context=ctx,
|
189
|
+
self.template_name, request=context.request, context=values
|
175
190
|
)
|
176
191
|
|
177
192
|
|
@@ -202,17 +217,21 @@ def do_component(parser: Parser, token: Token) -> str:
|
|
202
217
|
raise TemplateSyntaxError(
|
203
218
|
'"with" in {bits[0]} tag needs at least one keyword argument.'
|
204
219
|
)
|
220
|
+
elif option == "include_context":
|
221
|
+
value = True
|
205
222
|
else:
|
206
223
|
raise TemplateSyntaxError(f"Unknown argument for {bits[0]} tag: {option}.")
|
207
224
|
|
208
225
|
options[option] = value
|
209
226
|
|
227
|
+
include_context = options.get("include_context", False)
|
210
228
|
nodelist = parser.parse(("endcomponent",))
|
211
229
|
template_name = bits[1][1:-1]
|
230
|
+
|
212
231
|
extra_context = options.get("with", {})
|
213
232
|
parser.next_token()
|
214
233
|
|
215
|
-
return RenderComponentNode(template_name, nodelist, extra_context)
|
234
|
+
return RenderComponentNode(template_name, nodelist, extra_context, include_context)
|
216
235
|
|
217
236
|
|
218
237
|
@register.filter
|
File without changes
|
File without changes
|