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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {django_unfold-0.24.0.dist-info → django_unfold-0.26.0.dist-info}/METADATA +51 -6
  2. {django_unfold-0.24.0.dist-info → django_unfold-0.26.0.dist-info}/RECORD +36 -26
  3. unfold/admin.py +11 -3
  4. unfold/contrib/import_export/forms.py +28 -5
  5. unfold/contrib/import_export/templates/admin/import_export/change_form.html +10 -0
  6. unfold/contrib/import_export/templates/admin/import_export/export.html +38 -3
  7. unfold/contrib/import_export/templates/admin/import_export/import_form.html +9 -20
  8. unfold/contrib/import_export/templates/admin/import_export/resource_fields_list.html +24 -0
  9. unfold/contrib/inlines/__init__.py +0 -0
  10. unfold/contrib/inlines/admin.py +141 -0
  11. unfold/contrib/inlines/apps.py +6 -0
  12. unfold/contrib/inlines/checks.py +18 -0
  13. unfold/contrib/inlines/forms.py +43 -0
  14. unfold/forms.py +6 -0
  15. unfold/static/unfold/css/simplebar.css +230 -0
  16. unfold/static/unfold/css/styles.css +1 -1
  17. unfold/static/unfold/js/simplebar.js +10 -0
  18. unfold/styles.css +10 -2
  19. unfold/templates/admin/app_list.html +1 -1
  20. unfold/templates/admin/change_form.html +11 -9
  21. unfold/templates/admin/change_list_results.html +67 -65
  22. unfold/templates/admin/edit_inline/stacked.html +7 -7
  23. unfold/templates/admin/edit_inline/tabular.html +111 -109
  24. unfold/templates/admin/includes/fieldset.html +1 -1
  25. unfold/templates/unfold/helpers/app_list.html +1 -1
  26. unfold/templates/unfold/helpers/display_header.html +11 -8
  27. unfold/templates/unfold/helpers/field.html +20 -6
  28. unfold/templates/unfold/helpers/fieldsets_tabs.html +4 -4
  29. unfold/templates/unfold/helpers/form_label.html +1 -1
  30. unfold/templates/unfold/layouts/skeleton.html +2 -0
  31. unfold/templates/unfold/widgets/foreign_key_raw_id.html +21 -0
  32. unfold/templates/unfold/widgets/textarea.html +1 -7
  33. unfold/templates/unfold/widgets/textarea_expandable.html +7 -0
  34. unfold/widgets.py +36 -3
  35. unfold/contrib/import_export/admin.py +0 -37
  36. {django_unfold-0.24.0.dist-info → django_unfold-0.26.0.dist-info}/LICENSE.md +0 -0
  37. {django_unfold-0.24.0.dist-info → django_unfold-0.26.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,21 @@
1
+ <div class="flex flex-row">
2
+ {% include 'django/forms/widgets/input.html' %}
3
+
4
+ {% if related_url %}
5
+ <a href="{{ related_url }}" class="related-lookup related-widget-wrapper-link view-related bg-white border cursor-pointer flex items-center h-9.5 justify-center ml-2 rounded shadow-sm shrink-0 text-gray-400 text-sm w-9.5 hover:text-gray-700 dark:bg-gray-900 dark:border-gray-700 dark:text-gray-500 dark:hover:text-gray-200" id="lookup_id_{{ widget.name }}" title="{{ link_title }}">
6
+ <span class="material-symbols-outlined text-sm">search</span>
7
+ </a>
8
+ {% endif %}
9
+ </div>
10
+
11
+ {% if link_label %}
12
+ <strong class="mt-2 font-medium text-xs">
13
+ {% if link_url %}
14
+ <a href="{{ link_url }}" class="underline text-primary-500">
15
+ {{ link_label }}
16
+ </a>
17
+ {% else %}
18
+ {{ link_label }}
19
+ {% endif %}
20
+ </strong>
21
+ {% endif %}
@@ -1,7 +1 @@
1
- <div class="relative">
2
- <div class="border break-words font-medium invisible max-w-4xl px-3 py-2 text-sm" style="min-height: 64px">
3
- {% if widget.value %}{{ widget.value|linebreaks }}{% endif %}
4
- </div>
5
-
6
- <textarea onInput="this.previousElementSibling.innerText = this.value + String.fromCharCode(10)" name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% if widget.value %}{{ widget.value }}{% endif %}</textarea>
7
- </div>
1
+ <textarea name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% if widget.value %}{{ widget.value }}{% endif %}</textarea>
@@ -0,0 +1,7 @@
1
+ <div class="relative">
2
+ <div class="border break-words font-medium invisible max-w-4xl px-3 py-2 text-sm" style="min-height: 64px">
3
+ {% if widget.value %}{{ widget.value|linebreaks }}{% endif %}
4
+ </div>
5
+
6
+ <textarea onInput="this.previousElementSibling.innerText = this.value + String.fromCharCode(10)" name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% if widget.value %}{{ widget.value }}{% endif %}</textarea>
7
+ </div>
unfold/widgets.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from typing import Any, Callable, Dict, Optional, Tuple, Union
2
2
 
3
3
  from django.contrib.admin.options import VERTICAL
4
+ from django.contrib.admin.sites import AdminSite
4
5
  from django.contrib.admin.widgets import (
5
6
  AdminBigIntegerFieldWidget,
6
7
  AdminDateWidget,
@@ -13,8 +14,10 @@ from django.contrib.admin.widgets import (
13
14
  AdminTextInputWidget,
14
15
  AdminTimeWidget,
15
16
  AdminUUIDInputWidget,
17
+ ForeignKeyRawIdWidget,
16
18
  RelatedFieldWidgetWrapper,
17
19
  )
20
+ from django.db.models.fields.reverse_related import ForeignObjectRel
18
21
  from django.forms import (
19
22
  CheckboxInput,
20
23
  MultiWidget,
@@ -106,7 +109,6 @@ SELECT_CLASSES = [
106
109
  "pr-8",
107
110
  "max-w-2xl",
108
111
  "appearance-none",
109
- "truncate",
110
112
  ]
111
113
 
112
114
  PROSE_CLASSES = [
@@ -358,6 +360,20 @@ class UnfoldAdminSingleTimeWidget(AdminTimeWidget):
358
360
  class UnfoldAdminTextareaWidget(AdminTextareaWidget):
359
361
  template_name = "unfold/widgets/textarea.html"
360
362
 
363
+ def __init__(self, attrs: Optional[Dict[str, Any]] = None) -> None:
364
+ attrs = attrs or {}
365
+
366
+ super().__init__(
367
+ attrs={
368
+ "class": "vLargeTextField " + " ".join(TEXTAREA_CLASSES),
369
+ **(attrs or {}),
370
+ }
371
+ )
372
+
373
+
374
+ class UnfoldAdminExpandableTextareaWidget(AdminTextareaWidget):
375
+ template_name = "unfold/widgets/textarea_expandable.html"
376
+
361
377
  def __init__(self, attrs: Optional[Dict[str, Any]] = None) -> None:
362
378
  attrs = attrs or {}
363
379
 
@@ -499,7 +515,7 @@ class UnfoldBooleanWidget(CheckboxInput):
499
515
  if attrs is None:
500
516
  attrs = {}
501
517
 
502
- return super().__init__(
518
+ super().__init__(
503
519
  {
504
520
  **(attrs or {}),
505
521
  "class": " ".join(CHECKBOX_CLASSES + [attrs.get("class", "")]),
@@ -512,10 +528,27 @@ class UnfoldBooleanSwitchWidget(CheckboxInput):
512
528
  def __init__(
513
529
  self, attrs: Optional[Dict[str, Any]] = None, check_test: Callable = None
514
530
  ) -> None:
515
- return super().__init__(
531
+ super().__init__(
516
532
  attrs={"class": " ".join(SWITCH_CLASSES), **(attrs or {})}, check_test=None
517
533
  )
518
534
 
519
535
 
520
536
  class UnfoldRelatedFieldWidgetWrapper(RelatedFieldWidgetWrapper):
521
537
  template_name = "unfold/widgets/related_widget_wrapper.html"
538
+
539
+
540
+ class UnfoldForeignKeyRawIdWidget(ForeignKeyRawIdWidget):
541
+ template_name = "unfold/widgets/foreign_key_raw_id.html"
542
+
543
+ def __init__(
544
+ self,
545
+ rel: ForeignObjectRel,
546
+ admin_site: AdminSite,
547
+ attrs: Optional[Dict] = None,
548
+ using: Optional[Any] = None,
549
+ ) -> None:
550
+ attrs = {
551
+ "class": " ".join(["vForeignKeyRawIdAdminField"] + INPUT_CLASSES),
552
+ **(attrs or {}),
553
+ }
554
+ super().__init__(rel, admin_site, attrs, using)
@@ -1,37 +0,0 @@
1
- from django import forms
2
- from django.utils.translation import gettext_lazy as _
3
- from import_export.admin import ExportActionModelAdmin as BaseExportActionModelAdmin
4
- from unfold.admin import ActionForm
5
- from unfold.widgets import SELECT_CLASSES
6
-
7
-
8
- def export_action_form_factory(formats):
9
- class _ExportActionForm(ActionForm):
10
- format = forms.ChoiceField(
11
- label=" ",
12
- choices=formats,
13
- required=False,
14
- widget=forms.Select(
15
- {"class": " ".join([*SELECT_CLASSES, "ml-3", "!w-auto", "lg:!w-40"])}
16
- ),
17
- )
18
-
19
- _ExportActionForm.__name__ = "ExportActionForm"
20
-
21
- return _ExportActionForm
22
-
23
-
24
- class ExportActionModelAdmin(BaseExportActionModelAdmin):
25
- def __init__(self, *args, **kwargs):
26
- super().__init__(*args, **kwargs)
27
-
28
- choices = []
29
- formats = self.get_export_formats()
30
- if formats:
31
- for i, f in enumerate(formats):
32
- choices.append((str(i), f().get_title()))
33
-
34
- if len(formats) > 1:
35
- choices.insert(0, ("", _("Select format")))
36
-
37
- self.action_form = export_action_form_factory(choices)