Fix unit tests

This commit is contained in:
Ramon Wenger 2019-09-09 15:34:13 +02:00
parent e10b577ac1
commit b1a87cb08b
1 changed files with 12 additions and 3 deletions

View File

@ -9,6 +9,7 @@ from wagtail.images.blocks import ImageChooserBlock
from books.blocks import TextBlock, BasicKnowledgeBlock, LinkBlock, VideoBlock, DocumentBlock, \
ImageUrlBlock, AssignmentBlock, InfogramBlock, GeniallyBlock, SubtitleBlock, SurveyBlock, ModuleRoomSlugBlock
from core.wagtail_utils import StrictHierarchyPage
from surveys.models import Survey
from users.models import SchoolClass
logger = logging.getLogger(__name__)
@ -86,10 +87,18 @@ class ContentBlock(StrictHierarchyPage):
return self.get_parent().get_parent().specific
def save(self, *args, **kwargs):
for type, content_block, _ in self.contents.stream_data:
if type == 'survey':
for data in self.contents.stream_data:
if isinstance(data, tuple):
block_type, value = (data[0], data[1])
else:
block_type = data['type']
value = data['value']
if block_type == 'survey':
module = self.module
survey = content_block['survey_id']
survey = value['survey_id']
if isinstance(survey, int):
survey = Survey.objects.get(pk=survey)
if survey.module != module:
survey.module = module
survey.save()