Merge pull request #2905 from bookwyrm-social/broken-editions
Adds management command to repair editions in bad state
This commit is contained in:
commit
9d69f2fb3e
5 changed files with 57 additions and 2 deletions
|
@ -24,8 +24,7 @@ class Book(TestCase):
|
|||
title="Example Work", remote_id="https://example.com/book/1"
|
||||
)
|
||||
self.first_edition = models.Edition.objects.create(
|
||||
title="Example Edition",
|
||||
parent_work=self.work,
|
||||
title="Example Edition", parent_work=self.work
|
||||
)
|
||||
self.second_edition = models.Edition.objects.create(
|
||||
title="Another Example Edition",
|
||||
|
@ -143,3 +142,15 @@ class Book(TestCase):
|
|||
for article in articles
|
||||
)
|
||||
self.assertTrue(all(book.sort_title == "test edition" for book in books))
|
||||
|
||||
def test_repair_edition(self):
|
||||
"""Fix editions with no works"""
|
||||
edition = models.Edition.objects.create(title="test")
|
||||
edition.authors.set([models.Author.objects.create(name="Author Name")])
|
||||
self.assertIsNone(edition.parent_work)
|
||||
|
||||
edition.repair()
|
||||
edition.refresh_from_db()
|
||||
|
||||
self.assertEqual(edition.parent_work.title, "test")
|
||||
self.assertEqual(edition.parent_work.authors.count(), 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue