diff --git a/app/contrib/partners/admin.py b/app/contrib/partners/admin.py index 0962a594..895e6502 100644 --- a/app/contrib/partners/admin.py +++ b/app/contrib/partners/admin.py @@ -1,7 +1,9 @@ from django.contrib import admin +from adminsortable2.admin import SortableAdminMixin + from .models import Partner @admin.register(Partner) -class PartnerAdmin(admin.ModelAdmin): +class PartnerAdmin(SortableAdminMixin, admin.ModelAdmin): list_display = ("name", "link") diff --git a/app/contrib/partners/migrations/0002_alter_partner_options_partner_position.py b/app/contrib/partners/migrations/0002_alter_partner_options_partner_position.py new file mode 100644 index 00000000..1eac7d97 --- /dev/null +++ b/app/contrib/partners/migrations/0002_alter_partner_options_partner_position.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2 on 2024-09-02 21:46 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('partners', '0001_initial'), + ] + + operations = [ + migrations.AlterModelOptions( + name='partner', + options={'ordering': ['position'], 'verbose_name': 'Parceiro'}, + ), + migrations.AddField( + model_name='partner', + name='position', + field=models.PositiveIntegerField(default=0), + ), + ] diff --git a/app/contrib/partners/models.py b/app/contrib/partners/models.py index aa757046..ffeeba34 100644 --- a/app/contrib/partners/models.py +++ b/app/contrib/partners/models.py @@ -9,8 +9,16 @@ class Partner(models.Model): logo = FilerFileField(verbose_name=_("Imagem"), on_delete=models.SET_NULL, null=True, blank=True) link = models.URLField(blank=True, null=True, verbose_name="Link da Parceria") + position = models.PositiveIntegerField( + default=0, + blank=False, + null=False, + verbose_name="Posição" + ) + def __str__(self): return self.name class Meta: verbose_name = "Parceiro" + ordering = ["position"] \ No newline at end of file