Add subtitle block to room entry contents
Resolves MS-487
This commit is contained in:
parent
ebb8b11f74
commit
f2f7d30959
|
|
@ -82,7 +82,6 @@
|
|||
block: 'subtitle',
|
||||
title: 'Untertitel',
|
||||
icon: 'title-icon',
|
||||
show: hasDefaultFeatures
|
||||
},
|
||||
{
|
||||
type: 'link',
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from django.db import models
|
|||
from django_extensions.db.models import TitleSlugDescriptionModel
|
||||
from wagtail.core.fields import StreamField
|
||||
|
||||
from books.blocks import DocumentBlock, ImageUrlBlock, LinkBlock, VideoBlock
|
||||
from books.blocks import DocumentBlock, ImageUrlBlock, LinkBlock, SubtitleBlock, VideoBlock
|
||||
from books.models import TextBlock
|
||||
from core.mixins import GraphqlNodeMixin
|
||||
from users.models import SchoolClass
|
||||
|
|
@ -37,6 +37,7 @@ class RoomEntry(TitleSlugDescriptionModel):
|
|||
('image_url_block', ImageUrlBlock()),
|
||||
('link_block', LinkBlock()),
|
||||
('document_block', DocumentBlock()),
|
||||
('subtitle', SubtitleBlock()),
|
||||
('video_block', VideoBlock())
|
||||
], null=True, blank=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,32 @@ from rooms.factories import RoomEntryFactory, RoomFactory
|
|||
from rooms.models import RoomEntry
|
||||
from users.factories import SchoolClassFactory
|
||||
|
||||
ADD_ROOM_ENTRY_MUTATION = """
|
||||
fragment RoomEntryParts on RoomEntryNode {
|
||||
id
|
||||
slug
|
||||
title
|
||||
contents
|
||||
author {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
avatarUrl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mutation AddRoomEntry($input: AddRoomEntryInput!){
|
||||
addRoomEntry(input: $input) {
|
||||
roomEntry {
|
||||
...RoomEntryParts
|
||||
}
|
||||
errors
|
||||
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
class RoomEntryMutationsTestCase(SkillboxTestCase):
|
||||
def setUp(self):
|
||||
|
|
@ -141,31 +167,6 @@ class RoomEntryMutationsTestCase(SkillboxTestCase):
|
|||
|
||||
def test_add_room_entry_not_owner_from_other_class(self):
|
||||
self.assertEqual(RoomEntry.objects.count(), 1)
|
||||
mutation = """
|
||||
fragment RoomEntryParts on RoomEntryNode {
|
||||
id
|
||||
slug
|
||||
title
|
||||
contents
|
||||
author {
|
||||
id
|
||||
firstName
|
||||
lastName
|
||||
avatarUrl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mutation AddRoomEntry($input: AddRoomEntryInput!){
|
||||
addRoomEntry(input: $input) {
|
||||
roomEntry {
|
||||
...RoomEntryParts
|
||||
}
|
||||
errors
|
||||
|
||||
}
|
||||
}
|
||||
"""
|
||||
# input:
|
||||
# title = graphene.String(required=True)
|
||||
# contents = graphene.List(ContentElementInput)
|
||||
|
|
@ -175,7 +176,7 @@ mutation AddRoomEntry($input: AddRoomEntryInput!){
|
|||
'roomSlug': self.room.slug
|
||||
}
|
||||
|
||||
result = self.get_client(self.yet_another_user).execute(mutation, variables={
|
||||
result = self.get_client(self.yet_another_user).execute(ADD_ROOM_ENTRY_MUTATION, variables={
|
||||
'input': {
|
||||
'roomEntry': room_entry
|
||||
}
|
||||
|
|
@ -183,3 +184,26 @@ mutation AddRoomEntry($input: AddRoomEntryInput!){
|
|||
self.assertIsNotNone(result.errors)
|
||||
self.assertTrue('message' in result.errors[0])
|
||||
self.assertEqual(result.errors[0]['message'], 'You are in the wrong class')
|
||||
|
||||
def test_add_room_entry(self):
|
||||
self.assertEqual(RoomEntry.objects.count(), 1)
|
||||
text_block = {"type": "text_block", "value": {"text": "<p>some text</p>"}}
|
||||
subtitle_block = {"type": "subtitle", "value": {"text": "A subtitle"}}
|
||||
room_entry = {
|
||||
'title': 'A room entry',
|
||||
'roomSlug': self.room.slug,
|
||||
'contents': [text_block, subtitle_block]
|
||||
}
|
||||
result = self.get_client(self.user).execute(ADD_ROOM_ENTRY_MUTATION, variables={
|
||||
'input': {
|
||||
'roomEntry': room_entry
|
||||
}
|
||||
})
|
||||
self.assertIsNone(result.errors)
|
||||
room_entry_data = result.data.get('addRoomEntry').get('roomEntry')
|
||||
contents = room_entry_data.get('contents')
|
||||
self.assertEqual(len(contents), 2)
|
||||
text, subtitle = contents
|
||||
self.assertEqual(text.get('type'), 'text_block')
|
||||
self.assertEqual(subtitle.get('type'), 'subtitle')
|
||||
self.assertEqual(RoomEntry.objects.count(), 2)
|
||||
|
|
|
|||
Loading…
Reference in New Issue