Fix assignment creation
This commit is contained in:
parent
eef657e318
commit
13717c1371
|
|
@ -32,6 +32,7 @@ class MutateContentBlock(relay.ClientIDMutation):
|
||||||
block_type = content_block_data.get('type', ContentBlock.NORMAL)
|
block_type = content_block_data.get('type', ContentBlock.NORMAL)
|
||||||
|
|
||||||
content_block = get_object(ContentBlock, id_param)
|
content_block = get_object(ContentBlock, id_param)
|
||||||
|
module = content_block.get_parent().get_parent().specific
|
||||||
|
|
||||||
if visibility_list is not None:
|
if visibility_list is not None:
|
||||||
for v in visibility_list:
|
for v in visibility_list:
|
||||||
|
|
@ -45,7 +46,7 @@ class MutateContentBlock(relay.ClientIDMutation):
|
||||||
content_block.title = title
|
content_block.title = title
|
||||||
|
|
||||||
if contents is not None:
|
if contents is not None:
|
||||||
content_block.contents = json.dumps([handle_content_block(c, info.context) for c in contents])
|
content_block.contents = json.dumps([handle_content_block(c, info.context, module) for c in contents])
|
||||||
|
|
||||||
content_block.type = set_user_defined_block_type(block_type)
|
content_block.type = set_user_defined_block_type(block_type)
|
||||||
|
|
||||||
|
|
@ -96,7 +97,9 @@ class AddContentBlock(relay.ClientIDMutation):
|
||||||
revision.publish()
|
revision.publish()
|
||||||
new_content_block.save()
|
new_content_block.save()
|
||||||
|
|
||||||
new_content_block.contents = json.dumps([handle_content_block(c, context) for c in
|
module = new_content_block.get_parent().get_parent().specific
|
||||||
|
|
||||||
|
new_content_block.contents = json.dumps([handle_content_block(c, context, module) for c in
|
||||||
contents]) # can only do this after the content block has been saved
|
contents]) # can only do this after the content block has been saved
|
||||||
new_content_block.save()
|
new_content_block.save()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ ALLOWED_BLOCKS = (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def handle_content_block(content, context, allowed_blocks=ALLOWED_BLOCKS):
|
def handle_content_block(content, context, module, allowed_blocks=ALLOWED_BLOCKS):
|
||||||
# todo: add all the content blocks
|
# todo: add all the content blocks
|
||||||
# todo: sanitize user inputs!
|
# todo: sanitize user inputs!
|
||||||
if content['type'] not in allowed_blocks:
|
if content['type'] not in allowed_blocks:
|
||||||
|
|
@ -48,7 +48,8 @@ def handle_content_block(content, context, allowed_blocks=ALLOWED_BLOCKS):
|
||||||
assignment = Assignment.objects.create(
|
assignment = Assignment.objects.create(
|
||||||
title=content['value']['title'],
|
title=content['value']['title'],
|
||||||
assignment=content['value']['assignment'],
|
assignment=content['value']['assignment'],
|
||||||
owner=context.user
|
owner=context.user,
|
||||||
|
module=module,
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue