django-unfold 0.40.0__py3-none-any.whl → 0.42.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. {django_unfold-0.40.0.dist-info → django_unfold-0.42.0.dist-info}/METADATA +6 -1
  2. {django_unfold-0.40.0.dist-info → django_unfold-0.42.0.dist-info}/RECORD +62 -57
  3. {django_unfold-0.40.0.dist-info → django_unfold-0.42.0.dist-info}/WHEEL +1 -1
  4. unfold/admin.py +11 -1
  5. unfold/contrib/filters/admin.py +23 -33
  6. unfold/contrib/filters/forms.py +2 -2
  7. unfold/contrib/forms/templates/unfold/forms/array.html +2 -2
  8. unfold/contrib/guardian/templates/admin/guardian/model/obj_perms_manage.html +2 -2
  9. unfold/contrib/guardian/templates/admin/guardian/model/obj_perms_manage_group.html +2 -2
  10. unfold/contrib/guardian/templates/admin/guardian/model/obj_perms_manage_user.html +2 -2
  11. unfold/contrib/import_export/templates/admin/import_export/export.html +2 -2
  12. unfold/contrib/import_export/templates/admin/import_export/import.html +2 -2
  13. unfold/contrib/simple_history/templates/simple_history/object_history_form.html +2 -2
  14. unfold/contrib/simple_history/templates/simple_history/submit_line.html +1 -1
  15. unfold/settings.py +1 -0
  16. unfold/sites.py +25 -5
  17. unfold/static/admin/js/inlines.js +439 -0
  18. unfold/static/unfold/css/styles.css +1 -1
  19. unfold/static/unfold/fonts/material-symbols/Material-Symbols-Outlined.woff2 +0 -0
  20. unfold/static/unfold/fonts/material-symbols/styles.css +1 -2
  21. unfold/static/unfold/js/alpine.sort.js +1 -0
  22. unfold/static/unfold/js/app.js +42 -10
  23. unfold/static/unfold/js/select2.init.js +1 -1
  24. unfold/styles.css +19 -2
  25. unfold/templates/admin/app_index.html +1 -1
  26. unfold/templates/admin/auth/user/change_password.html +1 -1
  27. unfold/templates/admin/base.html +4 -4
  28. unfold/templates/admin/change_form.html +2 -2
  29. unfold/templates/admin/change_list.html +47 -45
  30. unfold/templates/admin/date_hierarchy.html +5 -5
  31. unfold/templates/admin/delete_confirmation.html +4 -9
  32. unfold/templates/admin/delete_selected_confirmation.html +4 -8
  33. unfold/templates/admin/edit_inline/stacked.html +23 -8
  34. unfold/templates/admin/edit_inline/tabular.html +44 -21
  35. unfold/templates/admin/object_history.html +2 -2
  36. unfold/templates/admin/submit_line.html +8 -8
  37. unfold/templates/registration/password_change_done.html +1 -1
  38. unfold/templates/registration/password_change_form.html +1 -1
  39. unfold/templates/unfold/change_list_filter.html +9 -17
  40. unfold/templates/unfold/helpers/account_links.html +1 -1
  41. unfold/templates/unfold/helpers/actions_row.html +9 -7
  42. unfold/templates/unfold/helpers/delete_submit_line.html +11 -0
  43. unfold/templates/unfold/helpers/display_header.html +8 -3
  44. unfold/templates/unfold/helpers/field_readonly.html +1 -1
  45. unfold/templates/unfold/helpers/field_readonly_value.html +1 -1
  46. unfold/templates/unfold/helpers/fieldset_row.html +2 -0
  47. unfold/templates/unfold/helpers/form_label.html +1 -1
  48. unfold/templates/unfold/helpers/header.html +1 -1
  49. unfold/templates/unfold/helpers/label.html +1 -1
  50. unfold/templates/unfold/helpers/language_switch.html +27 -0
  51. unfold/templates/unfold/helpers/tab_list.html +3 -3
  52. unfold/templates/unfold/helpers/theme_switch.html +1 -1
  53. unfold/templates/unfold/helpers/userlinks.html +4 -0
  54. unfold/templates/unfold/layouts/base_simple.html +1 -1
  55. unfold/templates/unfold/layouts/skeleton.html +1 -0
  56. unfold/templates/unfold/templatetags/preserve_changelist_filters.html +3 -0
  57. unfold/templates/unfold/widgets/split_datetime_vertical.html +1 -1
  58. unfold/templates/unfold/widgets/url.html +7 -5
  59. unfold/templatetags/unfold.py +29 -2
  60. unfold/utils.py +17 -0
  61. unfold/widgets.py +6 -2
  62. {django_unfold-0.40.0.dist-info → django_unfold-0.42.0.dist-info}/LICENSE.md +0 -0
@@ -4,8 +4,10 @@
4
4
  <div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
5
5
  {{ inline_admin_formset.formset.management_form }}
6
6
 
7
- <fieldset class="module {{ inline_admin_formset.classes }} min-w-0">
8
- <h2 class="bg-gray-100 border border-transparent font-semibold mb-6 px-4 py-3 rounded-md text-font-important-light text-sm lg:-mx-4 dark:bg-white/[.02] dark:border dark:border-gray-800 dark:text-font-important-dark {% if inline_admin_formset.opts.tab %}hidden{% endif %}">
7
+ <fieldset class="module relative {{ inline_admin_formset.classes }} min-w-0" aria-labelledby="{{ inline_admin_formset.formset.prefix }}-heading">
8
+ {% if inline_admin_formset.is_collapsible %}<details><summary>{% endif %}
9
+
10
+ <h2 id="{{ inline_admin_formset.formset.prefix }}-heading" class="bg-gray-100 border border-transparent font-semibold mb-6 px-4 py-3 rounded-md text-font-important-light text-sm lg:-mx-4 dark:bg-white/[.02] dark:border dark:border-gray-800 dark:text-font-important-dark {% if inline_admin_formset.opts.tab %}hidden{% endif %} {% if inline_admin_formset.is_collapsible %} cursor-pointer{% endif %}">
9
11
  {% if inline_admin_formset.formset.max_num == 1 %}
10
12
  {{ inline_admin_formset.opts.verbose_name|capfirst }}
11
13
  {% else %}
@@ -13,15 +15,22 @@
13
15
  {% endif %}
14
16
  </h2>
15
17
 
18
+ {% if inline_admin_formset.is_collapsible %}</summary>{% endif %}
19
+
16
20
  {{ inline_admin_formset.formset.non_form_errors }}
17
21
 
18
22
  <div class="border border-gray-200 mb-6 overflow-x-auto rounded-md shadow-sm dark:border-gray-800" data-simplebar data-simplebar-auto-hide="false">
19
- <table class="border-spacing-none border-separate w-full">
23
+ <table class="border-spacing-none border-separate w-full"
24
+ {% if inline_admin_formset.opts.ordering_field %}
25
+ data-ordering-field="{{ inline_admin_formset.opts.ordering_field }}"
26
+ x-on:end="sortRecords"
27
+ x-sort.ghost
28
+ {% endif %}>
20
29
  <thead class="hidden lg:table-header-group">
21
30
  <tr>
22
31
  {% for field in inline_admin_formset.fields %}
23
32
  {% if not field.widget.is_hidden %}
24
- <th class="column-{{ field.name }}{% if field.required %} required{% endif %} align-middle border-b border-gray-200 font-semibold px-3 py-2 text-left text-font-important-light text-sm whitespace-nowrap dark:text-font-important-dark dark:border-gray-800">
33
+ <th class="column-{{ field.name }}{% if field.required %} required{% endif %} align-middle border-b border-gray-200 font-semibold px-3 py-2 text-left text-font-important-light text-sm whitespace-nowrap dark:text-font-important-dark dark:border-gray-800 {% if inline_admin_formset.opts.ordering_field and field.name == inline_admin_formset.opts.ordering_field and inline_admin_formset.opts.hide_ordering_field %}hidden{% endif %}">
25
34
  <span class="flex flex-row items-center">
26
35
  {{ field.label|capfirst }}
27
36
 
@@ -41,8 +50,8 @@
41
50
  </tr>
42
51
  </thead>
43
52
 
44
- <tbody>
45
- {% for inline_admin_form in inline_admin_formset %}
53
+ {% for inline_admin_form in inline_admin_formset %}
54
+ <tbody x-sort:item>
46
55
  {% if inline_admin_form.form.non_field_errors %}
47
56
  <tr class="row-form-errors group inline-tabular">
48
57
  <td colspan="{{ inline_admin_form|cell_count }}">
@@ -118,20 +127,32 @@
118
127
  {% with is_last_col=forloop.last %}
119
128
  {% for field in line %}
120
129
  {% if field.is_readonly or not field.field.is_hidden %}
121
- <td{% if field.field.name %} class="field-{{ field.field.name }} group field-tabular {% if field.field.errors|length > 0 %} errors{% endif %}{% if inline_admin_form.original %} p-3 lg:py-3{% else %} py-3{% endif %}{% if field.is_checkbox %} align-middle{% else %} align-top{% endif %} {% if is_last_row and not inline_admin_formset.has_add_permission %}{% if is_last_col %}border-0 {% else %}border-b lg:border-0{% endif %}{% else %}border-b{% endif %} border-gray-200 flex items-center before:capitalize before:content-[attr(data-label)] before:mr-auto before:text-gray-500 before:pr-4 lg:before:hidden font-normal px-3 text-left text-sm lg:table-cell dark:border-gray-800 {% if field.field.is_hidden %} !hidden{% endif %}"{% endif %} data-label="{{ field.field.label }}">
122
- {% if field.is_readonly %}
123
- {% include "unfold/helpers/field_readonly_value.html" with tabular=1 %}
124
- {% else %}
125
- {{ field.field }}
126
-
127
- {% if field.field.errors|length > 0 %}
128
- <div class="mt-1 text-red-600 text-sm dark:text-red-500">
129
- {% for error in field.field.errors %}
130
- {{ error }}
131
- {% endfor %}
132
- </div>
130
+ <td{% if field.field.name %} class="field-{{ field.field.name }} group field-tabular {% if field.field.errors|length > 0 %} errors{% endif %}{% if inline_admin_form.original %} p-3 lg:py-3{% else %} py-3{% endif %}{% if field.is_checkbox %} align-middle{% else %} align-top{% endif %} {% if is_last_row and not inline_admin_formset.has_add_permission %}{% if is_last_col %}border-0 {% else %}border-b lg:border-0{% endif %}{% else %}border-b{% endif %} border-gray-200 flex items-center before:capitalize before:content-[attr(data-label)] before:mr-auto before:text-gray-500 before:pr-4 lg:before:hidden font-normal px-3 text-left text-sm lg:table-cell dark:border-gray-800 {% if field.field.is_hidden %} !hidden{% endif %} {% if inline_admin_formset.opts.ordering_field and field.field.name == inline_admin_formset.opts.ordering_field and inline_admin_formset.opts.hide_ordering_field %}!hidden{% endif %}"{% endif %} data-label="{{ field.field.label }}">
131
+ <div class="flex flex-row gap-3 items-center">
132
+ {% if forloop.parentloop.counter == 1 and forloop.counter == 1 %}
133
+ {% if inline_admin_formset.opts.ordering_field %}
134
+ {% if inline_admin_form.original %}
135
+ <span class="material-symbols-outlined cursor-pointer" x-sort:handle>drag_indicator</span>
136
+ {% else %}
137
+ <span class="-mr-3" x-sort:handle></span>
138
+ {% endif %}
139
+ {% endif %}
140
+ {% endif %}
141
+
142
+ {% if field.is_readonly %}
143
+ {% include "unfold/helpers/field_readonly_value.html" with tabular=1 %}
144
+ {% else %}
145
+ {{ field.field }}
146
+
147
+ {% if field.field.errors|length > 0 %}
148
+ <div class="mt-1 text-red-600 text-sm dark:text-red-500">
149
+ {% for error in field.field.errors %}
150
+ {{ error }}
151
+ {% endfor %}
152
+ </div>
153
+ {% endif %}
133
154
  {% endif %}
134
- {% endif %}
155
+ </div>
135
156
  </td>
136
157
  {% endif %}
137
158
  {% endfor %}
@@ -152,10 +173,12 @@
152
173
  {% endif %}
153
174
  {% endwith %}
154
175
  </tr>
155
- {% endfor %}
156
- </tbody>
176
+ </tbody>
177
+ {% endfor %}
157
178
  </table>
158
179
  </div>
180
+
181
+ {% if inline_admin_formset.is_collapsible %}</details>{% endif %}
159
182
  </fieldset>
160
183
  </div>
161
184
  </div>
@@ -2,9 +2,9 @@
2
2
  {% load i18n admin_urls %}
3
3
 
4
4
  {% block breadcrumbs %}
5
- <div class="px-4 lg:px-12">
5
+ <div class="px-4 lg:px-8">
6
6
  <div class="container mb-12 mx-auto -my-3">
7
- <ul class="flex">
7
+ <ul class="flex flex-wrap">
8
8
  {% url 'admin:index' as link %}
9
9
  {% trans 'Home' as name %}
10
10
  {% include 'unfold/helpers/breadcrumb_item.html' with link=link name=name %}
@@ -1,8 +1,8 @@
1
1
  {% load i18n admin_urls %}
2
2
 
3
- <div {% if not is_popup %}id="submit-row"{% endif %} class="relative z-20 {% if not is_popup %} mt-20 lg:mt-8{% endif %}">
4
- <div class="{% if not is_popup %}bottom-0 fixed left-0 right-0{% endif %}" {% if not is_popup %}x-bind:class="{'xl:left-0': !sidebarDesktopOpen, 'xl:left-72': sidebarDesktopOpen}"{% endif %}>
5
- <div class="bg-white dark:bg-gray-900 {% if not is_popup %}border-t px-4 py-4 relative scrollable-top lg:px-12 dark:border-gray-800{% endif %}">
3
+ <div {% if not is_popup %}id="submit-row"{% endif %} class="relative mt-16 z-20">
4
+ <div class="{% if not is_popup %}lg:bottom-0 lg:fixed lg:left-0 lg:right-0{% endif %}" {% if not is_popup %}x-bind:class="{'xl:left-0': !sidebarDesktopOpen, 'xl:left-72': sidebarDesktopOpen}"{% endif %}>
5
+ <div class="bg-white dark:bg-gray-900 {% if not is_popup %}lg:border-t lg:py-4 relative scrollable-top lg:px-8 dark:border-gray-800{% endif %}">
6
6
  <div class="container flex flex-col-reverse gap-3 items-center mx-auto lg:flex-row-reverse">
7
7
  {% block submit-row %}
8
8
  {% if show_save %}
@@ -18,7 +18,7 @@
18
18
  {% endfor %}
19
19
 
20
20
  {% if show_save_and_continue %}
21
- <button type="submit" name="_continue" class="border font-medium hidden px-3 py-2 rounded-md transition-all w-full hover:bg-gray-50 lg:block lg:w-auto dark:border-gray-700 dark:hover:text-gray-200 dark:hover:bg-gray-900">
21
+ <button type="submit" name="_continue" class="border font-medium px-3 py-2 rounded-md transition-all w-full hover:bg-gray-50 lg:block lg:w-auto dark:border-gray-700 dark:hover:text-gray-200 dark:hover:bg-gray-900">
22
22
  {% if can_change %}
23
23
  {% translate 'Save and continue editing' %}
24
24
  {% else %}
@@ -30,19 +30,19 @@
30
30
  {% if show_close %}
31
31
  {% url opts|admin_urlname:'changelist' as changelist_url %}
32
32
 
33
- <a href="{% add_preserved_filters changelist_url %}" class="border font-medium hidden px-3 py-2 rounded-md transition-all w-full hover:bg-gray-50 lg:block lg:w-auto dark:border-gray-700 dark:hover:text-gray-200 dark:hover:bg-gray-900">
33
+ <a href="{% add_preserved_filters changelist_url %}" class="border font-medium px-3 py-2 rounded-md transition-all w-full hover:bg-gray-50 lg:block lg:w-auto dark:border-gray-700 dark:hover:text-gray-200 dark:hover:bg-gray-900">
34
34
  {% translate 'Close' %}
35
35
  </a>
36
36
  {% endif %}
37
37
 
38
38
  {% if show_save_and_add_another %}
39
- <button type="submit" name="_addanother" class="border font-medium hidden px-3 py-2 rounded-md transition-all w-full hover:bg-gray-50 lg:block lg:w-auto dark:border-gray-700 dark:hover:text-gray-200 dark:hover:bg-gray-900">
39
+ <button type="submit" name="_addanother" class="border font-medium px-3 py-2 rounded-md transition-all w-full hover:bg-gray-50 lg:block lg:w-auto dark:border-gray-700 dark:hover:text-gray-200 dark:hover:bg-gray-900">
40
40
  {% translate 'Save and add another' %}
41
41
  </button>
42
42
  {% endif %}
43
43
 
44
44
  {% if show_save_as_new %}
45
- <button type="submit" name="_saveasnew" class="border font-medium hidden px-3 py-2 rounded-md transition-all w-full hover:bg-gray-50 lg:block lg:w-auto dark:border-gray-700 dark:hover:text-gray-200 dark:hover:bg-gray-900">
45
+ <button type="submit" name="_saveasnew" class="border font-medium px-3 py-2 rounded-md transition-all w-full hover:bg-gray-50 lg:block lg:w-auto dark:border-gray-700 dark:hover:text-gray-200 dark:hover:bg-gray-900">
46
46
  {% translate 'Save as new' %}
47
47
  </button>
48
48
  {% endif %}
@@ -51,7 +51,7 @@
51
51
  {% url opts|admin_urlname:'delete' original.pk|admin_urlquote as delete_url %}
52
52
 
53
53
  <p class="deletelink-box mr-auto w-full lg:w-auto">
54
- <a href="{% add_preserved_filters delete_url %}" class="block border border-red-500 font-medium px-3 py-2 rounded-md text-center text-red-500 whitespace-nowrap dark:border-transparent dark:bg-red-500/20 dark:text-red-500">
54
+ <a href="{% add_preserved_filters delete_url %}" class="bg-red-600 flex items-center justify-center font-medium h-9.5 ml-auto px-3 py-2 rounded-md text-white dark:bg-red-500/20 dark:text-red-500">
55
55
  {% translate "Delete" %} {{ opts.verbose_name }}
56
56
  </a>
57
57
  </p>
@@ -7,7 +7,7 @@
7
7
  {% block breadcrumbs %}
8
8
  <div class="px-12">
9
9
  <div class="container mb-12 mx-auto -my-3">
10
- <ul class="flex">
10
+ <ul class="flex flex-wrap">
11
11
  {% url 'admin:index' as link %}
12
12
  {% trans 'Home' as name %}
13
13
  {% include 'unfold/helpers/breadcrumb_item.html' with link=link name=name %}
@@ -7,7 +7,7 @@
7
7
  {% block breadcrumbs %}
8
8
  <div class="px-12">
9
9
  <div class="container mb-12 mx-auto -my-3">
10
- <ul class="flex">
10
+ <ul class="flex flex-wrap">
11
11
  {% url 'admin:index' as link %}
12
12
  {% trans 'Home' as name %}
13
13
  {% include 'unfold/helpers/breadcrumb_item.html' with link=link name=name %}
@@ -1,11 +1,11 @@
1
- {% load i18n admin_list %}
1
+ {% load i18n admin_list unfold %}
2
2
 
3
- <div id="changelist-filter" class="backdrop-blur-sm bg-opacity-80 bg-gray-900 flex fixed inset-0 z-50" x-show="filterOpen">
4
- <label for="show-filters" id="changelist-filter-close" class="flex-grow"></label>
3
+ <div id="changelist-filter" class="backdrop-blur-sm bg-opacity-80 bg-gray-900 flex inset-0 z-50 fixed {% if not cl.model_admin.list_filter_sheet %}2xl:bg-transparent 2xl:relative 2xl:!block 2xl:z-10{% endif %}" x-show="filterOpen">
4
+ <label for="show-filters" id="changelist-filter-close" class="flex-grow {% if not cl.model_admin.list_filter_sheet %}2xl:hidden{% endif %}" x-on:click="filterOpen = false"></label>
5
5
 
6
- <div class="bg-white flex mx-4 my-4 overflow-hidden rounded shadow-sm w-96 dark:bg-gray-800" x-on:click.outside="filterOpen = false">
6
+ <div class="bg-white flex m-4 overflow-hidden rounded shadow-sm w-80 dark:bg-gray-800 {% if not cl.model_admin.list_filter_sheet %} 2xl:border 2xl:sticky 2xl:top-4 2xl:dark:border-gray-800 2xl:bg-transparent 2xl:dark:!bg-transparent 2xl:m-0{% endif %}">
7
7
  <div class="flex-grow h-full overflow-auto relative">
8
- <h3 class="border-b flex font-semibold mb-6 px-6 py-4 text-font-important-light text-sm dark:text-font-important-dark dark:border-gray-700">
8
+ <h3 class="border-b flex font-semibold mb-4 px-4 py-4 text-font-important-light text-sm dark:text-font-important-dark dark:border-gray-800">
9
9
  {% trans "Filter" %}
10
10
 
11
11
  {% if cl.is_facets_optional %}
@@ -30,31 +30,23 @@
30
30
  </a>
31
31
  {% endif %}
32
32
 
33
- <a class="cursor-pointer material-symbols-outlined md-18 ml-auto pl-4 text-gray-400 transition-colors hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-400" x-on:click="filterOpen = false">
33
+ <a class="cursor-pointer material-symbols-outlined md-18 ml-auto pl-4 text-gray-400 transition-colors hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-400 {% if not cl.model_admin.list_filter_sheet %}2xl:hidden{% endif %}" x-on:click="filterOpen = false">
34
34
  close
35
35
  </a>
36
36
  </h3>
37
37
 
38
- <div class="px-6{% if cl.model_admin.list_filter_submit %} pb-16{% endif %}">
38
+ <div class="px-4{% if cl.model_admin.list_filter_submit %} {% endif %}">
39
39
  {% if cl.model_admin.list_filter_submit %}
40
40
  <form id="filter-form" method="get">
41
-
42
- {% if request.GET.q %}
43
- <input type="hidden" name="q" value="{{ request.GET.q }}">
44
- {% endif %}
45
-
46
- {% if request.GET.o %}
47
- <input type="hidden" name="o" value="{{ request.GET.o }}">
48
- {% endif %}
41
+ {% preserve_filters %}
49
42
  {% endif %}
50
43
 
51
-
52
44
  {% for spec in cl.filter_specs %}
53
45
  {% admin_list_filter cl spec %}
54
46
  {% endfor %}
55
47
 
56
48
  {% if cl.model_admin.list_filter_submit %}
57
- <div class="bg-gray-50 border-gray-200 border-t bottom-4 fixed px-6 py-3 right-4 rounded-b w-96 dark:bg-gray-700 dark:border-gray-600">
49
+ <div class="bottom-4 absolute left-4 right-4 {% if not cl.model_admin.list_filter_sheet %}2xl:left-0 2xl:right-0 2xl:relative 2xl:mt-8{% endif %}">
58
50
  <button type="submit" class="bg-primary-600 block border border-transparent font-medium px-3 py-2 rounded-md self-end text-sm text-white w-full">
59
51
  {% trans "Apply Filters" %}
60
52
  </button>
@@ -5,7 +5,7 @@
5
5
  <span class="material-symbols-outlined">person</span>
6
6
  </a>
7
7
 
8
- <nav class="absolute bg-white border flex flex-col leading-none overflow-hidden py-1 -right-2 rounded shadow-lg top-7 w-52 z-50 dark:bg-gray-800 dark:border-gray-700" x-cloak x-show="openUserLinks" @click.outside="openUserLinks = false">
8
+ <nav class="absolute bg-white border flex flex-col leading-none py-1 -right-2 rounded shadow-lg top-7 w-52 z-50 dark:bg-gray-800 dark:border-gray-700" x-cloak x-show="openUserLinks" @click.outside="openUserLinks = false">
9
9
  <div class="border-b border-gray-100 flex flex-row flex-shrink-0 items-start justify-start mb-1 pb-1 dark:border-gray-700">
10
10
  <span class="block mx-1 px-3 py-2 truncate">
11
11
  {% firstof user.get_short_name user.get_username %}
@@ -8,13 +8,15 @@
8
8
  more_horiz
9
9
  </span>
10
10
 
11
- <nav x-anchor.offset.4="$refs.rowDropdown{{ action_id }}" class="bg-white border flex flex-col leading-none py-1 rounded-md shadow-lg text-sm top-7 z-50 w-48 dark:bg-gray-800 dark:border-gray-700" x-cloak x-show="openActionsId{{ action_id }}" @click.outside="openActionsId{{ action_id }} = false">
12
- {% for action in actions %}
13
- <a href="{% url action.raw_path instance_pk %}" class="mx-1 px-3 py-2 rounded-md truncate hover:bg-gray-100 dark:hover:bg-gray-700 dark:hover:text-gray-200"{% for attr_name, attr_value in action.attrs.items %} {{ attr_name }}="{{ attr_value }}"{% endfor %}>
14
- {{ action.title }}
15
- </a>
16
- {% endfor %}
17
- </nav>
11
+ <template x-teleport="body">
12
+ <nav x-anchor.bottom-end.offset.4="$refs.rowDropdown{{ action_id }}" class="bg-white border flex flex-col leading-none py-1 rounded-md shadow-lg text-sm top-7 z-50 w-48 dark:bg-gray-800 dark:border-gray-700" x-cloak x-show="openActionsId{{ action_id }}" @click.outside="openActionsId{{ action_id }} = false">
13
+ {% for action in actions %}
14
+ <a href="{% url action.raw_path instance_pk %}" class="mx-1 px-3 py-2 rounded-md truncate hover:bg-gray-100 dark:hover:bg-gray-700 dark:hover:text-gray-200"{% for attr_name, attr_value in action.attrs.items %} {{ attr_name }}="{{ attr_value }}"{% endfor %}>
15
+ {{ action.title }}
16
+ </a>
17
+ {% endfor %}
18
+ </nav>
19
+ </template>
18
20
  </div>
19
21
  {% endwith %}
20
22
  </td>
@@ -0,0 +1,11 @@
1
+ {% load i18n %}
2
+
3
+ <div class="flex flex-col gap-3 items-center w-full lg:flex-row">
4
+ <a href="#" class="border cancel-link flex items-center justify-center font-medium px-3 py-2 rounded-md w-full hover:bg-gray-50 lg:block lg:mb-0 lg:w-auto dark:border-gray-700 dark:text-font-default-dark dark:hover:text-gray-200 dark:hover:bg-gray-900">
5
+ {% translate "No, take me back" %}
6
+ </a>
7
+
8
+ <button type="submit" class="bg-red-600 cursor-pointer flex items-center justify-center font-medium h-9.5 ml-0 px-3 py-2 rounded-md text-white w-full lg:ml-auto lg:w-auto dark:bg-red-500/20 dark:text-red-500">
9
+ {% translate "Yes, I’m sure" %}
10
+ </button>
11
+ </div>
@@ -2,9 +2,14 @@
2
2
 
3
3
  <span class="flex gap-4 items-center">
4
4
  {% if value.3 and value.3.path %}
5
- <span class="bg-center bg-cover bg-white flex font-medium justify-center overflow-hidden dark:bg-gray-900 dark:border-gray-700 {% if value.3.squared %}rounded-sm{% else %}rounded-full{% endif %}{% if not value.3.borderless %} border{% endif %}{% if not value.3.width or not value.3.height %} h-8 max-w-8 min-w-8{% endif %}">
6
- <img loading="lazy" src="{{ value.3.path }}" class="max-w-none object-cover" {% if value.3.width %}width="{{ value.3.width }}"{% endif %} {% if value.3.height %}height="{{ value.3.height }}"{% endif %} alt="{% trans "Record picture" %}" />
7
- </span>
5
+ {% if value.3.as_background %}
6
+ <span class="block bg-center bg-contain bg-no-repeat {% if not value.3.width %}w-16{% endif %} {% if not value.3.height %}h-12{% endif %}" style="background-image: url({{ value.3.path }}); {% if value.3.height %}height: {{ value.3.height }}px;{% endif %} {% if value.3.width %}width: {{ value.3.width }}px;{% endif %}">
7
+ </span>
8
+ {% else %}
9
+ <span class="bg-center bg-cover bg-white flex font-medium justify-center overflow-hidden dark:bg-gray-900 dark:border-gray-700 {% if value.3.squared %}rounded-sm{% else %}rounded-full{% endif %}{% if not value.3.borderless %} border{% endif %}{% if not value.3.width or not value.3.height %} h-8 max-w-8 min-w-8{% endif %}">
10
+ <img loading="lazy" src="{{ value.3.path }}" class="max-w-none object-cover" {% if value.3.width %}width="{{ value.3.width }}"{% endif %} {% if value.3.height %}height="{{ value.3.height }}"{% endif %} alt="{% trans "Record picture" %}" />
11
+ </span>
12
+ {% endif %}
8
13
  {% elif value.2 %}
9
14
  <span class="bg-white border flex font-medium h-8 justify-center items-center rounded-full text-xs uppercase w-8 dark:bg-gray-900 dark:border-gray-700">
10
15
  {{ value.2 }}
@@ -1,5 +1,5 @@
1
1
  <div class="flex group mb-6 flex-col last:mb-4">
2
- <label class="block font-medium mb-2 text-gray-900 text-sm dark:text-gray-200">
2
+ <label class="block font-semibold mb-2 text-gray-900 text-sm dark:text-gray-200">
3
3
  {{ title }}
4
4
  </label>
5
5
 
@@ -1 +1 @@
1
- <div class="readonly max-w-4xl py-2 text-sm *:rounded-md {% if not adminform.model_admin.compressed_fields and not field.is_image %}bg-gray-50 border font-medium px-3 rounded-md shadow-sm dark:border-gray-700 dark:bg-gray-800{% endif %} {% if field.is_image %}inline-block [&_img]:rounded-md !py-0{% endif %}">{% if value %}{{ value }}{% elif field.contents %}{{ field.contents }}{% else %}-{% endif %}</div>
1
+ <div class="readonly {% if field.is_json %}max-w-4xl{% else %}max-w-2xl{% endif %} py-2 text-sm *:rounded-md {% if not adminform.model_admin.compressed_fields and not field.is_image %}bg-gray-50 border font-medium px-3 rounded-md shadow-sm dark:border-gray-700 dark:bg-gray-800{% endif %} {% if field.is_image %}inline-block [&_img]:rounded-md !py-0{% endif %}">{% if value %}{{ value }}{% elif field.contents %}{{ field.contents }}{% else %}-{% endif %}</div>
@@ -1,4 +1,6 @@
1
+
1
2
  <div class="form-row
3
+ {% for field in line %}{% if inline_admin_formset.opts.ordering_field and field.field.name == inline_admin_formset.opts.ordering_field and inline_admin_formset.opts.hide_ordering_field %} hidden{% endif %}{% endfor %}
2
4
  {% if adminform.model_admin.compressed_fields %} border-b border-gray-200 -mx-3 px-3 pt-3 first:pt-0 dark:border-gray-800 last:border-b-0{% endif %}
3
5
  {% if not line.fields|length == 1 %} flex flex-row flex-wrap gap-x-8{% endif %}
4
6
  {% if not line.has_visible_field %} hidden{% endif %}
@@ -1,4 +1,4 @@
1
- <label for="{{ field.id_for_label }}" class="block text-font-important-light dark:text-font-important-dark{% if field.field.widget.input_type == "checkbox" %}{% else %} font-medium mb-2{% endif %}">
1
+ <label for="{{ field.id_for_label }}" class="block text-font-important-light dark:text-font-important-dark{% if field.field.widget.input_type == "checkbox" %}{% else %} font-semibold mb-2{% endif %}">
2
2
  {{ field.label }}
3
3
 
4
4
  {% if field.field.required %}
@@ -1,6 +1,6 @@
1
1
  {% if not is_popup %}
2
2
  {% block header %}
3
- <div class="border-b border-gray-200 mb-6 px-4 lg:px-12 dark:border-gray-800">
3
+ <div class="border-b border-gray-200 mb-6 px-4 lg:px-8 dark:border-gray-800">
4
4
  <div class="{% if not cl.model_admin.list_fullwidth %}container{% endif %} flex items-center h-16 mx-auto py-4">
5
5
  <div id="header-inner" class="flex items-center w-full">
6
6
  <div class="flex items-center w-full">
@@ -10,7 +10,7 @@
10
10
  {% elif type == 'primary' %}
11
11
  bg-primary-100 text-primary-700 dark:bg-primary-500/20 dark:text-primary-400
12
12
  {% else %}
13
- bg-gray-100 text-gray-700 dark:bg-gray-500/20 dark:text-gray-400
13
+ bg-gray-100 text-gray-700 dark:bg-gray-500/20 dark:text-gray-200
14
14
  {% endif %}">
15
15
  {{ text }}
16
16
  </span>
@@ -0,0 +1,27 @@
1
+ {% load i18n %}
2
+
3
+ {% get_current_language as LANGUAGE_CODE %}
4
+ {% get_available_languages as LANGUAGES %}
5
+ {% get_language_info_list for LANGUAGES as languages %}
6
+
7
+
8
+ <div class="relative" x-data="{ openLanguageLinks: false }">
9
+ <a class="block cursor-pointer hover:text-gray-700 dark:hover:text-gray-200" x-on:click="openLanguageLinks = !openLanguageLinks">
10
+ <span class="material-symbols-outlined">translate</span>
11
+ </a>
12
+
13
+ <div class="absolute bg-white border flex flex-col leading-none py-1 -right-2 rounded shadow-lg top-7 w-52 z-50 dark:bg-gray-800 dark:border-gray-700" x-cloak x-show="openLanguageLinks" @click.outside="openLanguageLinks = false">
14
+ {% for language in languages %}
15
+ <form action="{% url 'set_language' %}" method="post" class="flex w-full">
16
+ {% csrf_token %}
17
+
18
+ <input name="next" type="hidden" value="{{ redirect_to }}">
19
+ <input name="language" type="hidden" value="{{ language.code }}">
20
+
21
+ <button type="submit" class="block flex-grow mx-1 px-3 py-2 rounded text-left hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200 {% if language.code == LANGUAGE_CODE %}text-primary-600 dark:text-primary-500 dark:hover:!text-primary-500 hover:!text-primary-600{% endif %}">
22
+ {{ language.name_local }} ({{ language.code }})
23
+ </button>
24
+ </form>
25
+ {% endfor %}
26
+ </div>
27
+ </div>
@@ -8,7 +8,7 @@
8
8
  {% for item in tabs_list %}
9
9
  {% if item.has_permission %}
10
10
  <li class="border-b last:border-b-0 md:border-b-0 md:mr-8 dark:border-gray-800">
11
- <a href="{% if item.link_callback %}{{ item.link_callback }}{% else %}{{ item.link }}{% endif %}" class="block px-3 py-2 md:py-4 md:px-0 dark:border-gray-800 {% if item.active %} border-b font-semibold -mb-px text-primary-600 hover:text-primary-600 dark:text-primary-500 dark:hover:text-primary-500 md:border-primary-500 dark:md:!border-primary-600{% else %}font-medium hover:text-gray-700 dark:hover:text-gray-200{% endif %}">
11
+ <a href="{% if item.link_callback %}{{ item.link_callback }}{% else %}{{ item.link }}{% endif %}" class="block px-3 py-2 md:py-4 md:px-0 dark:border-gray-800 {% if item.active %} border-b font-semibold -mb-px text-primary-600 hover:text-primary-600 dark:text-primary-500 dark:hover:text-primary-500 md:border-primary-500 dark:md:!border-primary-600{% else %}font-medium hover:text-primary-600 dark:hover:text-primary-500{% endif %}">
12
12
  {{ item.title }}
13
13
  </a>
14
14
  </li>
@@ -20,7 +20,7 @@
20
20
  <a class="block cursor-pointer font-medium px-3 py-2 md:py-4 md:px-0"
21
21
  href="#general"
22
22
  x-on:click="activeTab = 'general'"
23
- x-bind:class="{'border-b border-gray-200 dark:border-gray-800 md:border-primary-500 dark:md:!border-primary-600 font-semibold -mb-px text-primary-600 dark:text-primary-500': activeTab == 'general', 'hover:text-gray-700 dark:hover:text-gray-200 dark:border-gray-800': activeTab != 'general'}">
23
+ x-bind:class="{'border-b border-gray-200 dark:border-gray-800 md:border-primary-500 dark:md:!border-primary-600 font-semibold -mb-px text-primary-600 dark:text-primary-500': activeTab == 'general', 'hover:text-primary-600 dark:hover:text-primary-500 dark:border-gray-800': activeTab != 'general'}">
24
24
  {% trans "General" %}
25
25
  </a>
26
26
  </li>
@@ -30,7 +30,7 @@
30
30
  <a class="block cursor-pointer font-medium px-3 py-2 md:py-4 md:px-0"
31
31
  href="#{{ inline.opts.verbose_name|slugify }}"
32
32
  x-on:click="activeTab = '{{ inline.opts.verbose_name|slugify }}'"
33
- x-bind:class="{'border-b border-gray-200 dark:border-gray-800 md:border-primary-500 dark:md:!border-primary-600 font-semibold -mb-px text-primary-600 dark:text-primary-500': activeTab == '{{ inline.opts.verbose_name|slugify }}', 'hover:text-gray-700 dark:hover:text-gray-200 dark:border-gray-800': activeTab != '{{ inline.opts.verbose_name|slugify }}'}">
33
+ x-bind:class="{'border-b border-gray-200 dark:border-gray-800 md:border-primary-500 dark:md:!border-primary-600 font-semibold -mb-px text-primary-600 dark:text-primary-500': activeTab == '{{ inline.opts.verbose_name|slugify }}', 'hover:text-primary-600 dark:hover:text-primary-500 dark:border-gray-800': activeTab != '{{ inline.opts.verbose_name|slugify }}'}">
34
34
  {% if inline.formset.max_num == 1 %}
35
35
  {{ inline.opts.verbose_name|capfirst }}
36
36
  {% else %}
@@ -7,7 +7,7 @@
7
7
  </span>
8
8
  </a>
9
9
 
10
- <nav class="absolute bg-white border flex flex-col leading-none overflow-hidden py-1 -right-2 rounded shadow-lg top-7 w-40 z-50 dark:bg-gray-800 dark:border-gray-700" x-cloak x-show="openTheme" @click.outside="openTheme = false">
10
+ <nav class="absolute bg-white border flex flex-col leading-none py-1 -right-2 rounded shadow-lg top-7 w-40 z-50 dark:bg-gray-800 dark:border-gray-700" x-cloak x-show="openTheme" @click.outside="openTheme = false">
11
11
  <a class="cursor-pointer flex flex-row leading-none mx-1 px-3 py-1.5 rounded hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200"
12
12
  x-on:click="adminTheme = 'dark'"
13
13
  x-bind:class="adminTheme == 'dark' && 'text-primary-600 dark:text-primary-500 dark:hover:!text-primary-500 hover:!text-primary-600'">
@@ -7,6 +7,10 @@
7
7
  {% include "unfold/helpers/label.html" with text=environment.0 type=environment.1 %}
8
8
  {% endif %}
9
9
 
10
+ {% if show_languages %}
11
+ {% include "unfold/helpers/language_switch.html" %}
12
+ {% endif %}
13
+
10
14
  {% if not theme %}
11
15
  {% include "unfold/helpers/theme_switch.html" %}
12
16
  {% endif %}
@@ -21,7 +21,7 @@
21
21
  {% endspaceless %}
22
22
  {% endif %}
23
23
 
24
- <div class="px-4 lg:px-12">
24
+ <div class="px-4 lg:px-8">
25
25
  <div id="content" class="container mx-auto {% block coltype %}colM{% endblock %}">
26
26
  {% block content %}
27
27
  {% block object-tools %}{% endblock %}
@@ -33,6 +33,7 @@
33
33
 
34
34
  <script src="{% static 'unfold/js/alpine.anchor.js' %}" defer></script>
35
35
  <script src="{% static 'unfold/js/alpine.persist.js' %}" defer></script>
36
+ <script src="{% static 'unfold/js/alpine.sort.js' %}" defer></script>
36
37
  <script src="{% static 'unfold/js/alpine.js' %}" defer></script>
37
38
  <script src="{% static 'unfold/js/htmx.js' %}"></script>
38
39
  <script src="{% static 'unfold/js/chart.js' %}"></script>
@@ -0,0 +1,3 @@
1
+ {% for key, value in params.items %}
2
+ <input type="hidden" name="{{ key }}" value="{{ value }}">
3
+ {% endfor %}
@@ -1,4 +1,4 @@
1
- <div class="datetime flex flex-col max-w-2xl">
1
+ <div class="datetime flex flex-col max-w-2xl w-full">
2
2
  <div class="flex flex-col flex-wrap mb-2">
3
3
  {% if date_label %}
4
4
  <div class="mb-2">
@@ -1,7 +1,9 @@
1
- <div class="flex flex-row gap-2 items-center">
2
- {% include "django/forms/widgets/input.html" %}
1
+ <div class="flex flex-col gap-2">
2
+ {% include "django/forms/widgets/input.html" %}
3
3
 
4
- {% if url_valid %}
5
- {{ current_label }} <a href="{{ widget.href }}" class="text-primary-600 dark:text-primary-500">{{ widget.value }}</a>
6
- {% endif %}
4
+ {% if url_valid %}
5
+ <p class="text-xs">
6
+ {{ current_label }} <a href="{{ widget.href }}" class="text-primary-600 dark:text-primary-500">{{ widget.value }}</a>
7
+ </p>
8
+ {% endif %}
7
9
  </div>
@@ -1,9 +1,11 @@
1
- from typing import Any, Dict, List, Mapping, Optional, Union
1
+ from typing import Any, Dict, List, Mapping, Optional, Set, Union
2
2
 
3
3
  from django import template
4
4
  from django.contrib.admin.helpers import AdminForm, Fieldset
5
+ from django.contrib.admin.views.main import ChangeList
5
6
  from django.forms import Field
6
- from django.template import Library, Node, RequestContext, TemplateSyntaxError
7
+ from django.http import HttpRequest
8
+ from django.template import Context, Library, Node, RequestContext, TemplateSyntaxError
7
9
  from django.template.base import NodeList, Parser, Token, token_kwargs
8
10
  from django.template.loader import render_to_string
9
11
  from django.utils.safestring import SafeText
@@ -224,3 +226,28 @@ def add_css_class(field: Field, classes: Union[list, tuple]) -> Field:
224
226
  field.field.widget.attrs["class"] = classes
225
227
 
226
228
  return field
229
+
230
+
231
+ @register.inclusion_tag(
232
+ "unfold/templatetags/preserve_changelist_filters.html",
233
+ takes_context=True,
234
+ name="preserve_filters",
235
+ )
236
+ def preserve_changelist_filters(context: Context) -> Dict[str, Dict[str, str]]:
237
+ """
238
+ Generate hidden input fields to preserve filters for POST forms.
239
+ """
240
+ request: Optional[HttpRequest] = context.get("request")
241
+ changelist: Optional[ChangeList] = context.get("cl")
242
+
243
+ if not request or not changelist:
244
+ return {"params": {}}
245
+
246
+ used_params: Set[str] = {
247
+ param for spec in changelist.filter_specs for param in spec.used_parameters
248
+ }
249
+ preserved_params: Dict[str, str] = {
250
+ param: value for param, value in request.GET.items() if param not in used_params
251
+ }
252
+
253
+ return {"params": preserved_params}
unfold/utils.py CHANGED
@@ -3,6 +3,7 @@ import decimal
3
3
  import json
4
4
  from typing import Any, Iterable, List, Optional
5
5
 
6
+ from django.conf import settings
6
7
  from django.db import models
7
8
  from django.template.loader import render_to_string
8
9
  from django.utils import formats, timezone
@@ -146,3 +147,19 @@ def prettify_json(data: Any) -> Optional[str]:
146
147
  f'<div class="block dark:hidden">{format_response(response, "colorful")}</div>'
147
148
  f'<div class="hidden dark:block">{format_response(response, "monokai")}</div>'
148
149
  )
150
+
151
+
152
+ def parse_date_str(value: str) -> Optional[datetime.date]:
153
+ for format in settings.DATE_INPUT_FORMATS:
154
+ try:
155
+ return datetime.datetime.strptime(value, format).date()
156
+ except (ValueError, TypeError):
157
+ continue
158
+
159
+
160
+ def parse_datetime_str(value: str) -> Optional[datetime.datetime]:
161
+ for format in settings.DATETIME_INPUT_FORMATS:
162
+ try:
163
+ return datetime.datetime.strptime(value, format)
164
+ except (ValueError, TypeError):
165
+ continue
unfold/widgets.py CHANGED
@@ -35,7 +35,7 @@ from .exceptions import UnfoldException
35
35
 
36
36
  LABEL_CLASSES = [
37
37
  "block",
38
- "font-medium",
38
+ "font-semibold",
39
39
  "mb-2",
40
40
  "text-font-important-light",
41
41
  "text-sm",
@@ -43,7 +43,7 @@ LABEL_CLASSES = [
43
43
  ]
44
44
 
45
45
  CHECKBOX_LABEL_CLASSES = [
46
- "font-medium",
46
+ "font-semibold",
47
47
  "ml-2",
48
48
  "text-sm",
49
49
  "text-font-important-light",
@@ -332,6 +332,8 @@ class UnfoldAdminImageSmallFieldWidget(FileFieldMixin, AdminFileWidget):
332
332
 
333
333
 
334
334
  class UnfoldAdminDateWidget(AdminDateWidget):
335
+ template_name = "unfold/widgets/date.html"
336
+
335
337
  def __init__(
336
338
  self, attrs: Optional[Dict[str, Any]] = None, format: Optional[str] = None
337
339
  ) -> None:
@@ -358,6 +360,8 @@ class UnfoldAdminSingleDateWidget(AdminDateWidget):
358
360
 
359
361
 
360
362
  class UnfoldAdminTimeWidget(AdminTimeWidget):
363
+ template_name = "unfold/widgets/time.html"
364
+
361
365
  def __init__(
362
366
  self, attrs: Optional[Dict[str, Any]] = None, format: Optional[str] = None
363
367
  ) -> None: