From ec2a43faa55531932f339b9a75f8f654c9c8bf50 Mon Sep 17 00:00:00 2001 From: Joel Bradshaw Date: Wed, 13 Jan 2021 18:36:07 -0800 Subject: [PATCH 1/2] Fix error in migrations I was getting the following error when running 0035: AttributeError: 'Edition' object has no attribute 'get_rank', But that line seems to be unnecessary, since save() does the same thing, and we are already calling that. --- bookwyrm/migrations/0035_edition_edition_rank.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bookwyrm/migrations/0035_edition_edition_rank.py b/bookwyrm/migrations/0035_edition_edition_rank.py index 6ccb2142..1a75a097 100644 --- a/bookwyrm/migrations/0035_edition_edition_rank.py +++ b/bookwyrm/migrations/0035_edition_edition_rank.py @@ -8,7 +8,6 @@ def set_rank(app_registry, schema_editor): db_alias = schema_editor.connection.alias books = app_registry.get_model('bookwyrm', 'Edition') for book in books.objects.using(db_alias): - book.edition_rank = book.get_rank book.save() class Migration(migrations.Migration): From 0b703a252bcedc15dbba78709e536ef645a89396 Mon Sep 17 00:00:00 2001 From: Joel Bradshaw Date: Wed, 13 Jan 2021 18:43:05 -0800 Subject: [PATCH 2/2] Make get_rank() a regular method It doesn't act like a property, and we have edition_rank as a proper property anyway --- bookwyrm/models/book.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bookwyrm/models/book.py b/bookwyrm/models/book.py index 49b9f0a9..3f2285f7 100644 --- a/bookwyrm/models/book.py +++ b/bookwyrm/models/book.py @@ -178,7 +178,6 @@ class Edition(Book): activity_serializer = activitypub.Edition name_field = 'title' - @property def get_rank(self): ''' calculate how complete the data is on this edition ''' if self.parent_work and self.parent_work.default_edition == self: @@ -204,7 +203,7 @@ class Edition(Book): self.isbn_13 = isbn_10_to_13(self.isbn_10) # set rank - self.edition_rank = self.get_rank + self.edition_rank = self.get_rank() return super().save(*args, **kwargs)