Update mutation to also handle solutions
This commit is contained in:
parent
12a4d7f477
commit
9e84908d10
|
|
@ -13,6 +13,7 @@ class InputTypes(graphene.Enum):
|
|||
document_block = "document_block"
|
||||
content_list_item = "content_list_item"
|
||||
subtitle = "subtitle"
|
||||
solution = "solution"
|
||||
readonly = "readonly"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@ import bleach
|
|||
from api.utils import get_object
|
||||
from assignments.models import Assignment
|
||||
from books.models import ContentBlock
|
||||
from core.logger import get_logger
|
||||
from wagtail.blocks import StreamValue
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
class AssignmentParameterException(Exception):
|
||||
pass
|
||||
|
|
@ -46,6 +49,7 @@ ALLOWED_BLOCKS = (
|
|||
"document_block",
|
||||
"content_list_item",
|
||||
"subtitle",
|
||||
"solution",
|
||||
"readonly",
|
||||
)
|
||||
|
||||
|
|
@ -75,6 +79,7 @@ def handle_content_block(
|
|||
# todo: add all the content blocks
|
||||
# todo: sanitize user inputs!
|
||||
if content["type"] not in allowed_blocks:
|
||||
logger.info("not in allowed blocks")
|
||||
return
|
||||
|
||||
id = content.get("id")
|
||||
|
|
@ -136,6 +141,12 @@ def handle_content_block(
|
|||
content_type = "document_block"
|
||||
value = {"url": bleach.clean(content["value"]["url"])}
|
||||
return get_content_dict(content_type=content_type, id=id, value=value)
|
||||
elif content["type"] == "solution":
|
||||
content_type = "solution"
|
||||
value = {
|
||||
"text": handle_text(bleach.clean(content["value"]["text"], strip=True)),
|
||||
}
|
||||
return get_content_dict(content_type=content_type, id=id, value=value)
|
||||
elif content["type"] == "subtitle":
|
||||
content_type = "subtitle"
|
||||
value = {"text": bleach.clean(content["value"]["text"])}
|
||||
|
|
|
|||
Loading…
Reference in New Issue