Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions csfieldguide/chapters/management/commands/loadchapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from utils.LoaderFactory import LoaderFactory
from utils.errors.MissingRequiredFieldError import MissingRequiredFieldError
from utils.errors.InvalidYAMLValueError import InvalidYAMLValueError
from chapters.models import Chapter


class Command(BaseCommand):
Expand Down Expand Up @@ -87,5 +88,9 @@ def handle(self, *args, **options):
structure_filename=chapter_structure_file,
).load()

_, result = Chapter.objects.exclude(slug__in=chapters.keys()).delete()
if result.get("chapters.Chapter", 0) > 0:
base_loader.log("Deleted {} chapters.".format(result["chapters.Chapter"]))

base_loader.log("All chapters loaded!")
base_loader.log("")