Merge branch 'feature/Anzeige-Bookmarks' into develop

This commit is contained in:
Lorenz Padberg 2024-05-03 17:25:46 +02:00
commit 1ae8de894b
1 changed files with 18 additions and 2 deletions

View File

@ -1,5 +1,8 @@
import json
import uuid import uuid
import graphene import graphene
from basicknowledge.models import BasicKnowledge
from basicknowledge.queries import InstrumentNode from basicknowledge.queries import InstrumentNode
from books.schema.nodes import ContentBlockNode, ModuleNode from books.schema.nodes import ContentBlockNode, ModuleNode
from books.schema.nodes.chapter import ChapterNode from books.schema.nodes.chapter import ChapterNode
@ -19,7 +22,7 @@ logger = get_logger(__name__)
content_dict = { content_dict = {
'assignment': 'Auftrag', 'assignment': 'Auftrag',
'basic_knowledge': '', 'basic_knowledge': 'dsafasdfasdf',
'survey': 'Übung', 'survey': 'Übung',
'image_block': 'Bild', 'image_block': 'Bild',
'link_block': 'Link', 'link_block': 'Link',
@ -39,11 +42,24 @@ def find_content(content_list, bookmark):
found = (content for content in content_list if uuid.UUID(content['id']) == bookmark.uuid) found = (content for content in content_list if uuid.UUID(content['id']) == bookmark.uuid)
content = next(found, None) content = next(found, None)
if content is None: if content is None:
for c in content_list:
if c.get('id') == bookmark.uuid:
return c.get('value').get('text', '')
return c.get('value').get('text', '')
return '' return ''
if content['type'] in ['text_block', 'subtitle', 'solution']: if content['type'] in ['text_block', 'subtitle', 'solution']:
return content['value'].get('text', '') return content['value'].get('text', '')
if content['type'] in ['basic_knowledge']: if content['type'] in ['basic_knowledge']:
return content['value'].get('description', '') description = content['value'].get('description', '')
if not description:
try:
return BasicKnowledge.objects.get(pk=content['value']['basic_knowledge']).title
except BasicKnowledge.DoesNotExist:
return ''
else:
return description
print(bookmark.uuid)
print(json.dumps(content_dict, indent=4))
return content_dict.get(content['type'], '') return content_dict.get(content['type'], '')
class NoteNode(DjangoObjectType): class NoteNode(DjangoObjectType):