-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2905 from bookwyrm-social/broken-editions
Adds management command to repair editions in bad state
- Loading branch information
Showing
5 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" Repair editions with missing works """ | ||
from django.core.management.base import BaseCommand | ||
from bookwyrm import models | ||
|
||
|
||
class Command(BaseCommand): | ||
"""command-line options""" | ||
|
||
help = "Repairs an edition that is in a broken state" | ||
|
||
# pylint: disable=unused-argument | ||
def handle(self, *args, **options): | ||
"""Find and repair broken editions""" | ||
# Find broken editions | ||
editions = models.Edition.objects.filter(parent_work__isnull=True) | ||
self.stdout.write(f"Repairing {editions.count()} edition(s):") | ||
|
||
# Do repair | ||
for edition in editions: | ||
edition.repair() | ||
self.stdout.write(".", ending="") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters