From 764240d67aacc7a2369f11bce86b3de8b07b642d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Mon, 9 Oct 2023 23:05:32 +0200 Subject: [PATCH] Fix bookshelf default sorting --- ..._author_options_alter_publisher_options.py | 20 +++++++++++++++++++ ram/bookshelf/models.py | 6 ++++++ ram/ram/__init__.py | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 ram/bookshelf/migrations/0008_alter_author_options_alter_publisher_options.py diff --git a/ram/bookshelf/migrations/0008_alter_author_options_alter_publisher_options.py b/ram/bookshelf/migrations/0008_alter_author_options_alter_publisher_options.py new file mode 100644 index 0000000..543bcd9 --- /dev/null +++ b/ram/bookshelf/migrations/0008_alter_author_options_alter_publisher_options.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.6 on 2023-10-09 21:08 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("bookshelf", "0007_alter_book_options"), + ] + + operations = [ + migrations.AlterModelOptions( + name="author", + options={"ordering": ["last_name", "first_name"]}, + ), + migrations.AlterModelOptions( + name="publisher", + options={"ordering": ["name"]}, + ), + ] diff --git a/ram/bookshelf/models.py b/ram/bookshelf/models.py index 112c68f..0d01d10 100644 --- a/ram/bookshelf/models.py +++ b/ram/bookshelf/models.py @@ -16,6 +16,9 @@ class Publisher(models.Model): country = CountryField(blank=True) website = models.URLField(blank=True) + class Meta: + ordering = ["name"] + def __str__(self): return self.name @@ -24,6 +27,9 @@ class Author(models.Model): first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) + class Meta: + ordering = ["last_name", "first_name"] + def __str__(self): return f"{self.last_name}, {self.first_name}" diff --git a/ram/ram/__init__.py b/ram/ram/__init__.py index f965868..55b01db 100644 --- a/ram/ram/__init__.py +++ b/ram/ram/__init__.py @@ -1,4 +1,4 @@ from ram.utils import git_suffix -__version__ = "0.6.4" +__version__ = "0.6.5" __version__ += git_suffix(__file__)