Changeset - 7a682ed6d0ff
[Not reviewed]
0 2 1
Ben Sturmfels (bsturmfels) - 5 months ago 2023-10-30 22:31:28
ben@sturm.com.au
usethesource: Add "ordering" field to determine candidate sort order
3 files changed with 28 insertions and 1 deletions:
0 comments (0 inline, 0 general)
conservancy/usethesource/admin.py
Show inline comments
...
 
@@ -11,7 +11,8 @@ class CommentInline(admin.TabularInline):
 

	
 
@admin.register(Candidate)
 
class CandidateAdmin(admin.ModelAdmin):
 
    list_display = ['name', 'vendor', 'device', 'release_date']
 
    list_display = ['name', 'vendor', 'device', 'release_date', 'ordering']
 
    list_editable = ['ordering']
 
    fields = [
 
        'name',
 
        'slug',
conservancy/usethesource/migrations/0002_auto_20231030_1830.py
Show inline comments
 
new file 100644
 
# 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),
 
        ),
 
    ]
conservancy/usethesource/models.py
Show inline comments
...
 
@@ -11,6 +11,10 @@ class Candidate(models.Model):
 
    description = models.TextField()
 
    source_url = models.URLField()
 
    binary_url = models.URLField(blank=True)
 
    ordering = models.SmallIntegerField(default=0)
 

	
 
    class Meta:
 
        ordering = ['ordering', 'name']
 

	
 
    def __str__(self):
 
        return self.name
0 comments (0 inline, 0 general)