From ba83b8311a93602de7f733c9a9e183e3ebbb006c Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Fri, 14 Oct 2022 10:05:51 +0200 Subject: [PATCH] Fix for carousel management. --- src/social/admin.py | 2 ++ .../migrations/0014_auto_20221014_1004.py | 22 +++++++++++++++++++ src/social/models.py | 3 +-- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 src/social/migrations/0014_auto_20221014_1004.py diff --git a/src/social/admin.py b/src/social/admin.py index 22cc3e303..cc1943262 100644 --- a/src/social/admin.py +++ b/src/social/admin.py @@ -23,6 +23,7 @@ class CiteAdmin(admin.ModelAdmin): list_filter = ['group'] readonly_fields = ['created_at'] autocomplete_fields = ['book'] + search_fields = ['text', 'link', 'picture_alt', 'picture_author', 'picture_link', 'image_title', 'image_author', 'image_link'] fieldsets = ( (None, {'fields': ('group', 'sticky', 'created_at', 'book')}), (_('Content'), {'fields': ('link', 'vip', 'text', 'small')}), @@ -69,6 +70,7 @@ admin.site.register(BannerGroup, BannerGroupAdmin) class CarouselItemInline(OrderableAdmin, admin.TabularInline): model = CarouselItem ordering_field = 'order' + autocomplete_fields = ['banner'] class CarouselAdmin(admin.ModelAdmin): diff --git a/src/social/migrations/0014_auto_20221014_1004.py b/src/social/migrations/0014_auto_20221014_1004.py new file mode 100644 index 000000000..987ebc278 --- /dev/null +++ b/src/social/migrations/0014_auto_20221014_1004.py @@ -0,0 +1,22 @@ +# Generated by Django 3.2.16 on 2022-10-14 08:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('social', '0013_auto_20210120_1445'), + ] + + operations = [ + migrations.AlterField( + model_name='carouselitem', + name='order', + field=models.PositiveSmallIntegerField(verbose_name='order'), + ), + migrations.AlterUniqueTogether( + name='carouselitem', + unique_together=set(), + ), + ] diff --git a/src/social/models.py b/src/social/models.py index b254b22dc..f001e310c 100644 --- a/src/social/models.py +++ b/src/social/models.py @@ -146,14 +146,13 @@ class Carousel(models.Model): class CarouselItem(models.Model): - order = models.PositiveSmallIntegerField(_('order'), unique=True) + order = models.PositiveSmallIntegerField(_('order')) carousel = models.ForeignKey(Carousel, models.CASCADE, verbose_name=_('carousel')) banner = models.ForeignKey(Cite, models.CASCADE, null=True, blank=True, verbose_name=_('banner')) banner_group = models.ForeignKey(BannerGroup, models.CASCADE, null=True, blank=True, verbose_name=_('banner group')) class Meta: ordering = ('order',) - unique_together = [('carousel', 'order')] verbose_name = _('carousel item') verbose_name_plural = _('carousel items') -- 2.20.1