usethesource: Add "ordering" field to determine candidate sort order
This commit is contained in:
parent
2f40b9c23b
commit
7a682ed6d0
3 changed files with 28 additions and 1 deletions
|
@ -11,7 +11,8 @@ class CommentInline(admin.TabularInline):
|
||||||
|
|
||||||
@admin.register(Candidate)
|
@admin.register(Candidate)
|
||||||
class CandidateAdmin(admin.ModelAdmin):
|
class CandidateAdmin(admin.ModelAdmin):
|
||||||
list_display = ['name', 'vendor', 'device', 'release_date']
|
list_display = ['name', 'vendor', 'device', 'release_date', 'ordering']
|
||||||
|
list_editable = ['ordering']
|
||||||
fields = [
|
fields = [
|
||||||
'name',
|
'name',
|
||||||
'slug',
|
'slug',
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Generated by Django 3.2.19 on 2023-10-30 18:30
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('usethesource', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='candidate',
|
||||||
|
options={'ordering': ['ordering', 'name']},
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='candidate',
|
||||||
|
name='ordering',
|
||||||
|
field=models.SmallIntegerField(default=0),
|
||||||
|
),
|
||||||
|
]
|
|
@ -11,6 +11,10 @@ class Candidate(models.Model):
|
||||||
description = models.TextField()
|
description = models.TextField()
|
||||||
source_url = models.URLField()
|
source_url = models.URLField()
|
||||||
binary_url = models.URLField(blank=True)
|
binary_url = models.URLField(blank=True)
|
||||||
|
ordering = models.SmallIntegerField(default=0)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ['ordering', 'name']
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
Loading…
Reference in a new issue