django-unfold 0.22.0__py3-none-any.whl → 0.24.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. {django_unfold-0.22.0.dist-info → django_unfold-0.24.0.dist-info}/METADATA +102 -4
  2. {django_unfold-0.22.0.dist-info → django_unfold-0.24.0.dist-info}/RECORD +44 -43
  3. unfold/admin.py +29 -22
  4. unfold/apps.py +5 -0
  5. unfold/checks.py +1 -1
  6. unfold/contrib/filters/admin.py +116 -0
  7. unfold/contrib/filters/forms.py +29 -1
  8. unfold/contrib/filters/templates/unfold/filters/filters_date_range.html +1 -1
  9. unfold/contrib/filters/templates/unfold/filters/filters_datetime_range.html +1 -1
  10. unfold/contrib/filters/templates/unfold/filters/filters_field.html +7 -0
  11. unfold/contrib/filters/templates/unfold/filters/filters_numeric_range.html +1 -1
  12. unfold/contrib/filters/templates/unfold/filters/filters_numeric_single.html +1 -1
  13. unfold/contrib/filters/templates/unfold/filters/filters_numeric_slider.html +1 -1
  14. unfold/contrib/import_export/admin.py +1 -1
  15. unfold/contrib/import_export/forms.py +6 -7
  16. unfold/contrib/import_export/templates/admin/import_export/export.html +1 -1
  17. unfold/contrib/import_export/templates/admin/import_export/import_form.html +2 -2
  18. unfold/forms.py +6 -1
  19. unfold/sites.py +3 -3
  20. unfold/static/unfold/css/styles.css +1 -1
  21. unfold/styles.css +11 -4
  22. unfold/templates/admin/actions.html +9 -9
  23. unfold/templates/admin/app_list.html +6 -8
  24. unfold/templates/admin/base.html +1 -3
  25. unfold/templates/admin/change_form.html +1 -2
  26. unfold/templates/admin/change_list.html +2 -2
  27. unfold/templates/admin/change_list_results.html +15 -3
  28. unfold/templates/admin/edit_inline/tabular.html +3 -3
  29. unfold/templates/admin/filter.html +2 -2
  30. unfold/templates/admin/search_form.html +10 -12
  31. unfold/templates/unfold/helpers/display_header.html +16 -13
  32. unfold/templates/unfold/helpers/tab_list.html +1 -1
  33. unfold/templates/unfold/layouts/base_simple.html +1 -1
  34. unfold/templates/unfold/widgets/date.html +1 -1
  35. unfold/templates/{admin → unfold}/widgets/related_widget_wrapper.html +4 -4
  36. unfold/templates/unfold/widgets/time.html +1 -1
  37. unfold/templatetags/unfold_list.py +8 -6
  38. unfold/widgets.py +18 -5
  39. {django_unfold-0.22.0.dist-info → django_unfold-0.24.0.dist-info}/LICENSE.md +0 -0
  40. {django_unfold-0.22.0.dist-info → django_unfold-0.24.0.dist-info}/WHEEL +0 -0
  41. /unfold/templates/{admin → unfold}/widgets/clearable_file_input.html +0 -0
  42. /unfold/templates/{admin → unfold}/widgets/radio.html +0 -0
  43. /unfold/templates/{admin → unfold}/widgets/radio_option.html +0 -0
  44. /unfold/templates/{admin → unfold}/widgets/split_datetime.html +0 -0
@@ -1,7 +1,35 @@
1
1
  from django import forms
2
2
  from django.utils.translation import gettext_lazy as _
3
3
 
4
- from ...widgets import INPUT_CLASSES, UnfoldAdminSplitDateTimeVerticalWidget
4
+ from ...widgets import (
5
+ INPUT_CLASSES,
6
+ UnfoldAdminSelectWidget,
7
+ UnfoldAdminSplitDateTimeVerticalWidget,
8
+ UnfoldAdminTextInputWidget,
9
+ )
10
+
11
+
12
+ class SearchForm(forms.Form):
13
+ def __init__(self, name, label, *args, **kwargs):
14
+ super().__init__(*args, **kwargs)
15
+
16
+ self.fields[name] = forms.CharField(
17
+ label=label,
18
+ required=False,
19
+ widget=UnfoldAdminTextInputWidget,
20
+ )
21
+
22
+
23
+ class DropdownForm(forms.Form):
24
+ def __init__(self, name, label, choices, *args, **kwargs):
25
+ super().__init__(*args, **kwargs)
26
+
27
+ self.fields[name] = forms.ChoiceField(
28
+ label=label,
29
+ required=False,
30
+ choices=choices,
31
+ widget=UnfoldAdminSelectWidget,
32
+ )
5
33
 
6
34
 
7
35
  class SingleNumericForm(forms.Form):
@@ -2,7 +2,7 @@
2
2
 
3
3
  {% with choices.0 as choice %}
4
4
  <div class="flex flex-col mb-6">
5
- <h3 class="font-medium mb-4 text-gray-700 text-sm dark:text-gray-200">{% blocktrans with filter_title=title %}By {{ filter_title }}{% endblocktrans %}</h3>
5
+ <h3 class="font-medium mb-2 text-gray-700 text-sm dark:text-gray-200">{% blocktrans with filter_title=title %}By {{ filter_title }}{% endblocktrans %}</h3>
6
6
 
7
7
  <div class="flex flex-col space-y-4">
8
8
  {% for field in choice.form %}
@@ -2,7 +2,7 @@
2
2
 
3
3
  {% with choices.0 as choice %}
4
4
  <div class="flex flex-col mb-6">
5
- <h3 class="font-medium mb-4 text-gray-700 text-sm dark:text-gray-200">{% blocktrans with filter_title=title %}By {{ filter_title }}{% endblocktrans %}</h3>
5
+ <h3 class="font-medium mb-2 text-gray-700 text-sm dark:text-gray-200">{% blocktrans with filter_title=title %}By {{ filter_title }}{% endblocktrans %}</h3>
6
6
 
7
7
  <div class="flex flex-col space-y-4">
8
8
  {% for field in choice.form %}
@@ -0,0 +1,7 @@
1
+ {% load i18n %}
2
+
3
+ {% with choices.0 as choice %}
4
+ {% for field in choice.form %}
5
+ {% include "unfold/helpers/field.html" %}
6
+ {% endfor %}
7
+ {% endwith %}
@@ -2,7 +2,7 @@
2
2
 
3
3
  {% with choices.0 as choice %}
4
4
  <div class="flex flex-col mb-6">
5
- <h3 class="font-medium mb-4 text-gray-700 text-sm dark:text-gray-200">{% blocktrans with filter_title=title %}By {{ filter_title }}{% endblocktrans %}</h3>
5
+ <h3 class="font-medium mb-2 text-gray-700 text-sm dark:text-gray-200">{% blocktrans with filter_title=title %}By {{ filter_title }}{% endblocktrans %}</h3>
6
6
 
7
7
  <div class="flex flex-row gap-4">
8
8
  {% for field in choice.form %}
@@ -2,7 +2,7 @@
2
2
 
3
3
  {% with choices.0 as choice %}
4
4
  <div class="flex flex-col mb-6">
5
- <h3 class="font-medium mb-4 text-gray-700 text-sm dark:text-gray-200">{% blocktrans with filter_title=title %}By {{ filter_title }}{% endblocktrans %}</h3>
5
+ <h3 class="font-medium mb-2 text-gray-700 text-sm dark:text-gray-200">{% blocktrans with filter_title=title %}By {{ filter_title }}{% endblocktrans %}</h3>
6
6
 
7
7
  {% for field in choice.form %}
8
8
  <div class="flex flex-row flex-wrap group relative{% if field.errors %} errors{% endif %}">
@@ -3,7 +3,7 @@
3
3
 
4
4
  {% with choices.0 as choice %}
5
5
  <div class="admin-numeric-filter-wrapper mb-6">
6
- <h3 class="font-medium mb-4 text-gray-700 text-sm dark:text-gray-200">
6
+ <h3 class="font-medium mb-2 text-gray-700 text-sm dark:text-gray-200">
7
7
  {% blocktrans with filter_title=title %}By {{ filter_title }}{% endblocktrans %}
8
8
  </h3>
9
9
 
@@ -7,7 +7,7 @@ from unfold.widgets import SELECT_CLASSES
7
7
 
8
8
  def export_action_form_factory(formats):
9
9
  class _ExportActionForm(ActionForm):
10
- file_format = forms.ChoiceField(
10
+ format = forms.ChoiceField(
11
11
  label=" ",
12
12
  choices=formats,
13
13
  required=False,
@@ -1,16 +1,15 @@
1
- from import_export.forms import ExportForm as BaseExportForm
2
- from import_export.forms import ImportForm as BaseImportForm
1
+ from import_export.forms import ImportExportFormBase as BaseImportExportFormBase
3
2
  from unfold.widgets import SELECT_CLASSES, UnfoldAdminFileFieldWidget
4
3
 
5
4
 
6
- class ImportForm(BaseImportForm):
5
+ class ImportForm(BaseImportExportFormBase):
7
6
  def __init__(self, *args, **kwargs):
8
7
  super().__init__(*args, **kwargs)
9
- self.fields["import_file"].widget = UnfoldAdminFileFieldWidget()
10
- self.fields["input_format"].widget.attrs["class"] = " ".join(SELECT_CLASSES)
8
+ self.fields["resource"].widget = UnfoldAdminFileFieldWidget()
9
+ self.fields["format"].widget.attrs["class"] = " ".join(SELECT_CLASSES)
11
10
 
12
11
 
13
- class ExportForm(BaseExportForm):
12
+ class ExportForm(BaseImportExportFormBase):
14
13
  def __init__(self, *args, **kwargs):
15
14
  super().__init__(*args, **kwargs)
16
- self.fields["file_format"].widget.attrs["class"] = " ".join(SELECT_CLASSES)
15
+ self.fields["format"].widget.attrs["class"] = " ".join(SELECT_CLASSES)
@@ -37,7 +37,7 @@
37
37
  {% csrf_token %}
38
38
 
39
39
  <fieldset class="border border-gray-200 mb-8 rounded-md pt-3 px-3 shadow-sm dark:border-gray-800">
40
- {% include "unfold/helpers/field.html" with field=form.file_format %}
40
+ {% include "unfold/helpers/field.html" with field=form.format %}
41
41
  </fieldset>
42
42
 
43
43
  <button type="submit" class="bg-primary-600 border border-transparent font-medium px-3 py-2 rounded-md text-sm text-white">
@@ -22,9 +22,9 @@
22
22
  </p>
23
23
 
24
24
  <fieldset class="border border-gray-200 mb-8 rounded-md pt-3 px-3 shadow-sm dark:border-gray-800">
25
- {% include "unfold/helpers/field.html" with field=form.import_file %}
25
+ {% include "unfold/helpers/field.html" with field=form.resource %}
26
26
 
27
- {% include "unfold/helpers/field.html" with field=form.input_format %}
27
+ {% include "unfold/helpers/field.html" with field=form.format %}
28
28
  </fieldset>
29
29
 
30
30
 
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({"class": " ".join([*SELECT_CLASSES, "w-72"])}),
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("admin:password_change_done", current_app=self.name)
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("admin:index"):
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("admin:index"):
229
+ elif link == request.path == reverse_lazy(f"{self.name}:index"):
230
230
  return True
231
231
 
232
232
  return False