Skip to content

Commit

Permalink
fix(vote): add sortable to partners app
Browse files Browse the repository at this point in the history
  • Loading branch information
igr-santos committed Sep 2, 2024
1 parent 42521c9 commit efb23df
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/contrib/partners/admin.py
Original file line number Diff line number Diff line change
@@ -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")
Original file line number Diff line number Diff line change
@@ -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),
),
]
8 changes: 8 additions & 0 deletions app/contrib/partners/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit efb23df

Please sign in to comment.