install djangocms-video 2.0.4

This commit is contained in:
2018-03-15 11:21:40 +00:00
parent ea1b97a6dd
commit 91f84ae022
5 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
{
"installed-apps": [
"djangocms_video"
],
"package-name": "djangocms-video"
}

View File

@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
from aldryn_client import forms
def split_and_strip(string):
return [item.strip() for item in string.split(',') if item]
class Form(forms.BaseForm):
templates = forms.CharField(
'List of additional templates (comma separated)',
required=False,
)
extensions = forms.CharField(
'List of allowed extensions, default "mp4, webm, ogv" when empty (comma separated)',
required=False,
)
def clean(self):
data = super(Form, self).clean()
# older versions of this addon had a bug where the values would be
# saved to settings.json as a list instead of a string.
if isinstance(data['templates'], list):
data['templates'] = ', '.join(data['templates'])
if isinstance(data['extensions'], list):
data['extensions'] = ', '.join(data['extensions'])
# prettify
data['templates'] = ', '.join(split_and_strip(data['templates']))
data['extensions'] = ', '.join(split_and_strip(data['extensions']))
return data
def to_settings(self, data, settings):
if data['templates']:
settings['DJANGOCMS_VIDEO_TEMPLATES'] = [
(item, item)
for item in split_and_strip(data['templates'])
]
if data['extensions']:
settings['DJANGOCMS_VIDEO_ALLOWED_EXTENSIONS'] = split_and_strip(data['extensions'])
return settings

View File

@@ -0,0 +1,4 @@
{
"extensions": null,
"templates": null
}