diff --git a/server/books/models/snapshot.py b/server/books/models/snapshot.py index 477a173c..c0a1c72e 100644 --- a/server/books/models/snapshot.py +++ b/server/books/models/snapshot.py @@ -144,7 +144,7 @@ class Snapshot(models.Model): content_block.hidden_for.add(selected_class) for custom_content_block in self.custom_content_blocks.all(): custom_content_block.to_regular_content_block(owner=user, school_class=selected_class) - for chapter_snapshot in self.chapters.through.objects.all(): + for chapter_snapshot in ChapterSnapshot.objects.filter(snapshot=self): chapter = chapter_snapshot.chapter if chapter_snapshot.title_hidden: chapter.title_hidden_for.add(selected_class) diff --git a/server/books/tests/test_snapshots.py b/server/books/tests/test_snapshots.py index 73646da1..f30f2b0a 100644 --- a/server/books/tests/test_snapshots.py +++ b/server/books/tests/test_snapshots.py @@ -317,6 +317,13 @@ class CreateSnapshotTestCase(SkillboxTestCase): def test_snapshot_chapter_visibility_after_apply(self): + result = self.graphene_client.execute(CREATE_SNAPSHOT_MUTATION, variables={ + 'input': { + 'module': self.slug, + 'selectedClass': to_global_id('SchoolClassNode', self.skillbox_class.pk), + } + }) + self.chapter.title_hidden_for.remove(self.skillbox_class) self.chapter.description_hidden_for.remove(self.skillbox_class)