Use slug to identify instruments on server
This commit is contained in:
parent
ef6711965f
commit
5f6817ebbe
|
|
@ -4,7 +4,8 @@ from graphene import InputObjectType
|
||||||
|
|
||||||
class AddNoteArgument(InputObjectType):
|
class AddNoteArgument(InputObjectType):
|
||||||
content = graphene.UUID()
|
content = graphene.UUID()
|
||||||
content_block = graphene.ID()
|
block = graphene.String()
|
||||||
|
type = graphene.String()
|
||||||
parent = graphene.ID()
|
parent = graphene.ID()
|
||||||
text = graphene.String(required=True)
|
text = graphene.String(required=True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,18 +59,27 @@ class AddNote(relay.ClientIDMutation):
|
||||||
|
|
||||||
note = kwargs.get('note')
|
note = kwargs.get('note')
|
||||||
content_uuid = note.get('content', '')
|
content_uuid = note.get('content', '')
|
||||||
content_block_id = note.get('content_block', '')
|
content_block_id = note.get('block', '')
|
||||||
parent = note.get('parent')
|
parent = note.get('parent')
|
||||||
text = note.get('text')
|
text = note.get('text')
|
||||||
|
|
||||||
if content_uuid != '':
|
if content_uuid != '':
|
||||||
content_block = get_object(ContentBlock, content_block_id)
|
type = note.get('type')
|
||||||
|
if type == 'ContentBlockNode':
|
||||||
|
content_block = get_object(ContentBlock, content_block_id)
|
||||||
|
|
||||||
bookmark = ContentBlockBookmark.objects.get(
|
bookmark = ContentBlockBookmark.objects.get(
|
||||||
content_block=content_block,
|
content_block=content_block,
|
||||||
uuid=content_uuid,
|
uuid=content_uuid,
|
||||||
user=user
|
user=user
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
instrument = BasicKnowledge.objects.get(slug=content_block_id)
|
||||||
|
bookmark = InstrumentBookmark.objects.get(
|
||||||
|
instrument=instrument,
|
||||||
|
uuid=content_uuid,
|
||||||
|
user=user
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
type, id = from_global_id(parent)
|
type, id = from_global_id(parent)
|
||||||
if type == 'ModuleNode':
|
if type == 'ModuleNode':
|
||||||
|
|
@ -176,7 +185,7 @@ class UpdateModuleBookmark(relay.ClientIDMutation):
|
||||||
class UpdateInstrumentBookmark(relay.ClientIDMutation):
|
class UpdateInstrumentBookmark(relay.ClientIDMutation):
|
||||||
class Input:
|
class Input:
|
||||||
uuid = graphene.UUID(required=True)
|
uuid = graphene.UUID(required=True)
|
||||||
instrument = graphene.ID(required=True)
|
instrument = graphene.String(required=True)
|
||||||
bookmarked = graphene.Boolean(required=True)
|
bookmarked = graphene.Boolean(required=True)
|
||||||
|
|
||||||
success = graphene.Boolean()
|
success = graphene.Boolean()
|
||||||
|
|
@ -184,11 +193,11 @@ class UpdateInstrumentBookmark(relay.ClientIDMutation):
|
||||||
@classmethod
|
@classmethod
|
||||||
def mutate_and_get_payload(cls, root, info, **kwargs):
|
def mutate_and_get_payload(cls, root, info, **kwargs):
|
||||||
user = info.context.user
|
user = info.context.user
|
||||||
instrument_id = kwargs.get('instrument')
|
instrument_slug = kwargs.get('instrument')
|
||||||
uuid = kwargs.get('uuid')
|
uuid = kwargs.get('uuid')
|
||||||
bookmarked = kwargs.get('bookmarked')
|
bookmarked = kwargs.get('bookmarked')
|
||||||
|
|
||||||
instrument = get_object(BasicKnowledge, instrument_id)
|
instrument = BasicKnowledge.objects.get(slug=instrument_slug)
|
||||||
|
|
||||||
if bookmarked:
|
if bookmarked:
|
||||||
InstrumentBookmark.objects.create(
|
InstrumentBookmark.objects.create(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue