From 5cbd6151228b9a3d47ebca622e5f0580eaede269 Mon Sep 17 00:00:00 2001 From: monodo Date: Tue, 28 May 2024 17:01:16 +0200 Subject: [PATCH] wip: fix drag & drop --- geocity/apps/forms/admin.py | 7 +++---- geocity/apps/forms/models.py | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/geocity/apps/forms/admin.py b/geocity/apps/forms/admin.py index d7396111b..00becb393 100644 --- a/geocity/apps/forms/admin.py +++ b/geocity/apps/forms/admin.py @@ -1,7 +1,7 @@ import string import django.db.models -from adminsortable2.admin import SortableAdminMixin, SortableInlineAdminMixin +from adminsortable2.admin import SortableAdminMixin, SortableTabularInline from constance import config from django import forms from django.contrib import admin @@ -178,8 +178,7 @@ def save(self, *args, **kwargs): return super().save(*args, **kwargs) -# TODO: enable drag and drop for inline reorder -class FormFieldInline(admin.TabularInline, SortableInlineAdminMixin): +class FormFieldInline(SortableTabularInline): model = models.FormField extra = 2 verbose_name = _("Champ") @@ -198,7 +197,7 @@ class Media: css = {"all": ("css/admin/admin.css",)} -class FormPricesInline(admin.TabularInline, SortableInlineAdminMixin): +class FormPricesInline(admin.TabularInline): model = models.Form.prices.through extra = 1 verbose_name = _("Tarif") diff --git a/geocity/apps/forms/models.py b/geocity/apps/forms/models.py index c2603f591..3d58c8a44 100644 --- a/geocity/apps/forms/models.py +++ b/geocity/apps/forms/models.py @@ -820,6 +820,9 @@ class Meta: verbose_name_plural = _("Champs du formulaire") ordering = ("order",) + def __str__(self): + return str(self.order) + # Input types INPUT_TYPE_ADDRESS = "address"