Skip to content

Commit

Permalink
Merge pull request #106 from molgen/add-wagtailvideos
Browse files Browse the repository at this point in the history
Add wagtailvideos
  • Loading branch information
donald authored Jan 19, 2021
2 parents f4c2c0e + 026d0b4 commit a39fa4b
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 12 deletions.
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
'modelcluster',
'taggit',
'rest_framework',
'wagtailvideos',
]
LOCAL_APPS = [
'mpicms.base.apps.BaseAppConfig',
Expand Down
20 changes: 19 additions & 1 deletion mpicms/base/blocks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from django.utils.translation import gettext_lazy as _
from django.utils.functional import cached_property

from wagtail.core import blocks
from wagtail.snippets.blocks import SnippetChooserBlock
from wagtail.contrib.table_block.blocks import TableBlock as WagtailTableBlock

import wagtailvideos.models
import wagtailvideos.widgets

class ContactBlock(blocks.StructBlock):
contact = SnippetChooserBlock('personal.Contact', label=_("Contact"))
Expand All @@ -24,11 +26,27 @@ class Meta: # noqa
template = 'base/blocks/table_block.html'


class VideoBlock(blocks.ChooserBlock):
@cached_property
def target_model(self):
return wagtailvideos.models.Video

@cached_property
def widget(self):
return wagtailvideos.widgets.AdminVideoChooser

def render_basic(self, value, context=None):
return value.video_tag(attrs={"controls": True}) if value else ""

class Meta:
icon = "fa-play"

class ContentBlock(blocks.StreamBlock):
richtext = blocks.RichTextBlock(label=_('Editor'))
markdown = MarkdownBlock(label=_('Raw Markdown'))
table = TableBlock(label=_('Table'))
contact = ContactBlock(label=_('Contact'))
video = VideoBlock(label=_('Video'))

class Meta: # noqa
label = _('content')
Expand Down
47 changes: 47 additions & 0 deletions mpicms/base/migrations/0053_auto_20210114_1926.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated by Django 3.1 on 2021-01-14 18:26

from django.db import migrations
import mpicms.base.blocks
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.snippets.blocks


class Migration(migrations.Migration):

dependencies = [
('base', '0052_formfield_clean_name'),
]

operations = [
migrations.AlterField(
model_name='homepage',
name='body',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(label='Editor')), ('markdown', mpicms.base.blocks.MarkdownBlock(label='Raw Markdown')), ('table', mpicms.base.blocks.TableBlock(label='Table')), ('contact', wagtail.core.blocks.StructBlock([('contact', wagtail.snippets.blocks.SnippetChooserBlock('personal.Contact', label='Contact')), ('information', wagtail.core.blocks.TextBlock(label='Information', required=False))], label='Contact')), ('video', mpicms.base.blocks.VideoBlock(label='Video'))], blank=True, verbose_name='content'),
),
migrations.AlterField(
model_name='homepage',
name='body_de',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(label='Editor')), ('markdown', mpicms.base.blocks.MarkdownBlock(label='Raw Markdown')), ('table', mpicms.base.blocks.TableBlock(label='Table')), ('contact', wagtail.core.blocks.StructBlock([('contact', wagtail.snippets.blocks.SnippetChooserBlock('personal.Contact', label='Contact')), ('information', wagtail.core.blocks.TextBlock(label='Information', required=False))], label='Contact')), ('video', mpicms.base.blocks.VideoBlock(label='Video'))], blank=True, null=True, verbose_name='content'),
),
migrations.AlterField(
model_name='homepage',
name='body_en',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(label='Editor')), ('markdown', mpicms.base.blocks.MarkdownBlock(label='Raw Markdown')), ('table', mpicms.base.blocks.TableBlock(label='Table')), ('contact', wagtail.core.blocks.StructBlock([('contact', wagtail.snippets.blocks.SnippetChooserBlock('personal.Contact', label='Contact')), ('information', wagtail.core.blocks.TextBlock(label='Information', required=False))], label='Contact')), ('video', mpicms.base.blocks.VideoBlock(label='Video'))], blank=True, null=True, verbose_name='content'),
),
migrations.AlterField(
model_name='wikipage',
name='body',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(label='Editor')), ('markdown', mpicms.base.blocks.MarkdownBlock(label='Raw Markdown')), ('table', mpicms.base.blocks.TableBlock(label='Table')), ('contact', wagtail.core.blocks.StructBlock([('contact', wagtail.snippets.blocks.SnippetChooserBlock('personal.Contact', label='Contact')), ('information', wagtail.core.blocks.TextBlock(label='Information', required=False))], label='Contact')), ('video', mpicms.base.blocks.VideoBlock(label='Video'))], blank=True, verbose_name='content'),
),
migrations.AlterField(
model_name='wikipage',
name='body_de',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(label='Editor')), ('markdown', mpicms.base.blocks.MarkdownBlock(label='Raw Markdown')), ('table', mpicms.base.blocks.TableBlock(label='Table')), ('contact', wagtail.core.blocks.StructBlock([('contact', wagtail.snippets.blocks.SnippetChooserBlock('personal.Contact', label='Contact')), ('information', wagtail.core.blocks.TextBlock(label='Information', required=False))], label='Contact')), ('video', mpicms.base.blocks.VideoBlock(label='Video'))], blank=True, null=True, verbose_name='content'),
),
migrations.AlterField(
model_name='wikipage',
name='body_en',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(label='Editor')), ('markdown', mpicms.base.blocks.MarkdownBlock(label='Raw Markdown')), ('table', mpicms.base.blocks.TableBlock(label='Table')), ('contact', wagtail.core.blocks.StructBlock([('contact', wagtail.snippets.blocks.SnippetChooserBlock('personal.Contact', label='Contact')), ('information', wagtail.core.blocks.TextBlock(label='Information', required=False))], label='Contact')), ('video', mpicms.base.blocks.VideoBlock(label='Video'))], blank=True, null=True, verbose_name='content'),
),
]
32 changes: 32 additions & 0 deletions mpicms/events/migrations/0014_auto_20210114_1926.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 3.1 on 2021-01-14 18:26

from django.db import migrations
import mpicms.base.blocks
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.snippets.blocks


class Migration(migrations.Migration):

dependencies = [
('events', '0013_auto_20200119_1857'),
]

operations = [
migrations.AlterField(
model_name='event',
name='body',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(label='Editor')), ('markdown', mpicms.base.blocks.MarkdownBlock(label='Raw Markdown')), ('table', mpicms.base.blocks.TableBlock(label='Table')), ('contact', wagtail.core.blocks.StructBlock([('contact', wagtail.snippets.blocks.SnippetChooserBlock('personal.Contact', label='Contact')), ('information', wagtail.core.blocks.TextBlock(label='Information', required=False))], label='Contact')), ('video', mpicms.base.blocks.VideoBlock(label='Video'))], blank=True, verbose_name='content'),
),
migrations.AlterField(
model_name='event',
name='body_de',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(label='Editor')), ('markdown', mpicms.base.blocks.MarkdownBlock(label='Raw Markdown')), ('table', mpicms.base.blocks.TableBlock(label='Table')), ('contact', wagtail.core.blocks.StructBlock([('contact', wagtail.snippets.blocks.SnippetChooserBlock('personal.Contact', label='Contact')), ('information', wagtail.core.blocks.TextBlock(label='Information', required=False))], label='Contact')), ('video', mpicms.base.blocks.VideoBlock(label='Video'))], blank=True, null=True, verbose_name='content'),
),
migrations.AlterField(
model_name='event',
name='body_en',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(label='Editor')), ('markdown', mpicms.base.blocks.MarkdownBlock(label='Raw Markdown')), ('table', mpicms.base.blocks.TableBlock(label='Table')), ('contact', wagtail.core.blocks.StructBlock([('contact', wagtail.snippets.blocks.SnippetChooserBlock('personal.Contact', label='Contact')), ('information', wagtail.core.blocks.TextBlock(label='Information', required=False))], label='Contact')), ('video', mpicms.base.blocks.VideoBlock(label='Video'))], blank=True, null=True, verbose_name='content'),
),
]
32 changes: 32 additions & 0 deletions mpicms/news/migrations/0024_auto_20210114_1926.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 3.1 on 2021-01-14 18:26

from django.db import migrations
import mpicms.base.blocks
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.snippets.blocks


class Migration(migrations.Migration):

dependencies = [
('news', '0023_auto_20200304_1706'),
]

operations = [
migrations.AlterField(
model_name='newsentry',
name='body',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(label='Editor')), ('markdown', mpicms.base.blocks.MarkdownBlock(label='Raw Markdown')), ('table', mpicms.base.blocks.TableBlock(label='Table')), ('contact', wagtail.core.blocks.StructBlock([('contact', wagtail.snippets.blocks.SnippetChooserBlock('personal.Contact', label='Contact')), ('information', wagtail.core.blocks.TextBlock(label='Information', required=False))], label='Contact')), ('video', mpicms.base.blocks.VideoBlock(label='Video'))], blank=True, verbose_name='content'),
),
migrations.AlterField(
model_name='newsentry',
name='body_de',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(label='Editor')), ('markdown', mpicms.base.blocks.MarkdownBlock(label='Raw Markdown')), ('table', mpicms.base.blocks.TableBlock(label='Table')), ('contact', wagtail.core.blocks.StructBlock([('contact', wagtail.snippets.blocks.SnippetChooserBlock('personal.Contact', label='Contact')), ('information', wagtail.core.blocks.TextBlock(label='Information', required=False))], label='Contact')), ('video', mpicms.base.blocks.VideoBlock(label='Video'))], blank=True, null=True, verbose_name='content'),
),
migrations.AlterField(
model_name='newsentry',
name='body_en',
field=wagtail.core.fields.StreamField([('richtext', wagtail.core.blocks.RichTextBlock(label='Editor')), ('markdown', mpicms.base.blocks.MarkdownBlock(label='Raw Markdown')), ('table', mpicms.base.blocks.TableBlock(label='Table')), ('contact', wagtail.core.blocks.StructBlock([('contact', wagtail.snippets.blocks.SnippetChooserBlock('personal.Contact', label='Contact')), ('information', wagtail.core.blocks.TextBlock(label='Information', required=False))], label='Contact')), ('video', mpicms.base.blocks.VideoBlock(label='Video'))], blank=True, null=True, verbose_name='content'),
),
]
4 changes: 1 addition & 3 deletions mpicms/templates/base/wiki_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ <h2 class="title is-2">{{ page.title }}</h2>
{% endif %}

<div id="content" class="content">
<p>
{% for block in page.body %}
{% include_block block %}
{% endfor %}
</p>
</div>
{% endblock %}
{% endblock %}
26 changes: 26 additions & 0 deletions patches/Fix-typo-in-ogg-media-format-description.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From a34ec1288a11bd5e27ccc9f693da47c1692f973d Mon Sep 17 00:00:00 2001
From: Donald Buczek <buczek@molgen.mpg.de>
Date: Tue, 19 Jan 2021 14:44:32 +0100
Subject: [PATCH] Fix typo in ogg media format description

https://github.com/neon-jungle/wagtailvideos/pull/50
---
lib/python3.7/site-packages/wagtailvideos/models.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/python3.7/site-packages/wagtailvideos/models.py b/lib/python3.7/site-packages/wagtailvideos/models.py
index 75c8e0e..c0ab41b 100644
--- a/lib/python3.7/site-packages/wagtailvideos/models.py
+++ b/lib/python3.7/site-packages/wagtailvideos/models.py
@@ -47,7 +47,7 @@ class VideoQuality(ChoiceEnum):
class MediaFormats(ChoiceEnum):
webm = 'VP8 and Vorbis in WebM'
mp4 = 'H.264 and MP3 in Mp4'
- ogg = 'Theora and Voris in Ogg'
+ ogg = 'Theora and Vorbis in Ogg'

def get_quality_param(self, quality):
if self is MediaFormats.webm:
--
2.26.2

1 change: 1 addition & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ markdown
pygments
ics
django-auth-ldap
git+https://github.com/neon-jungle/wagtailvideos@3cd93351b67c7d72a0b6b4ac74a62410d5e6bccb
6 changes: 4 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ beautifulsoup4==4.8.2 # via wagtail
certifi==2020.6.20 # via requests
chardet==3.0.4 # via requests
django-auth-ldap==2.2.0 # via -r base.in
django-enumchoicefield==2.0.0 # via wagtailvideos
django-filter==2.3.0 # via wagtail
django-modelcluster==5.0.2 # via wagtail
django-modeltranslation==0.15.1 # via wagtail-modeltranslation
django-taggit==1.3.0 # via wagtail
django-treebeard==4.3.1 # via wagtail
django==3.1 # via -r base.in, django-auth-ldap, django-filter, django-modeltranslation, django-taggit, django-treebeard, djangorestframework, wagtail
django==3.1 # via -r base.in, django-auth-ldap, django-enumchoicefield, django-filter, django-modeltranslation, django-taggit, django-treebeard, djangorestframework, wagtail, wagtailvideos
djangorestframework==3.11.1 # via wagtail
draftjs-exporter==2.1.7 # via wagtail
et-xmlfile==1.0.1 # via openpyxl
Expand Down Expand Up @@ -44,7 +45,8 @@ tatsu==4.4.0 # via ics
unidecode==1.1.1 # via wagtail
urllib3==1.25.10 # via requests
wagtail-modeltranslation==0.10.15 # via -r base.in
wagtail==2.10 # via -r base.in, wagtail-modeltranslation
wagtail==2.10 # via -r base.in, wagtail-modeltranslation, wagtailvideos
git+https://github.com/neon-jungle/wagtailvideos@3cd93351b67c7d72a0b6b4ac74a62410d5e6bccb # via -r base.in
webencodings==0.5.1 # via html5lib
willow==1.4 # via wagtail
xlrd==1.2.0 # via tablib
Expand Down
6 changes: 4 additions & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ decorator==4.4.2 # via ipython, traitlets
django-auth-ldap==2.2.0 # via -r ./test.txt
django-coverage-plugin==1.8.0 # via -r ./test.txt
django-debug-toolbar==2.2 # via -r dev.in
django-enumchoicefield==2.0.0 # via -r ./test.txt, wagtailvideos
django-filter==2.3.0 # via -r ./test.txt, wagtail
django-modelcluster==5.0.2 # via -r ./test.txt, wagtail
django-modeltranslation==0.15.1 # via -r ./test.txt, wagtail-modeltranslation
django-taggit==1.3.0 # via -r ./test.txt, wagtail
django-treebeard==4.3.1 # via -r ./test.txt, wagtail
django==3.1 # via -r ./test.txt, django-auth-ldap, django-debug-toolbar, django-filter, django-modeltranslation, django-taggit, django-treebeard, djangorestframework, wagtail
django==3.1 # via -r ./test.txt, django-auth-ldap, django-debug-toolbar, django-enumchoicefield, django-filter, django-modeltranslation, django-taggit, django-treebeard, djangorestframework, wagtail, wagtailvideos
djangorestframework==3.11.1 # via -r ./test.txt, wagtail
draftjs-exporter==2.1.7 # via -r ./test.txt, wagtail
et-xmlfile==1.0.1 # via -r ./test.txt, openpyxl
Expand Down Expand Up @@ -86,7 +87,8 @@ typed-ast==1.4.1 # via astroid
unidecode==1.1.1 # via -r ./test.txt, wagtail
urllib3==1.25.10 # via -r ./test.txt, requests
wagtail-modeltranslation==0.10.15 # via -r ./test.txt
wagtail==2.10 # via -r ./test.txt, wagtail-modeltranslation
wagtail==2.10 # via -r ./test.txt, wagtail-modeltranslation, wagtailvideos
git+https://github.com/neon-jungle/wagtailvideos@3cd93351b67c7d72a0b6b4ac74a62410d5e6bccb # via -r ./test.txt
wcwidth==0.2.5 # via prompt-toolkit
webencodings==0.5.1 # via -r ./test.txt, html5lib
willow==1.4 # via -r ./test.txt, wagtail
Expand Down
6 changes: 4 additions & 2 deletions requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ beautifulsoup4==4.8.2 # via -r ./base.txt, wagtail
certifi==2020.6.20 # via -r ./base.txt, requests
chardet==3.0.4 # via -r ./base.txt, requests
django-auth-ldap==2.2.0 # via -r ./base.txt
django-enumchoicefield==2.0.0 # via -r ./base.txt, wagtailvideos
django-filter==2.3.0 # via -r ./base.txt, wagtail
django-modelcluster==5.0.2 # via -r ./base.txt, wagtail
django-modeltranslation==0.15.1 # via -r ./base.txt, wagtail-modeltranslation
django-taggit==1.3.0 # via -r ./base.txt, wagtail
django-treebeard==4.3.1 # via -r ./base.txt, wagtail
django==3.1 # via -r ./base.txt, django-auth-ldap, django-filter, django-modeltranslation, django-taggit, django-treebeard, djangorestframework, wagtail
django==3.1 # via -r ./base.txt, django-auth-ldap, django-enumchoicefield, django-filter, django-modeltranslation, django-taggit, django-treebeard, djangorestframework, wagtail, wagtailvideos
djangorestframework==3.11.1 # via -r ./base.txt, wagtail
draftjs-exporter==2.1.7 # via -r ./base.txt, wagtail
et-xmlfile==1.0.1 # via -r ./base.txt, openpyxl
Expand Down Expand Up @@ -44,7 +45,8 @@ tatsu==4.4.0 # via -r ./base.txt, ics
unidecode==1.1.1 # via -r ./base.txt, wagtail
urllib3==1.25.10 # via -r ./base.txt, requests
wagtail-modeltranslation==0.10.15 # via -r ./base.txt
wagtail==2.10 # via -r ./base.txt, wagtail-modeltranslation
wagtail==2.10 # via -r ./base.txt, wagtail-modeltranslation, wagtailvideos
git+https://github.com/neon-jungle/wagtailvideos@3cd93351b67c7d72a0b6b4ac74a62410d5e6bccb # via -r ./base.txt
webencodings==0.5.1 # via -r ./base.txt, html5lib
willow==1.4 # via -r ./base.txt, wagtail
xlrd==1.2.0 # via -r ./base.txt, tablib
Expand Down
6 changes: 4 additions & 2 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ chardet==3.0.4 # via -r ./base.txt, requests
coverage==5.2.1 # via -r test.in, django-coverage-plugin
django-auth-ldap==2.2.0 # via -r ./base.txt
django-coverage-plugin==1.8.0 # via -r test.in
django-enumchoicefield==2.0.0 # via -r ./base.txt, wagtailvideos
django-filter==2.3.0 # via -r ./base.txt, wagtail
django-modelcluster==5.0.2 # via -r ./base.txt, wagtail
django-modeltranslation==0.15.1 # via -r ./base.txt, wagtail-modeltranslation
django-taggit==1.3.0 # via -r ./base.txt, wagtail
django-treebeard==4.3.1 # via -r ./base.txt, wagtail
django==3.1 # via -r ./base.txt, django-auth-ldap, django-filter, django-modeltranslation, django-taggit, django-treebeard, djangorestframework, wagtail
django==3.1 # via -r ./base.txt, django-auth-ldap, django-enumchoicefield, django-filter, django-modeltranslation, django-taggit, django-treebeard, djangorestframework, wagtail, wagtailvideos
djangorestframework==3.11.1 # via -r ./base.txt, wagtail
draftjs-exporter==2.1.7 # via -r ./base.txt, wagtail
et-xmlfile==1.0.1 # via -r ./base.txt, openpyxl
Expand Down Expand Up @@ -60,7 +61,8 @@ toml==0.10.1 # via pytest
unidecode==1.1.1 # via -r ./base.txt, wagtail
urllib3==1.25.10 # via -r ./base.txt, requests
wagtail-modeltranslation==0.10.15 # via -r ./base.txt
wagtail==2.10 # via -r ./base.txt, wagtail-modeltranslation
wagtail==2.10 # via -r ./base.txt, wagtail-modeltranslation, wagtailvideos
git+https://github.com/neon-jungle/wagtailvideos@3cd93351b67c7d72a0b6b4ac74a62410d5e6bccb # via -r ./base.txt
webencodings==0.5.1 # via -r ./base.txt, html5lib
willow==1.4 # via -r ./base.txt, wagtail
xlrd==1.2.0 # via -r ./base.txt, tablib
Expand Down

0 comments on commit a39fa4b

Please sign in to comment.