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):
|
||||
content = graphene.UUID()
|
||||
content_block = graphene.ID()
|
||||
block = graphene.String()
|
||||
type = graphene.String()
|
||||
parent = graphene.ID()
|
||||
text = graphene.String(required=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -59,11 +59,13 @@ class AddNote(relay.ClientIDMutation):
|
|||
|
||||
note = kwargs.get('note')
|
||||
content_uuid = note.get('content', '')
|
||||
content_block_id = note.get('content_block', '')
|
||||
content_block_id = note.get('block', '')
|
||||
parent = note.get('parent')
|
||||
text = note.get('text')
|
||||
|
||||
if content_uuid != '':
|
||||
type = note.get('type')
|
||||
if type == 'ContentBlockNode':
|
||||
content_block = get_object(ContentBlock, content_block_id)
|
||||
|
||||
bookmark = ContentBlockBookmark.objects.get(
|
||||
|
|
@ -71,6 +73,13 @@ class AddNote(relay.ClientIDMutation):
|
|||
uuid=content_uuid,
|
||||
user=user
|
||||
)
|
||||
else:
|
||||
instrument = BasicKnowledge.objects.get(slug=content_block_id)
|
||||
bookmark = InstrumentBookmark.objects.get(
|
||||
instrument=instrument,
|
||||
uuid=content_uuid,
|
||||
user=user
|
||||
)
|
||||
else:
|
||||
type, id = from_global_id(parent)
|
||||
if type == 'ModuleNode':
|
||||
|
|
@ -176,7 +185,7 @@ class UpdateModuleBookmark(relay.ClientIDMutation):
|
|||
class UpdateInstrumentBookmark(relay.ClientIDMutation):
|
||||
class Input:
|
||||
uuid = graphene.UUID(required=True)
|
||||
instrument = graphene.ID(required=True)
|
||||
instrument = graphene.String(required=True)
|
||||
bookmarked = graphene.Boolean(required=True)
|
||||
|
||||
success = graphene.Boolean()
|
||||
|
|
@ -184,11 +193,11 @@ class UpdateInstrumentBookmark(relay.ClientIDMutation):
|
|||
@classmethod
|
||||
def mutate_and_get_payload(cls, root, info, **kwargs):
|
||||
user = info.context.user
|
||||
instrument_id = kwargs.get('instrument')
|
||||
instrument_slug = kwargs.get('instrument')
|
||||
uuid = kwargs.get('uuid')
|
||||
bookmarked = kwargs.get('bookmarked')
|
||||
|
||||
instrument = get_object(BasicKnowledge, instrument_id)
|
||||
instrument = BasicKnowledge.objects.get(slug=instrument_slug)
|
||||
|
||||
if bookmarked:
|
||||
InstrumentBookmark.objects.create(
|
||||
|
|
|
|||
Loading…
Reference in New Issue