mirror of
https://github.com/Hopiu/django-fobi.git
synced 2026-05-11 06:13:10 +00:00
content_video pep8
This commit is contained in:
parent
47d050f74c
commit
e2ba8d60e7
7 changed files with 65 additions and 50 deletions
|
|
@ -1,9 +1,10 @@
|
|||
__title__ = 'fobi.contrib.plugins.form_elements.content.content_video'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = 'Copyright (c) 2014 Artur Barseghyan'
|
||||
__copyright__ = '2014-2016 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('default_app_config', 'UID',)
|
||||
|
||||
default_app_config = 'fobi.contrib.plugins.form_elements.content.content_video.apps.Config'
|
||||
default_app_config = 'fobi.contrib.plugins.form_elements.content.' \
|
||||
'content_video.apps.Config'
|
||||
|
||||
UID = "content_video"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
__title__ = 'fobi.contrib.plugins.form_elements.content.content_video.apps'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = 'Copyright (c) 2014 Artur Barseghyan'
|
||||
__copyright__ = '2014-2016 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('Config',)
|
||||
|
||||
|
|
@ -8,6 +8,8 @@ try:
|
|||
from django.apps import AppConfig
|
||||
|
||||
class Config(AppConfig):
|
||||
"""Config."""
|
||||
|
||||
name = 'fobi.contrib.plugins.form_elements.content.content_video'
|
||||
label = 'fobi_contrib_plugins_form_elements_content_content_video'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
__title__ = 'fobi.contrib.plugins.form_elements.content.content_video.conf'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = 'Copyright (c) 2014 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('get_setting',)
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from . import defaults
|
||||
|
||||
__title__ = 'fobi.contrib.plugins.form_elements.content.content_video.conf'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2016 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('get_setting',)
|
||||
|
||||
|
||||
def get_setting(setting, override=None):
|
||||
"""
|
||||
"""Get setting.
|
||||
|
||||
Get a setting from
|
||||
``fobi.contrib.plugins.form_elements.content.content_video`` conf module,
|
||||
falling back to the default.
|
||||
|
|
@ -17,12 +19,16 @@ def get_setting(setting, override=None):
|
|||
If override is not None, it will be used instead of the setting.
|
||||
|
||||
:param setting: String with setting name
|
||||
:param override: Value to use when no setting is available. Defaults to None.
|
||||
:param override: Value to use when no setting is available. Defaults to
|
||||
None.
|
||||
:return: Setting value.
|
||||
"""
|
||||
if override is not None:
|
||||
return override
|
||||
if hasattr(settings, 'FOBI_PLUGIN_CONTENT_VIDEO_{0}'.format(setting)):
|
||||
return getattr(settings, 'FOBI_PLUGIN_CONTENT_VIDEO_{0}'.format(setting))
|
||||
return getattr(
|
||||
settings,
|
||||
'FOBI_PLUGIN_CONTENT_VIDEO_{0}'.format(setting)
|
||||
)
|
||||
else:
|
||||
return getattr(defaults, setting)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
__title__ = 'fobi.contrib.plugins.form_elements.content.content_video.defaults'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = 'Copyright (c) 2014 Artur Barseghyan'
|
||||
__copyright__ = '2014-2016 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = (
|
||||
'SIZES', 'SIZE_400x300', 'SIZE_500x400', 'DEFAULT_SIZE',
|
||||
|
|
|
|||
|
|
@ -1,9 +1,3 @@
|
|||
__title__ = 'fobi.contrib.plugins.form_elements.content.content_video.fobi_form_elements'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = 'Copyright (c) 2014 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('ContentVideoPlugin',)
|
||||
|
||||
from uuid import uuid4
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
|
@ -17,31 +11,37 @@ from fobi.base import FormElementPlugin, form_element_plugin_registry
|
|||
from . import UID
|
||||
from .forms import ContentVideoForm
|
||||
|
||||
__title__ = 'fobi.contrib.plugins.form_elements.content.content_video.' \
|
||||
'fobi_form_elements'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2016 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('ContentVideoPlugin',)
|
||||
|
||||
|
||||
class ContentVideoPlugin(FormElementPlugin):
|
||||
"""
|
||||
Content video plugin.
|
||||
"""
|
||||
"""Content video plugin."""
|
||||
|
||||
uid = UID
|
||||
name = _("Content video")
|
||||
group = _("Content")
|
||||
form = ContentVideoForm
|
||||
|
||||
def post_processor(self):
|
||||
"""
|
||||
"""Process plugin data.
|
||||
|
||||
Always the same.
|
||||
"""
|
||||
self.data.name = "{0}_{1}".format(self.uid, uuid4())
|
||||
|
||||
def get_form_field_instances(self, request=None):
|
||||
"""
|
||||
Get form field instances.
|
||||
"""
|
||||
"""Get form field instances."""
|
||||
width, height = self.data.size.split('x')
|
||||
|
||||
kwargs = {
|
||||
'initial': '<div class="video-wrapper">{0}</div>'.format(
|
||||
render_video(self.data.url, width, height)
|
||||
),
|
||||
),
|
||||
'required': False,
|
||||
'label': '',
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,3 @@
|
|||
__title__ = 'fobi.contrib.plugins.form_elements.content.content_video.forms'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = 'Copyright (c) 2014 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('ContentVideoForm',)
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
|
@ -11,12 +5,18 @@ from fobi.base import BasePluginForm, get_theme
|
|||
|
||||
from .settings import DEFAULT_SIZE, SIZES
|
||||
|
||||
__title__ = 'fobi.contrib.plugins.form_elements.content.content_video.forms'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2016 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('ContentVideoForm',)
|
||||
|
||||
theme = get_theme(request=None, as_instance=True)
|
||||
|
||||
|
||||
class ContentVideoForm(forms.Form, BasePluginForm):
|
||||
"""
|
||||
Form for ``ContentVideoPlugin``.
|
||||
"""
|
||||
"""Form for ``ContentVideoPlugin``."""
|
||||
|
||||
plugin_data_fields = [
|
||||
("title", ""),
|
||||
("url", ""),
|
||||
|
|
@ -24,19 +24,25 @@ class ContentVideoForm(forms.Form, BasePluginForm):
|
|||
]
|
||||
|
||||
title = forms.CharField(
|
||||
label = _("Title"),
|
||||
required = True,
|
||||
widget = forms.widgets.TextInput(attrs={'class': theme.form_element_html_class})
|
||||
label=_("Title"),
|
||||
required=True,
|
||||
widget=forms.widgets.TextInput(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
)
|
||||
url = forms.CharField(
|
||||
label = _("URL"),
|
||||
required = True,
|
||||
widget = forms.widgets.TextInput(attrs={'class': theme.form_element_html_class})
|
||||
label=_("URL"),
|
||||
required=True,
|
||||
widget=forms.widgets.TextInput(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
)
|
||||
size = forms.ChoiceField(
|
||||
label = _("Size"),
|
||||
required = False,
|
||||
initial = DEFAULT_SIZE,
|
||||
choices = SIZES,
|
||||
widget = forms.widgets.Select(attrs={'class': theme.form_element_html_class})
|
||||
label=_("Size"),
|
||||
required=False,
|
||||
initial=DEFAULT_SIZE,
|
||||
choices=SIZES,
|
||||
widget=forms.widgets.Select(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
from .conf import get_setting
|
||||
|
||||
__title__ = 'fobi.contrib.plugins.form_elements.content.content_video.settings'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = 'Copyright (c) 2014 Artur Barseghyan'
|
||||
__copyright__ = '2014-2016 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = (
|
||||
'SIZES', 'SIZE_400x300', 'SIZE_500x400', 'DEFAULT_SIZE',
|
||||
)
|
||||
|
||||
from .conf import get_setting
|
||||
|
||||
SIZE_400x300 = get_setting('SIZE_400x300')
|
||||
SIZE_500x400 = get_setting('SIZE_500x400')
|
||||
DEFAULT_SIZE = get_setting('DEFAULT_SIZE')
|
||||
|
|
|
|||
Loading…
Reference in a new issue