Add path property to contentblock
This commit is contained in:
parent
afefc7f31e
commit
af4f19720b
|
|
@ -36,11 +36,12 @@ from core.wagtail_utils import StrictHierarchyPage
|
|||
from notes.models import ContentBlockBookmark
|
||||
from surveys.models import Survey
|
||||
from users.models import SchoolClass, User
|
||||
from core.mixins import GraphqlNodeMixin
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ContentBlock(StrictHierarchyPage):
|
||||
class ContentBlock(StrictHierarchyPage, GraphqlNodeMixin):
|
||||
class Meta:
|
||||
verbose_name = "Inhaltsblock"
|
||||
verbose_name_plural = "Inhaltsblöcke"
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class ContentBlockNode(DjangoObjectType, HiddenAndVisibleForMixin):
|
|||
bookmarks = graphene.List(ContentBlockBookmarkNode)
|
||||
original_creator = graphene.Field('users.schema.PublicUserNode')
|
||||
instrument_category = graphene.Field(InstrumentCategoryNode)
|
||||
path = graphene.String()
|
||||
|
||||
class Meta:
|
||||
model = ContentBlock
|
||||
|
|
@ -99,11 +100,17 @@ class ContentBlockNode(DjangoObjectType, HiddenAndVisibleForMixin):
|
|||
return category
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def resolve_path(root: ContentBlock, info, **kwargs):
|
||||
module = root.get_parent().get_parent()
|
||||
return f'module/{module.slug}#{root.graphql_id}'
|
||||
|
||||
|
||||
def process_module_room_slug_block(content):
|
||||
if content['type'] == 'module_room_slug':
|
||||
try:
|
||||
module_room_slug = ModuleRoomSlug.objects.get(title=content['value']['title'])
|
||||
module_room_slug = ModuleRoomSlug.objects.get(
|
||||
title=content['value']['title'])
|
||||
content['value'] = {
|
||||
'title': content['value']['title'],
|
||||
'slug': module_room_slug.slug
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ logger = get_logger(__name__)
|
|||
class BookQuery(object):
|
||||
node = relay.Node.Field()
|
||||
topic = graphene.Field(TopicOr404Node, slug=graphene.String())
|
||||
module = graphene.Field(ModuleNode, slug=graphene.String(), id=graphene.ID())
|
||||
module = graphene.Field(
|
||||
ModuleNode, slug=graphene.String(), id=graphene.ID())
|
||||
chapter = relay.Node.Field(ChapterNode)
|
||||
content_block = relay.Node.Field(ContentBlockNode)
|
||||
snapshot = relay.Node.Field(SnapshotNode)
|
||||
|
|
|
|||
|
|
@ -300,6 +300,7 @@ type ContentBlockNode implements Node & ContentBlockInterface {
|
|||
bookmarks: [ContentBlockBookmarkNode]
|
||||
originalCreator: PublicUserNode
|
||||
instrumentCategory: InstrumentCategoryNode
|
||||
path: String
|
||||
}
|
||||
|
||||
type ContentBlockNodeConnection {
|
||||
|
|
@ -512,6 +513,7 @@ enum InputTypes {
|
|||
document_block
|
||||
content_list_item
|
||||
subtitle
|
||||
readonly
|
||||
}
|
||||
|
||||
type InstrumentBookmarkNode implements Node {
|
||||
|
|
|
|||
Loading…
Reference in New Issue