X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/0c3e8f92c425a22c1b9da737db89977d31312353..4bb3e264dc9d9953c6a1ffcb0290a2ba0e0c094b:/apps/catalogue/management/commands/checkintegrity.py diff --git a/apps/catalogue/management/commands/checkintegrity.py b/apps/catalogue/management/commands/checkintegrity.py index 0892a7815..6ae2b9a2f 100644 --- a/apps/catalogue/management/commands/checkintegrity.py +++ b/apps/catalogue/management/commands/checkintegrity.py @@ -42,20 +42,20 @@ class Command(BaseCommand): print "To resolve: republish parent book." print - # Check for parent l-tags. + # Check for ancestry. parents = [] parent = book.parent while parent: parents.append(parent) parent = parent.parent - ltags = [b.book_tag() for b in parents] - if set(ltags) != set(book.tags.filter(category='book')): + ancestors = list(book.ancestor.all()) + if set(ancestors) != set(parents): if options['verbose']: - print "Wrong book tags for book:", book - print "Is: ", ", ".join(sorted(t.slug for t in book.tags.filter(category='book'))) - print "Should be:", ", ".join(sorted(t.slug for t in ltags)) + print "Wrong ancestry for book:", book + print "Is: ", ", ".join(ancestors) + print "Should be:", ", ".join(parents) if not options['dry_run']: - book.tags = ltags + list(book.tags.exclude(category='book')) + book.repopulate_ancestors() if options['verbose']: print "Fixed." if options['verbose']: