Fix unit tests
This commit is contained in:
parent
e10b577ac1
commit
b1a87cb08b
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue