Example #1
0
class Form(forms.BaseForm):
    templates = forms.CharField(
        'List of additional templates (comma separated)',
        required=False,
    )
    extensions = forms.CharField(
        'List of allowed extensions, default "mp3, ogg" 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_AUDIO_TEMPLATES'] = [
                (item, item)
                for item in split_and_strip(data['templates'])
            ]
        if data['extensions']:
            settings['DJANGOCMS_AUDIO_ALLOWED_EXTENSIONS'] = split_and_strip(data['extensions'])

        return settings
Example #2
0
class Form(forms.BaseForm):
    templates = forms.CharField(
        'List of additional templates (comma separated)',
        required=False,
    )
    terms = forms.CharField(
        'Default Terms',
        required=False,
    )
    show_context = forms.CheckboxField(
        'Show Context',
        required=False,
        initial=False,
    )

    def clean(self):
        data = super(Form, self).clean()

        # prettify
        data['templates'] = ', '.join(split_and_strip(data['templates']))
        return data

    def to_settings(self, data, settings):
        if data['templates']:
            settings['DJANGOCMS_FILE_TEMPLATES'] = [
                (item, item) for item in split_and_strip(data['templates'])
            ]
        if data['terms']:
            settings['DJANGOCMS_FILE_TERMS'] = data['terms']
        if data['show_context']:
            settings['DJANGOCMS_FILE_SHOW_CONTEXT'] = int(data['show_context'])

        return settings
Example #3
0
class Form(forms.BaseForm):
    templates = forms.CharField(
        'List of additional templates (comma separated)',
        required=False,
    )
    api_key = forms.CharField(
        'Google Maps API Key: Warning! This field is deprecated. '
        'Please leave it blank and set an environment variable called DJANGOCMS_GOOGLEMAP_API_KEY instead.'
        'https://developers.google.com/maps/documentation/javascript/get-api-key',
        required=False,
    )

    def clean(self):
        data = super(Form, self).clean()
        # prettify
        data['templates'] = ', '.join(split_and_strip(data['templates']))
        return data

    def to_settings(self, data, settings):
        from aldryn_addons.utils import djsenv as env
        if data['templates']:
            settings['DJANGOCMS_GOOGLEMAP_TEMPLATES'] = [
                (item, item) for item in split_and_strip(data['templates'])
            ]
        # We prefer the environment variables. But fallback to the form field.
        settings['DJANGOCMS_GOOGLEMAP_API_KEY'] = env(
            'DJANGOCMS_GOOGLEMAP_API_KEY',
            env(
                'GOOGLEMAP_API_KEY',
                data['api_key'],
            ))
        return settings
Example #4
0
class Form(forms.BaseForm):
    hide_promo = forms.CheckboxField(
        'Hide Promo Unit', required=False, initial=False
    )
    hide_promo_rollover = forms.CheckboxField(
        'Hide Promo Unit rollover field', required=False, initial=True
    )
    hide_promo_video = forms.CheckboxField(
        'Hide Promo Unit background video', required=False, initial=True
    )
    hide_twitter = forms.CheckboxField(
        'Hide Twitter plugin', required=False, initial=False
    )
    twitter_app_key = forms.CharField(
        'Twitter App Key', required=False
    )
    twitter_app_secret = forms.CharField(
        'Twitter App Secret', required=False
    )
    twitter_oauth_token = forms.CharField(
        'Twitter OAuth Tocken', required=False
    )
    twitter_oauth_secret = forms.CharField(
        'Twitter OAuth Secret', required=False
    )
    hide_counters = forms.CheckboxField(
        'Hide Counters plugin', required=False, initial=False
    )
    hide_rawhtml = forms.CheckboxField(
        'Hide Raw HTML plugin', required=False, initial=False
    )
    hide_gated_content = forms.CheckboxField(
        'Hide Gated Content plugin', required=False, initial=True
    )
    hide_float = forms.CheckboxField(
        'Hide Float plugin', required=False, initial=True
    )
    hide_lightbox = forms.CheckboxField(
        'Hide Lightbox plugin', required=False, initial=True
    )

    def to_settings(self, data, settings):
        settings['COMPONENTS_HIDE_PROMO'] = int(data['hide_promo'])
        settings['COMPONENTS_HIDE_PROMO_ROLLOVER'] = int(data['hide_promo_rollover'])
        settings['COMPONENTS_HIDE_PROMO_VIDEO'] = int(data['hide_promo_video'])
        settings['COMPONENTS_HIDE_TWITTER'] = int(data['hide_twitter'])
        if data['twitter_app_key']:
            settings['TWITTER_APP_KEY'] = data['twitter_app_key']
        if data['twitter_app_secret']:
            settings['TWITTER_APP_SECRET'] = data['twitter_app_secret']
        if data['twitter_oauth_token']:
            settings['TWITTER_OAUTH_TOKEN'] = data['twitter_oauth_token']
        if data['twitter_oauth_secret']:
            settings['TWITTER_OAUTH_SECRET'] = data['twitter_oauth_secret']
        settings['COMPONENTS_HIDE_COUNTERS'] = int(data['hide_counters'])
        settings['COMPONENTS_HIDE_RAWHTML'] = int(data['hide_rawhtml'])
        settings['COMPONENTS_HIDE_GATED_CONTENT'] = int(data['hide_gated_content'])
        settings['COMPONENTS_HIDE_FLOAT'] = int(data['hide_float'])
        settings['COMPONENTS_HIDE_LIGHTBOX'] = int(data['hide_lightbox'])
        return settings
class Form(forms.BaseForm):
    templates = forms.CharField(
        'List of additional templates (comma separated)',
        required=False,
    )
    api_key = forms.CharField(
        'You need to provide a valid Google Maps API key '
        'https://developers.google.com/maps/documentation/javascript/get-api-key',
        required=True,
    )

    def clean(self):
        data = super(Form, self).clean()
        # prettify
        data['templates'] = ', '.join(split_and_strip(data['templates']))
        return data

    def to_settings(self, data, settings):
        if data['templates']:
            settings['DJANGOCMS_GOOGLEMAP_TEMPLATES'] = [
                (item, item) for item in split_and_strip(data['templates'])
            ]
        if data['api_key']:
            settings['DJANGOCMS_GOOGLEMAP_API_KEY'] = data['api_key']

        return settings
Example #6
0
class Form(forms.BaseForm):

    META_SITE_PROTOCOL = forms.SelectField('Site protocol', choices=PROTOCOLS)
    META_SITE_TYPE = forms.SelectField('Site type', choices=OBJECT_TYPES)
    META_SITE_NAME = forms.CharField('Site name', required=False)
    META_IMAGE_URL = forms.CharField('Base image url for OpenGraph',
                                     required=False)
    META_USE_OG_PROPERTIES = forms.CheckboxField(
        'Render the OpenGraph properties', required=False)
    META_USE_TWITTER_PROPERTIES = forms.CheckboxField(
        'Render the Twitter properties', required=False)
    META_USE_GOOGLEPLUS_PROPERTIES = forms.CheckboxField(
        'Render the Google propertie', required=False)

    def to_settings(self, data, settings):
        settings['META_SITE_PROTOCOL'] = data['META_SITE_PROTOCOL']
        settings['META_SITE_TYPE'] = data['META_SITE_TYPE']
        settings['META_SITE_NAME'] = data['META_SITE_NAME']
        settings['META_INCLUDE_KEYWORDS'] = []
        settings['META_DEFAULT_KEYWORDS'] = []
        settings['META_IMAGE_URL'] = data['META_IMAGE_URL']
        settings['META_USE_OG_PROPERTIES'] = data['META_USE_OG_PROPERTIES']
        settings['META_USE_TWITTER_PROPERTIES'] = data[
            'META_USE_TWITTER_PROPERTIES']
        settings['META_USE_GOOGLEPLUS_PROPERTIES'] = data[
            'META_USE_GOOGLEPLUS_PROPERTIES']
        settings['META_USE_TITLE_TAG'] = False
        settings['META_USE_SITES'] = True
        return settings
class Form(forms.BaseForm):
    section_layouts = forms.CharField('Section layouts', required=False)
    slideshow_layouts = forms.CharField('Slideshow layouts', required=False)
    slide_layouts = forms.CharField('Slide layouts', required=False)
    hide_article = forms.CheckboxField('Hide Showcase Article',
                                       required=False,
                                       initial=False)
    hide_slide = forms.CheckboxField('Hide Showcase Slide',
                                     required=False,
                                     initial=False)

    def to_settings(self, data, settings):
        if data['section_layouts']:
            settings['SHOWCASE_SECTION_LAYOUTS'] = tuple(
                l.strip() for l in data['section_layouts'].split(','))
        if data['slideshow_layouts']:
            settings['SHOWCASE_SLIDESHOW_LAYOUTS'] = tuple(
                l.strip() for l in data['slideshow_layouts'].split(','))
        if data['slide_layouts']:
            settings['SHOWCASE_SLIDE_LAYOUTS'] = tuple(
                l.strip() for l in data['slide_layouts'].split(','))
        if data['hide_article']:
            settings['SHOWCASE_HIDE_ARTICLE'] = int(data['hide_article'])
        if data['hide_slide']:
            settings['SHOWCASE_HIDE_SLIDE'] = int(data['hide_slide'])
        return settings
class Form(forms.BaseForm):
    ace_theme = forms.CharField("Custom Editor Theme (i.e. 'ace/theme/solarized_dark')", required=False)
    ace_mode = forms.CharField("Custom Editor Mode (i.e. 'ace/mode/html')", required=False)

    def to_settings(self, data, settings):
        settings['ALDRYN_SNIPPET_ACE_THEME'] = data['ace_theme']
        settings['ALDRYN_SNIPPET_ACE_MODE'] = data['ace_mode']
        return settings
class Form(forms.BaseForm):
    apy_key = forms.CharField('Mandrill API key', required=True)
    template = forms.CharField('default mandrill template', required=False)

    def to_settings(self, data, settings):
        settings['MANDRILL_API_KEY'] = data['apy_key']
        if data['template']:
            settings['MANDRILL_DEFAULT_TEMPLATE'] = data['template']

        return settings
Example #10
0
class Form(forms.BaseForm):

    show_all_recipients = forms.CheckboxField(
        'Show all users as selectable e-mail recipients (not only admins)',
        required=False,
        initial=True)
    enable_simple_forms = forms.CheckboxField('Enable Simple forms',
                                              required=False,
                                              initial=False)
    enable_form_template = forms.CheckboxField('Enable Form template',
                                               required=False,
                                               initial=False)
    enable_custom_css = forms.CheckboxField('Enable Custom CSS classes',
                                            required=False,
                                            initial=False)
    enable_localstorage = forms.CheckboxField('Enable local storage',
                                              required=False,
                                              initial=False)
    enable_api = forms.CheckboxField('Enable API options',
                                     required=False,
                                     initial=False)
    enable_form_id = forms.CheckboxField('Enable Form ID',
                                         required=False,
                                         initial=False)
    default_action_backend = forms.SelectField('Default Action',
                                               ACTIONS,
                                               required=True)
    recaptcha_private_key = forms.CharField('ReCaptcha Private Key',
                                            required=False)
    recaptcha_public_key = forms.CharField('ReCaptcha Public Key',
                                           required=False)

    def to_settings(self, data, settings):
        settings['ALDRYN_FORMS_ENABLE_API'] = True
        settings['ALDRYN_FORMS_SHOW_ALL_RECIPIENTS'] = data[
            'show_all_recipients']
        settings['ALDRYN_FORMS_ENABLE_LOCALSTORAGE'] = data[
            'enable_localstorage']
        settings['ALDRYN_FORMS_ENABLE_SIMPLE_FORMS'] = data[
            'enable_simple_forms']
        settings['ALDRYN_FORMS_ENABLE_FORM_TEMPLATE'] = data[
            'enable_form_template']
        settings['ALDRYN_FORMS_ENABLE_CUSTOM_CSS'] = data['enable_custom_css']
        settings['ALDRYN_FORMS_DEFAULT_ACTION_BACKEND'] = data[
            'default_action_backend']
        settings['ALDRYN_FORMS_ENABLE_API'] = data['enable_api']
        settings['ALDRYN_FORMS_ENABLE_FORM_ID'] = data['enable_form_id']
        if data['recaptcha_private_key']:
            settings['RECAPTCHA_PRIVATE_KEY'] = data['recaptcha_private_key']
        if data['recaptcha_public_key']:
            settings['RECAPTCHA_PUBLIC_KEY'] = data['recaptcha_public_key']
        return settings
class Form(forms.BaseForm):
    templates = forms.CharField(
        'List of additional templates (comma separated)',
        required=False,
    )
    alignment = forms.CharField(
        'List of alignment types, default "left, center, right" (comma separated)',
        required=False,
    )
    ratio = forms.CharField(
        'The ratio used to calculate the missing width or height, default "1.618"',
        required=False,
    )
    nesting = forms.CheckboxField(
        'Allow plugins to be nested inside the picture plugin.',
        required=False,
        initial=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['alignment'], list):
            data['alignment'] = ', '.join(data['alignment'])

        # prettify
        data['templates'] = ', '.join(split_and_strip(data['templates']))
        data['alignment'] = ', '.join(split_and_strip(data['alignment']))
        return data

    def to_settings(self, data, settings):
        if data['templates']:
            settings['DJANGOCMS_PICTURE_TEMPLATES'] = [
                (item, item)
                for item in split_and_strip(data['templates'])
            ]
        if data['alignment']:
            settings['DJANGOCMS_PICTURE_ALIGN'] = [
                (item, item)
                for item in split_and_strip(data['alignment'])
            ]
        if data['ratio']:
            settings['DJANGOCMS_PICTURE_RATIO'] = float(data['ratio'])
        if data['nesting']:
            settings['DJANGOCMS_PICTURE_NESTING'] = data['nesting']

        return settings
class Form(forms.BaseForm):
    plugin_module = forms.CharField('Plugin module name', initial='Generic')
    plugin_name = forms.CharField('Plugin name', initial='Facebook Comments')
    plugin_template = forms.CharField(
        'Plugin Template', initial='djangocms_fbcomments/default.html')
    app_id = forms.CharField('Facebook App ID', required=False)

    def to_settings(self, data, settings):
        settings['DJANGOCMS_FBCOMMENTS_PLUGIN_MODULE'] = data['plugin_module']
        settings['DJANGOCMS_FBCOMMENTS_PLUGIN_NAME'] = data['plugin_name']
        settings['DJANGOCMS_FBCOMMENTS_PLUGIN_TEMPLATE'] = data[
            'plugin_template']
        settings['DJANGOCMS_FBCOMMENTS_APP_ID'] = data['app_id']
        return settings
class Form(forms.BaseForm):
    enable_glyphicons = forms.CheckboxField(
        'Enable Glyphicons',
        required=False,
        initial=True,
        help_text=
        'If you disable this, remember to also update your sass config to not load the font.',
    )
    enable_fontawesome = forms.CheckboxField(
        'Enable Fontawesome',
        required=False,
        initial=True,
        help_text=
        'If you disable this, remember to also update your sass config to not load the font.',
    )

    carousel_styles = forms.CharField(
        'List of additional carousel styles (comma separated)', required=False)

    def to_settings(self, data, settings):
        choices = []
        if data['enable_glyphicons']:
            choices.append(('glyphicons', 'glyphicons', 'Glyphicons'))
        if data['enable_fontawesome']:
            choices.append(('fontawesome', 'fa', 'Fontawesome'))
        settings['ALDRYN_BOOTSTRAP3_ICONSETS'] = choices
        settings['ALDRYN_BOOTSTRAP3_CAROUSEL_STYLES'] = data['carousel_styles']
        return settings
Example #14
0
class Form(forms.BaseForm):
    enable_rest_framework = forms.CheckboxField(
        'Enable Django REST Framework',
        required=False,
        initial=True,
    )

    permissions_policy = forms.CharField(
        'Django REST Framework Permissions Policy',
        required=False,
        initial='AllowAny',
        help_text=(
            'REST Framework Permissions Policies are described at '
            'http://www.django-rest-framework.org/api-guide/permissions/ '))

    def to_settings(self, data, settings):
        enable_rest_framework = data['enable_rest_framework']
        permissions_policy = ('rest_framework.permissions.{}'.format(
            data['permissions_policy']))

        if enable_rest_framework:
            settings['INSTALLED_APPS'].extend([
                'rest_framework',
            ])
            settings['ADDON_URLS'].append('aldryn_django_rest_framework.urls')
            settings['REST_FRAMEWORK'] = {
                'DEFAULT_PERMISSION_CLASSES': (permissions_policy, )
            }
        return settings
Example #15
0
class Form(forms.BaseForm):

    COLOR_SCHEMES = [
        ('light', 'Light'),
        ('dark', 'Dark'),
    ]

    FONTS = [
        ('arial', 'Arial'),
        ('lucida grande', 'Lucida Grande'),
        ('segoe ui', 'Segoe UI'),
        ('tahoma', 'Tahoma'),
        ('trebuchet ms', 'Trebuchet MS'),
        ('verdana', 'Verdana'),
    ]

    app_id = forms.CharField('Facebook App ID', required=False)
    color_scheme = forms.SelectField('Color Scheme', choices=COLOR_SCHEMES)
    font = forms.SelectField('Font', choices=FONTS, required=False)

    def to_settings(self, data, settings):
        settings['FACEBOOK_APP_ID'] = data['app_id']
        settings['FACEBOOK_COLOR_SCHEME'] = data['color_scheme']
        settings['FACEBOOK_FONT'] = data['font']
        return settings
Example #16
0
class Form(forms.BaseForm):
    gallery_styles = forms.CharField(
        'List of additional gallery styles (comma separated)', required=False)

    def to_settings(self, data, settings):
        settings['GALLERY_STYLES'] = data['gallery_styles']
        return settings
class Form(forms.BaseForm):

    disqus_shortname = forms.CharField('Site shortname')

    def to_settings(self, data, settings):
        settings['DISQUS_SHORTNAME'] = data['disqus_shortname']
        return settings
Example #18
0
class Form(forms.BaseForm):
    templates = forms.CharField(
        'List of additional templates (comma separated)',
        required=False,
    )
    """
    The following settings need to be configured on your project separately
    as we don't want to expose them as aldryn configurations yet:
        DJANGOCMS_LINK_INTRANET_HOSTNAME_PATTERN
        DJANGOCMS_LINK_USE_SELECT2
    """
    def clean(self):
        data = super(Form, self).clean()

        # prettify
        data['templates'] = ', '.join(split_and_strip(data['templates']))
        return data

    def to_settings(self, data, settings):
        if data['templates']:
            settings['DJANGOCMS_LINK_TEMPLATES'] = [
                (item, item) for item in split_and_strip(data['templates'])
            ]

        return settings
Example #19
0
class Form(forms.BaseForm):
    style_set = forms.CharField(
        'The "styles definition set" to use in the editor',
        required=False,
    )
    content_css = forms.CharField(
        'List of CSS files to be used to apply style to editor content',
        required=False,
    )

    def clean(self):
        data = super(Form, self).clean()

        if data.get('content_css'):
            files = data['content_css'].split(',')
            data['content_css'] = [item.strip() for item in files if item]
        return data

    def to_settings(self, data, settings):
        # boilerplate must provide /static/js/modules/ckeditor.wysiwyg.js and /static/css/base.css
        CKEDITOR_SETTINGS = {
            'height': 300,
            'language': '{{ language }}',
            'toolbar': 'CMS',
            'skin': 'moono-lisa',
        }

        # This could fail if aldryn-django-cms has not been configured yet.
        boilerplate_name = settings['ALDRYN_BOILERPLATE_NAME']

        if data.get('content_css'):
            CKEDITOR_SETTINGS['contentsCss'] = data['content_css']
        else:
            CKEDITOR_SETTINGS['contentsCss'] = ['/static/css/base.css']

        if data.get('style_set'):
            style_set = data['style_set']
        elif boilerplate_name == 'bootstrap3':
            style_set = '/static/js/addons/ckeditor.wysiwyg.js'
        else:
            style_set = ''

        CKEDITOR_SETTINGS['stylesSet'] = 'default:{}'.format(style_set)

        settings['CKEDITOR_SETTINGS'] = CKEDITOR_SETTINGS
        return settings
Example #20
0
class Form(forms.BaseForm):
    plugin_module = forms.CharField('Plugin module name', initial='Generic')
    plugin_name = forms.CharField('Plugin name', initial='Youtube')
    use_https = forms.CheckboxField(
        'Use HTTPS?', initial=False, required=False,
        help_text='Check this box to use HTTPS for thumbnail URLS')
    api_key = forms.CharField(
        'YouTube Data API key',
        help_text='You can register an app via '
                  'https://developers.google.com/youtube/registering_an_application')

    def to_settings(self, data, settings):
        settings['DJANGOCMS_YOUTUBE_PLUGIN_MODULE'] = data['plugin_module']
        settings['DJANGOCMS_YOUTUBE_PLUGIN_NAME'] = data['plugin_name']
        settings['DJANGOCMS_YOUTUBE_USE_HTTPS'] = data['use_https']
        settings['DJANGOCMS_YOUTUBE_API_KEY'] = data['api_key']
        return settings
class Form(forms.BaseForm):
    paginator_paginate_by = forms.CharField('Paginator: item per page count',
                                            required=False)

    def to_settings(self, data, settings):
        settings['ALDRYN_COMMON_PAGINATOR_PAGINATE_BY'] = data[
            'paginator_paginate_by']
        return settings
Example #22
0
class Form(forms.BaseForm):
    google_ua = forms.CharField("Google UA", required=True)


    def to_settings(self, data, settings):
        settings['INSTALLED_APPS'].extend(['djangocms_privacy_settings'])
        settings['GOOGLE_UA'] = data['google_ua']

        return settings
class Form(forms.BaseForm):
    slick_cdn = forms.CharField('Replaced default slick cdn url',
                                required=False)

    def to_settings(self, data, settings):
        if data['slick_cdn']:
            settings['SLICK_CDN'] = data['slick_cdn']

        return settings
Example #24
0
class Form(forms.BaseForm):

    gridloading_effects = forms.CharField(
        'List of additional grid loading effects (comma separated)',
        required=False)

    def to_settings(self, data, settings):
        settings['GRIDLOADING_EFFECTS'] = data['gridloading_effects']
        return settings
Example #25
0
class Form(forms.BaseForm):
    name = forms.CharField(
        'name of consent cookie that remembers user choice',
        help_text='Default: cookie_consent',
        required=False
    )
    max_age = forms.NumberField(
        'max-age of consent cookie',
        help_text='Default: 1 year',
        required=False
    )
    decline = forms.CharField(
        'decline value',
        help_text='Default: -1',
        required=False
    )
    enabled = forms.CheckboxField(
        'Enabled', required=False, initial=True
    )
    opt_out = forms.CheckboxField(
        'opt-out cookies', required=False, initial=False,
        help_text='opt-out cookies are set until declined opt-in cookies are set only if accepted'

    )
    cache_backend = forms.CharField(
        'Alias for backend to use for caching',
        help_text='Default: default',
        required=False
    )

    def to_settings(self, data, settings):
        if data['name']:
            settings['COOKIE_CONSENT_NAME'] = data['name']
        if data['max_age']:
            settings['COOKIE_CONSENT_MAX_AGE'] = int(data['max_age'])
        if data['decline']:
            settings['COOKIE_CONSENT_DECLINE'] = data['decline']
        settings['COOKIE_CONSENT_ENABLED'] = data['enabled']
        settings['COOKIE_CONSENT_OPT_OUT'] = data['opt_out']
        if data['cache_backend']:
            settings['COOKIE_CONSENT_CACHE_BACKEND'] = data['cache_backend']
        #settings['ADDON_URLS'].append('cookie_consent.urls')

        return settings
class Form(forms.BaseForm):

    default_send_to = forms.CharField(
        "Default send to",
        help_text="E-mail in this field will be default e-mail to send "
                  "staff notifications."
    )

    def to_settings(self, data, settings):
        settings['ALDRYN_JOBS_DEFAULT_SEND_TO'] = data['default_send_to']
        return settings
Example #27
0
class Form(forms.BaseForm):
    plugin_styles = forms.CharField(
        'List of additional plugin styles (comma separated)', required=False)

    def to_settings(self, data, settings):
        choices = []
        for style in data['plugin_styles'].split(','):
            style = style.strip()
            choices.append((style, style))
        settings['ALDRYN_EVENTS_PLUGIN_STYLES'] = choices
        return settings
Example #28
0
class Form(forms.BaseForm):
    style_set = forms.CharField(
        'The "styles definition set" to use in the editor',
        required=False,
    )
    content_css = forms.CharField(
        'List of CSS files to be used to apply style to editor content',
        required=False,
    )

    def clean(self):
        data = super(Form, self).clean()

        if data.get('content_css'):
            files = data['content_css'].split(',')
            data['content_css'] = [item.strip() for item in files if item]
        return data

    def to_settings(self, data, settings):
        CKEDITOR_SETTINGS = {
            'height': 300,
            'language': '{{ language }}',
            'toolbar': 'CMS',
            'skin': 'moono-lisa',
        }

        if data.get('content_css'):
            CKEDITOR_SETTINGS['contentsCss'] = data['content_css']
        else:
            CKEDITOR_SETTINGS['contentsCss'] = ['/static/css/base.css']

        if data.get('style_set'):
            style_set = data['style_set']
        else:
            style_set = ''

        CKEDITOR_SETTINGS['stylesSet'] = 'default:{}'.format(style_set)

        settings['CKEDITOR_SETTINGS'] = CKEDITOR_SETTINGS
        return settings
Example #29
0
class Form(forms.BaseForm):

    META_SITE_PROTOCOL = forms.SelectField(
        'Site protocol',
        choices=PROTOCOLS,
    )
    META_SITE_TYPE = forms.SelectField('Site type',
                                       choices=OBJECT_TYPES,
                                       required=False)
    META_SITE_NAME = forms.CharField('Site name', required=False)
    META_USE_OG_PROPERTIES = forms.CheckboxField(
        'Render the OpenGraph properties', required=False)
    META_USE_TWITTER_PROPERTIES = forms.CheckboxField(
        'Render the Twitter properties', required=False)
    META_USE_GOOGLEPLUS_PROPERTIES = forms.CheckboxField(
        'Render the Google properties', required=False)
    PAGE_META_DESCRIPTION_LENGTH = forms.CharField(
        'Max description field length (default: 320)', required=False)
    PAGE_META_TWITTER_DESCRIPTION_LENGTH = forms.CharField(
        'Max twitter description field length (default: 280)', required=False)

    def to_settings(self, data, settings):
        settings['META_SITE_PROTOCOL'] = data['META_SITE_PROTOCOL']
        settings['META_SITE_TYPE'] = data['META_SITE_TYPE']
        settings['META_SITE_NAME'] = data['META_SITE_NAME']
        settings['META_INCLUDE_KEYWORDS'] = []
        settings['META_DEFAULT_KEYWORDS'] = []
        settings['META_USE_OG_PROPERTIES'] = data['META_USE_OG_PROPERTIES']
        settings['META_USE_TWITTER_PROPERTIES'] = data[
            'META_USE_TWITTER_PROPERTIES']
        settings['META_USE_GOOGLEPLUS_PROPERTIES'] = data[
            'META_USE_GOOGLEPLUS_PROPERTIES']
        settings['PAGE_META_TWITTER_DESCRIPTION_LENGTH'] = data[
            'PAGE_META_TWITTER_DESCRIPTION_LENGTH']
        settings['PAGE_META_DESCRIPTION_LENGTH'] = data[
            'PAGE_META_DESCRIPTION_LENGTH']
        settings['META_USE_TITLE_TAG'] = False
        settings['META_USE_SITES'] = True
        return settings
class Form(forms.BaseForm):

    google_tag_manager_id = forms.CharField(
        "Google Tag Manager ID",
        required=False,
        initial='',
        help_text="Provide the Google Tag Manager ID for this site.")

    def to_settings(self, cleaned_data, settings_dict):
        if cleaned_data['google_tag_manager_id']:
            settings_dict['GOOGLE_TAG_MANAGER_ID'] = cleaned_data[
                'google_tag_manager_id']

        return settings_dict