django-unfold 0.22.0__py3-none-any.whl → 0.23.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.22.0.dist-info → django_unfold-0.23.0.dist-info}/METADATA +7 -2
- {django_unfold-0.22.0.dist-info → django_unfold-0.23.0.dist-info}/RECORD +30 -30
- unfold/admin.py +29 -22
- unfold/apps.py +5 -0
- unfold/checks.py +1 -1
- unfold/forms.py +6 -1
- unfold/sites.py +3 -3
- unfold/static/unfold/css/styles.css +1 -1
- unfold/styles.css +11 -4
- unfold/templates/admin/actions.html +9 -9
- unfold/templates/admin/app_list.html +6 -8
- unfold/templates/admin/base.html +1 -3
- unfold/templates/admin/change_form.html +1 -2
- unfold/templates/admin/change_list.html +2 -2
- unfold/templates/admin/change_list_results.html +15 -3
- unfold/templates/admin/edit_inline/tabular.html +3 -3
- unfold/templates/admin/search_form.html +10 -12
- unfold/templates/unfold/helpers/tab_list.html +1 -1
- unfold/templates/unfold/layouts/base_simple.html +1 -1
- unfold/templates/unfold/widgets/date.html +1 -1
- unfold/templates/{admin → unfold}/widgets/related_widget_wrapper.html +4 -4
- unfold/templates/unfold/widgets/time.html +1 -1
- unfold/templatetags/unfold_list.py +8 -6
- unfold/widgets.py +16 -3
- {django_unfold-0.22.0.dist-info → django_unfold-0.23.0.dist-info}/LICENSE.md +0 -0
- {django_unfold-0.22.0.dist-info → django_unfold-0.23.0.dist-info}/WHEEL +0 -0
- /unfold/templates/{admin → unfold}/widgets/clearable_file_input.html +0 -0
- /unfold/templates/{admin → unfold}/widgets/radio.html +0 -0
- /unfold/templates/{admin → unfold}/widgets/radio_option.html +0 -0
- /unfold/templates/{admin → unfold}/widgets/split_datetime.html +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: django-unfold
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.23.0
|
4
4
|
Summary: Modern Django admin theme for seamless interface development
|
5
5
|
Home-page: https://unfoldadmin.com
|
6
6
|
License: MIT
|
@@ -59,6 +59,7 @@ Did you decide to start using Unfold but you don't have time to make the switch
|
|
59
59
|
- **Colors:** possibility to override default color scheme
|
60
60
|
- **Third party packages:** default support for multiple popular applications
|
61
61
|
- **Environment label**: distinguish between environments by displaying a label
|
62
|
+
- **Parallel admin**: support for having default admin in parallel with Unfold
|
62
63
|
- **VS Code**: project configuration and development container is included
|
63
64
|
|
64
65
|
## Table of contents <!-- omit from toc -->
|
@@ -708,6 +709,10 @@ class CrontabScheduleAdmin(ModelAdmin):
|
|
708
709
|
@admin.register(SolarSchedule)
|
709
710
|
class SolarScheduleAdmin(ModelAdmin):
|
710
711
|
pass
|
712
|
+
|
713
|
+
@admin.register(ClockedSchedule)
|
714
|
+
class ClockedScheduleAdmin(ModelAdmin):
|
715
|
+
pass
|
711
716
|
```
|
712
717
|
|
713
718
|
### django-guardian
|
@@ -737,7 +742,7 @@ When implementing `import_export.admin.ExportActionModelAdmin` class in admin pa
|
|
737
742
|
admin.py
|
738
743
|
|
739
744
|
from unfold.admin import ModelAdmin
|
740
|
-
from unfold.contrib.import_export import ExportActionModelAdmin
|
745
|
+
from unfold.contrib.import_export.admin import ExportActionModelAdmin
|
741
746
|
|
742
747
|
class ExampleAdmin(ModelAdmin, ExportActionModelAdmin):
|
743
748
|
pass
|
@@ -1,7 +1,7 @@
|
|
1
1
|
unfold/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
unfold/admin.py,sha256=
|
3
|
-
unfold/apps.py,sha256=
|
4
|
-
unfold/checks.py,sha256=
|
2
|
+
unfold/admin.py,sha256=JjfiJhWSdhDBMK3cf6IsCyGwv5povQgAZtzeHWKrEtA,23792
|
3
|
+
unfold/apps.py,sha256=SlBXPYrUd2uXn67qFbRvbXSUk3XFWrF4-5WELgDCvho,381
|
4
|
+
unfold/checks.py,sha256=Smgji9w19hnYjJElJ_FJnnyTEAE-E-OUB6otHu7lasY,1670
|
5
5
|
unfold/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
unfold/contrib/filters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
unfold/contrib/filters/admin.py,sha256=7FJl86b407ylTjgkRN2EwXGHnnVNwBiGvA1_822L5uc,16412
|
@@ -58,10 +58,10 @@ unfold/contrib/simple_history/templates/simple_history/submit_line.html,sha256=n
|
|
58
58
|
unfold/dataclasses.py,sha256=JJdGYzQ8MpeOe2FQPJqrMn_UJcxUz1VJgHCuCtkZCA8,199
|
59
59
|
unfold/decorators.py,sha256=BVDlxhZxB4ND3f5-5oiENRTv_W_Q_Eu-gZlsrYKOxiU,3272
|
60
60
|
unfold/exceptions.py,sha256=gcCj1ox61E137bk_0Cqy4YC3SttdPgB-fiJUqpmyHSE,43
|
61
|
-
unfold/forms.py,sha256=
|
61
|
+
unfold/forms.py,sha256=SzdyBC5wqE5IcoZWS2oXObycmfmICHsqlS3X03mw4QA,3468
|
62
62
|
unfold/settings.py,sha256=--TdTSWdOA8TQGW4-vjJkjy_zEyd_kZwBr3BIuQ8hzI,1208
|
63
|
-
unfold/sites.py,sha256=
|
64
|
-
unfold/static/unfold/css/styles.css,sha256=
|
63
|
+
unfold/sites.py,sha256=Gy_i43j2nizW2g8-mas5icvtk-beKism_CznATW6Ia8,12586
|
64
|
+
unfold/static/unfold/css/styles.css,sha256=DjRQV4lwg81SmOyR1YRs1QWHNA0FdV7XYRiYP33lTig,91399
|
65
65
|
unfold/static/unfold/fonts/inter/Inter-Bold.woff2,sha256=O88EyjAeRPE_QEyKBKpK5wf2epUOEu8wwjj5bnhCZqE,46552
|
66
66
|
unfold/static/unfold/fonts/inter/Inter-Medium.woff2,sha256=O88EyjAeRPE_QEyKBKpK5wf2epUOEu8wwjj5bnhCZqE,46552
|
67
67
|
unfold/static/unfold/fonts/inter/Inter-Regular.woff2,sha256=O88EyjAeRPE_QEyKBKpK5wf2epUOEu8wwjj5bnhCZqE,46552
|
@@ -74,24 +74,24 @@ unfold/static/unfold/js/alpine.persist.js,sha256=84PZYnPi25AFm7wIWRe1gzA74c5Rv2V
|
|
74
74
|
unfold/static/unfold/js/app.js,sha256=CIitJoFqpeZYPw8icGVXYX9tVRUgqFxcPZ2WjWS8Ylk,5288
|
75
75
|
unfold/static/unfold/js/chart.js,sha256=22W6cFERR-CElMOKRgMMicueMVP0Vf7FBEBYH8Z8tCk,200633
|
76
76
|
unfold/static/unfold/js/htmx.js,sha256=XOLqvnZiyEx46EW9vaJTBUaaWg8CGVVfXJkVsUmJbpI,42820
|
77
|
-
unfold/styles.css,sha256=
|
78
|
-
unfold/templates/admin/actions.html,sha256=
|
77
|
+
unfold/styles.css,sha256=dlTJBzFvZEfH9xSs2AJ9nfzYTnxf8muCMa8COifqmzU,17598
|
78
|
+
unfold/templates/admin/actions.html,sha256=1tVlUpLoM72K2Ew4vQGcRwPjHuAtO5Jm4QdDsDLOq0I,2625
|
79
79
|
unfold/templates/admin/app_index.html,sha256=lVjMIFsspHQ09LGHKfdfg7TlqlL39AX5LbwoeoZjFhk,1335
|
80
|
-
unfold/templates/admin/app_list.html,sha256=
|
80
|
+
unfold/templates/admin/app_list.html,sha256=7u2Ex0ArdC0CJNCTDnTEZpAXI_xbNQ1nrzAH4BuInNA,3009
|
81
81
|
unfold/templates/admin/auth/user/add_form.html,sha256=iLig-vd2YExXsj0xGBwYhZ4kGUihwYtLtNVhzObgSzg,478
|
82
82
|
unfold/templates/admin/auth/user/change_password.html,sha256=-Wa9ml3yss-kDz0YQxCiwoxs91KQD8eetCt5l6xekWM,2892
|
83
|
-
unfold/templates/admin/base.html,sha256=
|
83
|
+
unfold/templates/admin/base.html,sha256=MGqtCcydXZPnp6dasaWktyd9D6rdUYX01rFGAv7Zkm4,2226
|
84
84
|
unfold/templates/admin/base_site.html,sha256=3ckWrcAdd7Pw1hk6Zwyknab_Qb-rteV9-mXhMnfo6VI,361
|
85
|
-
unfold/templates/admin/change_form.html,sha256
|
85
|
+
unfold/templates/admin/change_form.html,sha256=-X_fQOGaa6k0WVbMO7he9bZIdIY3oj8PyRSV4dnt6qA,5320
|
86
86
|
unfold/templates/admin/change_form_object_tools.html,sha256=eyeH-i2HgEM0Yi-OJA2D1VnKJyC19A_my1IDGxxoP8Y,593
|
87
|
-
unfold/templates/admin/change_list.html,sha256=
|
87
|
+
unfold/templates/admin/change_list.html,sha256=18GDZswc1c0xtw2BcKti9SX95Ar9e1BX_HSY0K79g_8,5102
|
88
88
|
unfold/templates/admin/change_list_object_tools.html,sha256=cmMiT2nT20Ph5yfpj9aHPr76Z-JP4aSXp0o-Rnad28s,147
|
89
|
-
unfold/templates/admin/change_list_results.html,sha256=
|
89
|
+
unfold/templates/admin/change_list_results.html,sha256=32zSgJ6W5uQlfzI-0N1FmCFagw2VYaXuiUZyZbxUIag,5004
|
90
90
|
unfold/templates/admin/date_hierarchy.html,sha256=BfUPbsLpHZVa40BHBahz1H9RSVuz36Jc3yrlobOiIpw,1306
|
91
91
|
unfold/templates/admin/delete_confirmation.html,sha256=hpa2E14oZEXBBs6W1qdNQuF650TIO2Rhr52Q6UfwVeQ,5166
|
92
92
|
unfold/templates/admin/delete_selected_confirmation.html,sha256=Foka2yvwAMEZre-Kh1KNadRzrCotdKM2U4e6AJQYZu8,4941
|
93
93
|
unfold/templates/admin/edit_inline/stacked.html,sha256=U6O_r9-5Hp7mT0l1EgTeBB8tc9nEAAi0etL2aCU2pBM,4415
|
94
|
-
unfold/templates/admin/edit_inline/tabular.html,sha256=
|
94
|
+
unfold/templates/admin/edit_inline/tabular.html,sha256=YOrCgAQ9apLZf8VtFmUhK-WFoQomPtlilT9ktkEFBQA,12315
|
95
95
|
unfold/templates/admin/filter.html,sha256=JAp95Mg6W2Pfdrr-gxEZld9EvgMGLj8etMdSl84l4ro,1686
|
96
96
|
unfold/templates/admin/includes/fieldset.html,sha256=r4XjcZAOkWxHQExHZBWoCGtO3LYL0Iwkw1C55oR5V6M,2898
|
97
97
|
unfold/templates/admin/includes/object_delete_summary.html,sha256=Nv69SCzyJHFX14iJFfodxKM0IIpQegKZH0fvKB15QJI,468
|
@@ -100,13 +100,8 @@ unfold/templates/admin/login.html,sha256=WdOfFLofwBWj9VKCq1U22uLY19J2YQY6vRaE4OO
|
|
100
100
|
unfold/templates/admin/nav_sidebar.html,sha256=63lUhsHfrjZowplnOEq4BkGD9jlX0bVQw5VrAMJqf5M,1178
|
101
101
|
unfold/templates/admin/object_history.html,sha256=PsbhXFd_3SCB9YkSJeHESp2VqjNlHtUW26mRtaZ-MD0,5069
|
102
102
|
unfold/templates/admin/pagination.html,sha256=KWTPV7_hVSZ1374a-pqHXhnOueNQKu1UnSUYirrWtCk,1173
|
103
|
-
unfold/templates/admin/search_form.html,sha256=
|
103
|
+
unfold/templates/admin/search_form.html,sha256=8fJlPYHQDCm4Je05wwdNJuJQR6ChLgghWmo-yHSybMs,1099
|
104
104
|
unfold/templates/admin/submit_line.html,sha256=Oi7lUe2oh8O4--ZM0eQzVtZQnRKVeVXylc1ECGA7zKI,4247
|
105
|
-
unfold/templates/admin/widgets/clearable_file_input.html,sha256=vXsyP0-YD-z3z6VL4vXW9pJH9_-ZU9u-3AnmZkni-R4,1994
|
106
|
-
unfold/templates/admin/widgets/radio.html,sha256=3WcmclQNg7R_pRjEHL1dHkGjAzWlWNYnhHkAirC4nuA,646
|
107
|
-
unfold/templates/admin/widgets/radio_option.html,sha256=IZgPx-aWKJuxrSalJ3K50RFd1vwSpb9Qk0yZwfV78_A,368
|
108
|
-
unfold/templates/admin/widgets/related_widget_wrapper.html,sha256=U6RaeR86xbi1AWUrMm1SbjlXGwpC3PZdNLTbk3alxXI,3799
|
109
|
-
unfold/templates/admin/widgets/split_datetime.html,sha256=eXLFZyCv84LCTFWAUhNO3xAIzWvGBvI1ZpYbB38_HOI,862
|
110
105
|
unfold/templates/auth/widgets/read_only_password_hash.html,sha256=Li9efo-3cFC5zj9im0SPfc62R4ZNVPQhs24H1U7xmD8,785
|
111
106
|
unfold/templates/registration/logged_out.html,sha256=E7RHtB6AGQwgUIiV7dwJ1DbdfNvEhzJARONnB6jRLhQ,1028
|
112
107
|
unfold/templates/registration/password_change_done.html,sha256=i1ZzfTwZHWNWoN9_xHZDdcgLdTOVbTFFD1HUSuG0LkY,1062
|
@@ -153,27 +148,32 @@ unfold/templates/unfold/helpers/site_icon.html,sha256=RO-R5yRt6yOx41Z8dpDP4lzwMX
|
|
153
148
|
unfold/templates/unfold/helpers/site_logo.html,sha256=05tqXzHy--pluceRQ2jDUZCFX9DjPHdBqGaieUv9sXk,424
|
154
149
|
unfold/templates/unfold/helpers/submit.html,sha256=oSzq85LRLhdOlbFtFZFhYm6ucT95u6LunTeSTDClszQ,206
|
155
150
|
unfold/templates/unfold/helpers/tab_action.html,sha256=wanUlr_CKqSjxvKC7_moHFWK-hd7aT3KDdNATkJE2XE,337
|
156
|
-
unfold/templates/unfold/helpers/tab_list.html,sha256=
|
151
|
+
unfold/templates/unfold/helpers/tab_list.html,sha256=WMFSx0HEvylI_AOIPtFuWff1ePJkY6HS-PhRwo0EBUk,2029
|
157
152
|
unfold/templates/unfold/helpers/theme_switch.html,sha256=skkl6fYUnYLM7fAPivHxWjnOnuQSKa-7aDxh7I8dGIg,2266
|
158
153
|
unfold/templates/unfold/helpers/userlinks.html,sha256=qWjtBt9Q_tU8a874ii0Qqg8t_d-SSYBTB_3QZfNlx9g,634
|
159
154
|
unfold/templates/unfold/helpers/welcomemsg.html,sha256=noRysgSENef4_53pXaTiBCy2or6lQm1ZtmCQVODAB1c,1120
|
160
|
-
unfold/templates/unfold/layouts/base_simple.html,sha256=
|
155
|
+
unfold/templates/unfold/layouts/base_simple.html,sha256=rki7n7QagHFAaCEn488pTOj9dpNL9AwwzKps8Ipiubk,993
|
161
156
|
unfold/templates/unfold/layouts/skeleton.html,sha256=D35u-G6-h5SwTMzIZaEURedsPObSjoB198lLsJwmZWs,3278
|
157
|
+
unfold/templates/unfold/widgets/clearable_file_input.html,sha256=vXsyP0-YD-z3z6VL4vXW9pJH9_-ZU9u-3AnmZkni-R4,1994
|
162
158
|
unfold/templates/unfold/widgets/clearable_file_input_small.html,sha256=rqUnHF4jwL8_RySUuq2aXgj-0P_usgo1HeVT_IcfyFY,2531
|
163
|
-
unfold/templates/unfold/widgets/date.html,sha256=
|
159
|
+
unfold/templates/unfold/widgets/date.html,sha256=WXo2LG1v_gBZBSg-zocj7oujMKI0MWLYCIFfB04HMLQ,122
|
160
|
+
unfold/templates/unfold/widgets/radio.html,sha256=3WcmclQNg7R_pRjEHL1dHkGjAzWlWNYnhHkAirC4nuA,646
|
161
|
+
unfold/templates/unfold/widgets/radio_option.html,sha256=IZgPx-aWKJuxrSalJ3K50RFd1vwSpb9Qk0yZwfV78_A,368
|
164
162
|
unfold/templates/unfold/widgets/range.html,sha256=28FBtSUgUcG82vpk_I27Lbs5oWZOV_oMzVhx4wj3-Ik,262
|
163
|
+
unfold/templates/unfold/widgets/related_widget_wrapper.html,sha256=0I6wSu8z_sJPqmX6uZev4mQGIIM336d6kvHdHj36ny4,3831
|
164
|
+
unfold/templates/unfold/widgets/split_datetime.html,sha256=eXLFZyCv84LCTFWAUhNO3xAIzWvGBvI1ZpYbB38_HOI,862
|
165
165
|
unfold/templates/unfold/widgets/split_datetime_vertical.html,sha256=xinCH4kkQ-yKUqcSI7-m-_UEzOEKWqvLTjUa3i-e8EM,881
|
166
166
|
unfold/templates/unfold/widgets/split_money.html,sha256=AFLUBmzGbY-RXgsfz7gaDxVRhplaIPhXjg_hWYo9xcY,352
|
167
167
|
unfold/templates/unfold/widgets/textarea.html,sha256=4xIGWb20DuwiwumndByrAyh7xF-ReXKLulSpDImX_cs,459
|
168
|
-
unfold/templates/unfold/widgets/time.html,sha256=
|
168
|
+
unfold/templates/unfold/widgets/time.html,sha256=WXo2LG1v_gBZBSg-zocj7oujMKI0MWLYCIFfB04HMLQ,122
|
169
169
|
unfold/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
170
170
|
unfold/templatetags/unfold.py,sha256=HFe0GrTD4va0lLzsZhxqjEOONmehqOWdf5vulkxgfGU,6302
|
171
|
-
unfold/templatetags/unfold_list.py,sha256=
|
171
|
+
unfold/templatetags/unfold_list.py,sha256=5xAjQX0_JnVwDaj-wGkGqbjOAtp-a18koWIKj5VfBz0,13867
|
172
172
|
unfold/typing.py,sha256=1P8PWM2oeaceUJtA5j071RbKEBpHYaux441u7Hd6wv4,643
|
173
173
|
unfold/utils.py,sha256=5OIgDcwvIJQbwbnnqHx61cHh-2T1h184mTAuNq5WXLI,4088
|
174
174
|
unfold/views.py,sha256=Ml3XlEoHLcbEWof59Dw8ihKBMcmp-gBAibThtBFj55A,708
|
175
|
-
unfold/widgets.py,sha256=
|
176
|
-
django_unfold-0.
|
177
|
-
django_unfold-0.
|
178
|
-
django_unfold-0.
|
179
|
-
django_unfold-0.
|
175
|
+
unfold/widgets.py,sha256=e2yGwpyO7VT1NoSj0VzzRlmQZIzREAKOgp7CkyZ4hv0,14204
|
176
|
+
django_unfold-0.23.0.dist-info/LICENSE.md,sha256=Ltk_quRyyvV3J5v3brtOqmibeZSw2Hrb8bY1W3ya0Ik,1077
|
177
|
+
django_unfold-0.23.0.dist-info/METADATA,sha256=j8ueC2Ym74SeXEcdOxhx1KT4JfRLK7kO1pjj1rmlqdI,42827
|
178
|
+
django_unfold-0.23.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
179
|
+
django_unfold-0.23.0.dist-info/RECORD,,
|
unfold/admin.py
CHANGED
@@ -8,6 +8,7 @@ from django.contrib.admin import StackedInline as BaseStackedInline
|
|
8
8
|
from django.contrib.admin import TabularInline as BaseTabularInline
|
9
9
|
from django.contrib.admin import display, helpers
|
10
10
|
from django.contrib.admin.utils import lookup_field
|
11
|
+
from django.contrib.admin.widgets import RelatedFieldWidgetWrapper
|
11
12
|
from django.core.exceptions import ObjectDoesNotExist
|
12
13
|
from django.db import models
|
13
14
|
from django.db.models import (
|
@@ -39,7 +40,6 @@ from django.utils.safestring import SafeText, mark_safe
|
|
39
40
|
from django.utils.text import capfirst
|
40
41
|
from django.utils.translation import gettext_lazy as _
|
41
42
|
from django.views import View
|
42
|
-
from unfold.utils import display_for_field
|
43
43
|
|
44
44
|
from .checks import UnfoldModelAdminChecks
|
45
45
|
from .dataclasses import UnfoldAction
|
@@ -47,9 +47,9 @@ from .exceptions import UnfoldException
|
|
47
47
|
from .forms import ActionForm
|
48
48
|
from .settings import get_config
|
49
49
|
from .typing import FieldsetsType
|
50
|
+
from .utils import display_for_field
|
50
51
|
from .widgets import (
|
51
52
|
CHECKBOX_LABEL_CLASSES,
|
52
|
-
INPUT_CLASSES,
|
53
53
|
LABEL_CLASSES,
|
54
54
|
SELECT_CLASSES,
|
55
55
|
UnfoldAdminBigIntegerFieldWidget,
|
@@ -62,6 +62,7 @@ from .widgets import (
|
|
62
62
|
UnfoldAdminMoneyWidget,
|
63
63
|
UnfoldAdminNullBooleanSelectWidget,
|
64
64
|
UnfoldAdminRadioSelectWidget,
|
65
|
+
UnfoldAdminSelect,
|
65
66
|
UnfoldAdminSingleDateWidget,
|
66
67
|
UnfoldAdminSingleTimeWidget,
|
67
68
|
UnfoldAdminSplitDateTimeWidget,
|
@@ -142,6 +143,11 @@ class UnfoldAdminField(helpers.AdminField):
|
|
142
143
|
def label_tag(self) -> SafeText:
|
143
144
|
classes = []
|
144
145
|
|
146
|
+
if not self.field.field.widget.__class__.__name__.startswith(
|
147
|
+
"Unfold"
|
148
|
+
) and not self.field.field.widget.template_name.startswith("unfold"):
|
149
|
+
return super().label_tag()
|
150
|
+
|
145
151
|
# TODO load config from current AdminSite (override Fieldline.__iter__ method)
|
146
152
|
for lang, flag in get_config()["EXTENSIONS"]["modeltranslation"][
|
147
153
|
"flags"
|
@@ -175,6 +181,9 @@ helpers.AdminField = UnfoldAdminField
|
|
175
181
|
|
176
182
|
class UnfoldAdminReadonlyField(helpers.AdminReadonlyField):
|
177
183
|
def label_tag(self) -> SafeText:
|
184
|
+
if not isinstance(self.model_admin, ModelAdmin):
|
185
|
+
return super().label_tag()
|
186
|
+
|
178
187
|
attrs = {
|
179
188
|
"class": " ".join(LABEL_CLASSES + ["mb-2"]),
|
180
189
|
}
|
@@ -285,9 +294,7 @@ class ModelAdminMixin:
|
|
285
294
|
radio_style=self.radio_fields[db_field.name]
|
286
295
|
)
|
287
296
|
else:
|
288
|
-
kwargs["widget"] =
|
289
|
-
attrs={"class": " ".join(SELECT_CLASSES)}
|
290
|
-
)
|
297
|
+
kwargs["widget"] = UnfoldAdminSelect()
|
291
298
|
|
292
299
|
kwargs["choices"] = db_field.get_choices(
|
293
300
|
include_blank=db_field.blank, blank_choice=[("", _("Select value"))]
|
@@ -301,16 +308,12 @@ class ModelAdminMixin:
|
|
301
308
|
# Overrides widgets for all related fields
|
302
309
|
if "widget" not in kwargs:
|
303
310
|
if db_field.name in self.raw_id_fields:
|
304
|
-
kwargs["widget"] =
|
305
|
-
attrs={"class": " ".join(INPUT_CLASSES)}
|
306
|
-
)
|
311
|
+
kwargs["widget"] = UnfoldAdminTextInputWidget()
|
307
312
|
elif (
|
308
313
|
db_field.name not in self.get_autocomplete_fields(request)
|
309
314
|
and db_field.name not in self.radio_fields
|
310
315
|
):
|
311
|
-
kwargs["widget"] =
|
312
|
-
attrs={"class": " ".join(SELECT_CLASSES)}
|
313
|
-
)
|
316
|
+
kwargs["widget"] = UnfoldAdminSelect()
|
314
317
|
kwargs["empty_label"] = _("Select value")
|
315
318
|
|
316
319
|
return super().formfield_for_foreignkey(db_field, request, **kwargs)
|
@@ -323,9 +326,7 @@ class ModelAdminMixin:
|
|
323
326
|
) -> ModelMultipleChoiceField:
|
324
327
|
if "widget" not in kwargs:
|
325
328
|
if db_field.name in self.raw_id_fields:
|
326
|
-
kwargs["widget"] =
|
327
|
-
attrs={"class": " ".join(INPUT_CLASSES)}
|
328
|
-
)
|
329
|
+
kwargs["widget"] = UnfoldAdminTextInputWidget()
|
329
330
|
|
330
331
|
form_field = super().formfield_for_manytomany(db_field, request, **kwargs)
|
331
332
|
|
@@ -342,9 +343,7 @@ class ModelAdminMixin:
|
|
342
343
|
self, db_field: Field, request: HttpRequest, **kwargs
|
343
344
|
) -> Optional[Field]:
|
344
345
|
if "widget" not in kwargs:
|
345
|
-
kwargs["widget"] =
|
346
|
-
attrs={"class": " ".join(SELECT_CLASSES)}
|
347
|
-
)
|
346
|
+
kwargs["widget"] = UnfoldAdminNullBooleanSelectWidget()
|
348
347
|
|
349
348
|
return db_field.formfield(**kwargs)
|
350
349
|
|
@@ -354,7 +353,14 @@ class ModelAdminMixin:
|
|
354
353
|
if isinstance(db_field, models.BooleanField) and db_field.null is True:
|
355
354
|
return self.formfield_for_nullboolean_field(db_field, request, **kwargs)
|
356
355
|
|
357
|
-
|
356
|
+
formfield = super().formfield_for_dbfield(db_field, request, **kwargs)
|
357
|
+
|
358
|
+
if formfield and isinstance(formfield.widget, RelatedFieldWidgetWrapper):
|
359
|
+
formfield.widget.template_name = (
|
360
|
+
"unfold/widgets/related_widget_wrapper.html"
|
361
|
+
)
|
362
|
+
|
363
|
+
return formfield
|
358
364
|
|
359
365
|
|
360
366
|
class ModelAdmin(ModelAdminMixin, BaseModelAdmin):
|
@@ -400,7 +406,7 @@ class ModelAdmin(ModelAdminMixin, BaseModelAdmin):
|
|
400
406
|
filtered_actions.append(action)
|
401
407
|
continue
|
402
408
|
permission_checks = (
|
403
|
-
getattr(self, "has_
|
409
|
+
getattr(self, f"has_{permission}_permission")
|
404
410
|
for permission in action.method.allowed_permissions
|
405
411
|
)
|
406
412
|
if any(has_permission(request) for has_permission in permission_checks):
|
@@ -546,7 +552,8 @@ class ModelAdmin(ModelAdminMixin, BaseModelAdmin):
|
|
546
552
|
"title": action.description,
|
547
553
|
"attrs": action.method.attrs,
|
548
554
|
"path": reverse(
|
549
|
-
f"
|
555
|
+
f"{self.admin_site.name}:{action.action_name}",
|
556
|
+
args=(object_id,),
|
550
557
|
),
|
551
558
|
}
|
552
559
|
)
|
@@ -570,7 +577,7 @@ class ModelAdmin(ModelAdminMixin, BaseModelAdmin):
|
|
570
577
|
{
|
571
578
|
"title": action.description,
|
572
579
|
"attrs": action.method.attrs,
|
573
|
-
"path": reverse(f"
|
580
|
+
"path": reverse(f"{self.admin_site.name}:{action.action_name}"),
|
574
581
|
}
|
575
582
|
for action in self.get_actions_list(request)
|
576
583
|
]
|
@@ -579,7 +586,7 @@ class ModelAdmin(ModelAdminMixin, BaseModelAdmin):
|
|
579
586
|
{
|
580
587
|
"title": action.description,
|
581
588
|
"attrs": action.method.attrs,
|
582
|
-
"raw_path": f"
|
589
|
+
"raw_path": f"{self.admin_site.name}:{action.action_name}",
|
583
590
|
}
|
584
591
|
for action in self.get_actions_row(request)
|
585
592
|
]
|
unfold/apps.py
CHANGED
@@ -7,9 +7,14 @@ from .sites import UnfoldAdminSite
|
|
7
7
|
|
8
8
|
class DefaultAppConfig(AppConfig):
|
9
9
|
name = "unfold"
|
10
|
+
default = True
|
10
11
|
|
11
12
|
def ready(self):
|
12
13
|
site = UnfoldAdminSite()
|
13
14
|
|
14
15
|
admin.site = site
|
15
16
|
sites.site = site
|
17
|
+
|
18
|
+
|
19
|
+
class BasicAppConfig(AppConfig):
|
20
|
+
name = "unfold"
|
unfold/checks.py
CHANGED
@@ -30,7 +30,7 @@ class UnfoldModelAdminChecks(ModelAdminChecks):
|
|
30
30
|
if not hasattr(action.method, "allowed_permissions"):
|
31
31
|
continue
|
32
32
|
for permission in action.method.allowed_permissions:
|
33
|
-
method_name = "has_
|
33
|
+
method_name = f"has_{permission}_permission"
|
34
34
|
if not hasattr(obj, method_name):
|
35
35
|
errors.append(
|
36
36
|
checks.Error(
|
unfold/forms.py
CHANGED
@@ -22,7 +22,12 @@ from .widgets import BASE_INPUT_CLASSES, INPUT_CLASSES, SELECT_CLASSES
|
|
22
22
|
class ActionForm(forms.Form):
|
23
23
|
action = forms.ChoiceField(
|
24
24
|
label="",
|
25
|
-
widget=forms.Select(
|
25
|
+
widget=forms.Select(
|
26
|
+
{
|
27
|
+
"class": " ".join([*SELECT_CLASSES, "max-w-full", "lg:!w-64"]),
|
28
|
+
"x-model": "action",
|
29
|
+
}
|
30
|
+
),
|
26
31
|
)
|
27
32
|
|
28
33
|
select_across = forms.BooleanField(
|
unfold/sites.py
CHANGED
@@ -205,7 +205,7 @@ class UnfoldAdminSite(AdminSite):
|
|
205
205
|
|
206
206
|
from .forms import AdminOwnPasswordChangeForm
|
207
207
|
|
208
|
-
url = reverse("
|
208
|
+
url = reverse(f"{self.name}:password_change_done", current_app=self.name)
|
209
209
|
defaults = {
|
210
210
|
"form_class": AdminOwnPasswordChangeForm,
|
211
211
|
"success_url": url,
|
@@ -224,9 +224,9 @@ class UnfoldAdminSite(AdminSite):
|
|
224
224
|
if not isinstance(link, str):
|
225
225
|
link = str(link)
|
226
226
|
|
227
|
-
if link in request.path and link != reverse_lazy("
|
227
|
+
if link in request.path and link != reverse_lazy(f"{self.name}:index"):
|
228
228
|
return True
|
229
|
-
elif link == request.path == reverse_lazy("
|
229
|
+
elif link == request.path == reverse_lazy(f"{self.name}:index"):
|
230
230
|
return True
|
231
231
|
|
232
232
|
return False
|