Fix for carousel management.
authorRadek Czajka <rczajka@rczajka.pl>
Fri, 14 Oct 2022 08:05:51 +0000 (10:05 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Fri, 14 Oct 2022 08:05:51 +0000 (10:05 +0200)
src/social/admin.py
src/social/migrations/0014_auto_20221014_1004.py [new file with mode: 0644]
src/social/models.py

index 22cc3e3..cc19432 100644 (file)
@@ -23,6 +23,7 @@ class CiteAdmin(admin.ModelAdmin):
     list_filter = ['group']
     readonly_fields = ['created_at']
     autocomplete_fields = ['book']
     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')}),
     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'
 class CarouselItemInline(OrderableAdmin, admin.TabularInline):
     model = CarouselItem
     ordering_field = 'order'
+    autocomplete_fields = ['banner']
 
 
 class CarouselAdmin(admin.ModelAdmin):
 
 
 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 (file)
index 0000000..987ebc2
--- /dev/null
@@ -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(),
+        ),
+    ]
index b254b22..f001e31 100644 (file)
@@ -146,14 +146,13 @@ class Carousel(models.Model):
 
 
 class CarouselItem(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',)
     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')
 
         verbose_name = _('carousel item')
         verbose_name_plural = _('carousel items')