Merge branch 'feature/MS-540-Use-wagtail-documents' into release/Wagtail-anpassungen
This commit is contained in:
commit
3b7595db9d
|
|
@ -0,0 +1,44 @@
|
|||
<template>
|
||||
<div class="cms-document-block">
|
||||
<document-icon class="cms-document-block__icon" />
|
||||
<a
|
||||
:href="value.url"
|
||||
class="cms-document-block__link"
|
||||
target="_blank"
|
||||
>{{ value.title }}</a>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const DocumentIcon = () => import(/* webpackChunkName: "icons" */'@/components/icons/DocumentIcon');
|
||||
|
||||
export default {
|
||||
props: {
|
||||
value: Object,
|
||||
},
|
||||
|
||||
components: {
|
||||
DocumentIcon,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import "~styles/helpers";
|
||||
|
||||
.cms-document-block {
|
||||
display: grid;
|
||||
grid-template-columns: 50px 1fr 50px;
|
||||
align-items: center;
|
||||
|
||||
&__icon {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
&__link {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -31,6 +31,7 @@ const ImageUrlBlock = () => import(/* webpackChunkName: "content-components" */'
|
|||
const VideoBlock = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/VideoBlock');
|
||||
const LinkBlock = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/LinkBlock');
|
||||
const DocumentBlock = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/DocumentBlock');
|
||||
const CmsDocumentBlock = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/CmsDocumentBlock');
|
||||
const InfogramBlock = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/InfogramBlock');
|
||||
const ThinglinkBlock = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/ThinglinkBlock');
|
||||
const GeniallyBlock = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/GeniallyBlock');
|
||||
|
|
@ -88,6 +89,7 @@ export default {
|
|||
'content_list': ContentListBlock,
|
||||
'module_room_slug': ModuleRoomSlug,
|
||||
'thinglink_block': ThinglinkBlock,
|
||||
'cms_document_block': CmsDocumentBlock,
|
||||
Survey,
|
||||
Solution,
|
||||
Instruction,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from graphene.types import Scalar
|
|||
from graphene_django.converter import convert_django_field
|
||||
from graphql_relay import to_global_id
|
||||
from wagtail.core.fields import StreamField
|
||||
from wagtail.documents.models import Document
|
||||
from wagtail.images.models import Image
|
||||
|
||||
from assignments.models import Assignment
|
||||
|
|
@ -85,6 +86,19 @@ def augment_fields(raw_data):
|
|||
item_data = data['value']
|
||||
data['value'] = augment_fields(item_data)
|
||||
|
||||
if _type == 'cms_document_block':
|
||||
_value = data['value']
|
||||
document = Document.objects.get(id=_value)
|
||||
value = {
|
||||
'value': _value,
|
||||
'id': document.id,
|
||||
'file_name': document.filename,
|
||||
'file_extension': document.file_extension,
|
||||
'url': document.url,
|
||||
'title': document.title
|
||||
}
|
||||
data['value'] = value
|
||||
|
||||
return raw_data
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from django.db import models
|
|||
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList, StreamFieldPanel
|
||||
from wagtail.core.blocks import StreamBlock
|
||||
from wagtail.core.fields import StreamField
|
||||
from wagtail.documents.blocks import DocumentChooserBlock
|
||||
from wagtail.images.blocks import ImageChooserBlock
|
||||
|
||||
from core.wagtail_utils import get_default_settings
|
||||
|
|
@ -63,7 +64,8 @@ class ContentBlock(StrictHierarchyPage):
|
|||
('thinglink_block', ThinglinkBlock()),
|
||||
('subtitle', SubtitleBlock()),
|
||||
('instruction', InstructionBlock()),
|
||||
('module_room_slug', ModuleRoomSlugBlock())
|
||||
('module_room_slug', ModuleRoomSlugBlock()),
|
||||
('cms_document_block', DocumentChooserBlock())
|
||||
]
|
||||
|
||||
content_list_item = StreamBlock(content_blocks)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class InputTypes(graphene.Enum):
|
|||
video_block = 'video_block'
|
||||
document_block = 'document_block'
|
||||
content_list_item = 'content_list_item'
|
||||
subtitle= 'subtitle'
|
||||
subtitle = 'subtitle'
|
||||
|
||||
|
||||
class ContentElementValueInput(InputObjectType):
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ ALLOWED_BLOCKS = (
|
|||
'assignment',
|
||||
'document_block',
|
||||
'content_list_item',
|
||||
'subtitle'
|
||||
'subtitle',
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ from django.urls import re_path
|
|||
from django.views.generic import RedirectView
|
||||
from wagtail.admin import urls as wagtailadmin_urls
|
||||
from wagtail.core import urls as wagtail_urls
|
||||
from wagtail.documents import urls as wagtaildocs_urls
|
||||
|
||||
from wagtailautocomplete.urls.admin import urlpatterns as autocomplete_admin_urls
|
||||
|
||||
from core import views
|
||||
|
|
@ -19,6 +21,7 @@ urlpatterns = [
|
|||
# wagtail
|
||||
url(r'^admin/autocomplete/', include(autocomplete_admin_urls)),
|
||||
url(r'^cms/', include(wagtailadmin_urls)),
|
||||
url(r'^documents/', include(wagtaildocs_urls)),
|
||||
|
||||
# graphql backend
|
||||
url(r'^api/', include('api.urls', namespace="api")),
|
||||
|
|
|
|||
Loading…
Reference in New Issue