Exemplo n.º 1
0
class CommentsForm(ListForm):
    template = 'admin/box-form.html'
    id = 'settings-form'
    css_class = 'form'
    submit_text = None
    
    event = events.Admin.Settings.CommentsForm
    
    fields = [
       RadioButtonList('comments_engine',
            label_text=N_('Comment Engine'),
            options=comments_enable_disable,
            validator=comments_enable_validator,
        ),
        ListFieldSet('builtin', suppress_label=True, legend=N_('Built-in Comments:'), css_classes=['details_fieldset'], children=[

            CheckBox('req_comment_approval',
                label_text=N_('Moderation'),
                help_text=N_('Require comments to be approved by an admin'),
                css_classes=['checkbox-inline-help'],
                validator=Bool(if_missing='')),
            TextField('akismet_key', label_text=N_('Akismet Key')),
            TextField('akismet_url', label_text=N_('Akismet URL')),
            TextArea('vulgarity_filtered_words', label_text=N_('Filtered Words'),
                attrs=dict(rows=3, cols=15),
                help_text=N_('Enter words to be filtered separated by a comma.')),
        ]),
        ListFieldSet('facebook', suppress_label=True, legend=N_('Facebook Comments:'), css_classes=['details_fieldset'], children=[
            TextField('facebook_appid', label_text=N_('Application ID'),
                help_text=N_('See: https://developers.facebook.com/apps')),
        ]),
        SubmitButton('save', default=N_('Save'), css_classes=['btn', 'btn-save', 'blue', 'f-rgt']),
    ]
Exemplo n.º 2
0
class APIForm(ListForm):
    template = 'admin/box-form.html'
    id = 'settings-form'
    css_class = 'form'
    submit_text = None

    event = events.Admin.Settings.APIForm

    fields = [
        boolean_radiobuttonlist(
            'api_secret_key_required',
            label_text=N_('Require a key to access the API')),
        ListFieldSet('key',
                     suppress_label=True,
                     legend=N_('API Key:'),
                     css_classes=['details_fieldset'],
                     children=[
                         TextField('api_secret_key',
                                   label_text=N_('Access Key')),
                     ]),
        ListFieldSet('prefs',
                     suppress_label=True,
                     legend=N_('API Settings:'),
                     css_classes=['details_fieldset'],
                     children=[
                         TextField('api_media_max_results',
                                   label_text=N_('Max media results')),
                         TextField('api_tree_max_depth',
                                   label_text=N_('Max tree depth')),
                     ]),
        SubmitButton('save',
                     default='Save',
                     css_classes=['btn', 'btn-save', 'blue', 'f-rgt']),
    ]
Exemplo n.º 3
0
class UserForm(ListForm):
    template = 'admin/box-form.html'
    id = 'user-form'
    css_class = 'form'
    submit_text = None
    show_children_errors = True
    _name = 'user-form' # TODO: Figure out why this is required??
    
    event = events.Admin.UserForm
    
    fields = [
        TextField('display_name', label_text=N_('Display Name'), validator=TextField.validator(not_empty=True), maxlength=255),
        TextField('email_address', label_text=N_('Email Address'), validator=email_validator(not_empty=True), maxlength=255),
        ListFieldSet('login_details', suppress_label=True, legend=N_('Login Details:'),
            css_classes=['details_fieldset'],
            validator = Schema(chained_validators=[
                FieldsMatch('password', 'confirm_password',
                messages={'invalidNoMatch': N_("Passwords do not match"),})]
            ),
            children=[
                CheckBoxList('groups', label_text=N_('Groups'), 
                    options=lambda: Group.custom_groups(Group.group_id, Group.display_name).all()),
                TextField('user_name', label_text=N_('Username'), maxlength=16, validator=All(PlainText(), UniqueUsername(not_empty=True))),
                PasswordField('password', label_text=N_('Password'), validators=NotEmpty, maxlength=80, attrs={'autocomplete': 'off'}),
                PasswordField('confirm_password', label_text=N_('Confirm password'), validators=NotEmpty, maxlength=80, attrs={'autocomplete': 'off'}),
            ]
        ),
        SubmitButton('save', default=N_('Save'), named_button=True, css_classes=['btn', 'btn-save', 'blue', 'f-rgt']),
        SubmitButton('delete', default=N_('Delete'), named_button=True, css_classes=['btn', 'btn-delete']),
    ]
Exemplo n.º 4
0
class NotificationsForm(ListForm):
    template = 'admin/box-form.html'
    id = 'settings-form'
    css_class = 'form'
    submit_text = None

    event = events.Admin.Settings.NotificationsForm

    fields = [
        ListFieldSet('email',
                     suppress_label=True,
                     legend=N_('Email Notifications:'),
                     css_classes=['details_fieldset'],
                     children=[
                         TextField('email_media_uploaded',
                                   validator=email_list_validator,
                                   label_text=N_('Media Uploaded'),
                                   maxlength=255),
                         TextField('email_comment_posted',
                                   validator=email_list_validator,
                                   label_text=N_('Comment Posted'),
                                   maxlength=255),
                         TextField('email_support_requests',
                                   validator=email_list_validator,
                                   label_text=N_('Support Requested'),
                                   maxlength=255),
                         TextField('email_send_from',
                                   validator=email_validator,
                                   label_text=N_('Send Emails From'),
                                   maxlength=255),
                     ]),
        SubmitButton('save',
                     default=N_('Save'),
                     css_classes=['btn', 'btn-save', 'blue', 'f-rgt']),
    ]
Exemplo n.º 5
0
class UploadForm(ListForm):
    template = 'admin/box-form.html'
    id = 'settings-form'
    css_class = 'form'
    submit_text = None

    event = events.Admin.Settings.UploadForm

    fields = [
        TextField('max_upload_size',
                  label_text=N_('Max. allowed upload file size in megabytes'),
                  validator=MegaByteValidator(not_empty=True, min=0)),
        ListFieldSet('legal_wording',
                     suppress_label=True,
                     legend=N_('Legal Wording:'),
                     css_classes=['details_fieldset'],
                     children=[
                         XHTMLTextArea('wording_user_uploads',
                                       label_text=N_('User Uploads'),
                                       attrs=dict(rows=15, cols=25)),
                     ]),
        SubmitButton('save',
                     default=N_('Save'),
                     css_classes=['btn', 'btn-save', 'blue', 'f-rgt']),
    ]
Exemplo n.º 6
0
class AdvertisingForm(ListForm):
    template = 'admin/box-form.html'
    id = 'settings-form'
    css_class = 'form'
    submit_text = None

    event = events.Admin.Settings.AdvertisingForm

    fields = [
        ListFieldSet(
            'advanced',
            suppress_label=True,
            legend='',
            css_classes=['details_fieldset'],
            children=[
                TextArea('advertising_banner_html',
                         label_text=N_('Banner HTML'),
                         attrs=dict(rows=15, cols=25)),
                TextArea('advertising_sidebar_html',
                         label_text=N_('Sidebar HTML'),
                         attrs=dict(rows=15, cols=25)),
            ],
        ),
        SubmitButton('save',
                     default=N_('Save'),
                     css_classes=['btn', 'btn-save', 'blue', 'f-rgt']),
    ]
Exemplo n.º 7
0
class GeneralForm(ListForm):
    template = 'admin/box-form.html'
    id = 'settings-form'
    css_class = 'form'
    submit_text = None
    
    event = events.Admin.Settings.GeneralForm
    
    fields = [
        ListFieldSet('general', suppress_label=True, legend=N_('General Settings:'), css_classes=['details_fieldset'], children=[
            TextField('general_site_name', maxlength=255,
                label_text=N_('Site Name')),
            SingleSelectField('general_site_title_display_order',
                label_text=N_('Display Site Name'),
                options=title_options,
            ),
            SingleSelectField('primary_language',
                label_text=N_('Default Language'), # TODO v0.9.1: Change to 'Primary Language'
                options=languages,
            ),
            SingleSelectField('featured_category',
                label_text=N_('Featured Category'),
                options=category_options,
                validator=Int(),
            ),
            RadioButtonList('rich_text_editor',
                label_text=N_('Rich Text Editing'),
                options=rich_text_editors,
                validator=rich_text_editors_validator,
            ),
        ]),
        SubmitButton('save', default=N_('Save'), css_classes=['btn', 'btn-save', 'blue', 'f-rgt']),
    ]
Exemplo n.º 8
0
class PopularityForm(ListForm):
    template = 'admin/box-form.html'
    id = 'settings-form'
    css_class = 'form'
    submit_text = None

    event = events.Admin.Settings.PopularityForm

    fields = [
        ListFieldSet('popularity',
                     suppress_label=True,
                     css_classes=['details_fieldset'],
                     legend=N_('Popularity Algorithm Variables:'),
                     children=[
                         TextField('popularity_decay_exponent',
                                   validator=Int(not_empty=True, min=1),
                                   label_text=N_('Decay Exponent')),
                         TextField('popularity_decay_lifetime',
                                   validator=Int(not_empty=True, min=1),
                                   label_text=N_('Decay Lifetime')),
                     ]),
        SubmitButton('save',
                     default=N_('Save'),
                     css_classes=['btn', 'btn-save', 'blue', 'f-rgt']),
    ]
Exemplo n.º 9
0
class LocalFileStorageForm(StorageForm):
    event = events.Admin.Storage.LocalFileStorageForm

    fields = StorageForm.fields + [
        ListFieldSet('specifics',
            suppress_label=True,
            legend=N_('Options specific to Local File Storage:'),
            children=[
                TextField('path',
                    label_text=N_('Path to store files under'),
                    help_text=N_('Defaults to the "data_dir" from your INI file.'),
                ),
                TextField('rtmp_server_uri',
                    label_text=N_('RTMP Server URL'),
                    help_text=N_('Files must be accessible under the same name as they are stored with locally.'),
                ),
            ],
        )
    ] + StorageForm.buttons


    def display(self, value, engine, **kwargs):
        """Display the form with default values from the given StorageEngine.

        If the value dict is not fully populated, populate any missing entries
        with the values from the given StorageEngine's
        :attr:`_data <mediadrop.lib.storage.StorageEngine._data>` dict.

        :param value: A (sparse) dict of values to populate the form with.
        :type value: dict
        :param engine: An instance of the storage engine implementation.
        :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass

        """
        specifics = value.setdefault('specifics', {})
        specifics.setdefault('path', engine._data.get('path', None))
        specifics.setdefault('rtmp_server_uri', engine._data.get('rtmp_server_uri', None))
        return StorageForm.display(self, value, engine, **kwargs)

    def save_engine_params(self, engine, **kwargs):
        """Map validated field values to engine data.

        Since form widgets may be nested or named differently than the keys
        in the :attr:`mediadrop.lib.storage.StorageEngine._data` dict, it is
        necessary to manually map field values to the data dictionary.

        :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass
        :param engine: An instance of the storage engine implementation.
        :param \*\*kwargs: Validated and filtered form values.
        :raises formencode.Invalid: If some post-validation error is detected
            in the user input. This will trigger the same error handling
            behaviour as with the @validate decorator.

        """
        StorageForm.save_engine_params(self, engine, **kwargs)
        specifics = kwargs['specifics']
        engine._data['path'] = specifics['path'] or None
        engine._data['rtmp_server_uri'] = specifics['rtmp_server_uri'] or None
Exemplo n.º 10
0
class SiteMapsForm(ListForm):
    template = 'admin/box-form.html'
    id = 'settings-form'
    css_class = 'form'
    submit_text = None

    event = events.Admin.Settings.SiteMapsForm

    fields = [
        ListFieldSet('rss',
                     suppress_label=True,
                     legend='',
                     css_classes=['details_fieldset'],
                     children=[
                         CheckBox('sitemaps_display',
                                  css_classes=['checkbox-left'],
                                  label_text=N_('Site Maps'),
                                  validator=Bool(if_missing='')),
                         CheckBox('rss_display',
                                  css_classes=['checkbox-left'],
                                  label_text=N_('RSS Feeds'),
                                  validator=Bool(if_missing='')),
                     ]),
        ListFieldSet(
            'feeds',
            suppress_label=True,
            css_classes=['details_fieldset'],
            legend=N_('RSS Feed Defaults:'),
            children=[
                TextField(
                    u'default_feed_results',
                    validator=Int(not_empty=True, min=1, if_missing=30),
                    label_text=N_(u'number of items'),
                    help_text=N_(
                        u'The number of items in the feed can be overriden per request '
                        U'if you add "?limit=X" to the feed URL. If the "limit" parameter '
                        u'is absent, the default above is used.'),
                ),
            ]),
        SubmitButton('save',
                     default=N_('Save'),
                     css_classes=['btn', 'btn-save', 'blue', 'f-rgt']),
    ]
Exemplo n.º 11
0
class PlayerPrefsForm(ListForm):
    template = 'admin/box-form.html'
    id = 'player-form'
    css_class = 'form playerform'
    submit_text = None
    show_children_errors = True
    _name = 'player-form'  # TODO: Figure out why this is required??
    params = ['player']

    fields = [
        ListFieldSet(
            'general',
            legend=N_('General Options:'),
            suppress_label=True,
            children=[
                TextField(
                    'display_name',
                    label_text=N_('Display Name'),
                    validator=TextField.validator(not_empty=True),
                    maxlength=100,
                ),
            ],
        ),
    ]

    buttons = [
        SubmitButton(
            'save',
            default=N_('Save'),
            css_classes=['btn', 'btn-save', 'blue', 'f-rgt'],
        ),
    ]

    def display(self, value, player, **kwargs):
        """Display the form with default values from the given player.

        If the value dict is not fully populated, populate any missing entries
        with the values from the given player's
        :attr:`_data <mediadrop.model.player.PlayerPrefs._data>` dict.

        :param value: A (sparse) dict of values to populate the form with.
        :type value: dict
        :param player: The player prefs mapped object to retrieve the default
            values from.
        :type player: :class:`mediadrop.model.player.PlayerPrefs` subclass

        """
        return ListForm.display(self, value, **kwargs)

    def save_data(self, player, **kwargs):
        """Map validated field values to `PlayerPrefs.data`.
Exemplo n.º 12
0
class AnalyticsForm(ListForm):
    template = 'admin/box-form.html'
    id = 'settings-form'
    css_class = 'form'
    submit_text = None
    
    event = events.Admin.Settings.AnalyticsForm
    
    fields = [
        ListFieldSet('google', suppress_label=True, legend=N_('Google Analytics Details:'), css_classes=['details_fieldset'], children=[
            TextField('google_analytics_uacct', maxlength=255, label_text=N_('Tracking Code')),
        ]),
        SubmitButton('save', default=N_('Save'), css_classes=['btn', 'btn-save', 'blue', 'f-rgt']),
    ]
Exemplo n.º 13
0
class RemoteURLStorageForm(StorageForm):
    event = events.Admin.Storage.RemoteURLStorageForm

    fields = StorageForm.fields + [
        ListFieldSet(
            'rtmp',
            legend=N_('RTMP Servers:'),
            suppress_label=True,
            children=[
                # FIXME: Display errors from the RTMPURLValidator
                FormFieldRepeater(
                    'known_servers',
                    widget=TextField(
                        css_classes=['textfield rtmp-server-uri'],
                        validator=RTMPURLValidator(),
                    ),
                    suppress_label=True,
                    repetitions=1,
                ),
            ],
        )
    ] + StorageForm.buttons

    javascript = [rtmp_server_js]

    def display(self, value, engine, **kwargs):
        """Display the form with default values from the given StorageEngine.

        If the value dict is not fully populated, populate any missing entries
        with the values from the given StorageEngine's
        :attr:`_data <mediadrop.lib.storage.StorageEngine._data>` dict.

        :param value: A (sparse) dict of values to populate the form with.
        :type value: dict
        :param engine: An instance of the storage engine implementation.
        :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass

        """
        rtmp = value.setdefault('rtmp', {})
        rtmp.setdefault('known_servers',
                        engine._data.get('rtmp_server_uris', ()))
        return StorageForm.display(self, value, engine, **kwargs)

    def save_engine_params(self, engine, **kwargs):
        """Map validated field values to engine data.

        Since form widgets may be nested or named differently than the keys
        in the :attr:`mediadrop.lib.storage.StorageEngine._data` dict, it is
        necessary to manually map field values to the data dictionary.

        :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass
        :param engine: An instance of the storage engine implementation.
        :param \*\*kwargs: Validated and filtered form values.
        :raises formencode.Invalid: If some post-validation error is detected
            in the user input. This will trigger the same error handling
            behaviour as with the @validate decorator.

        """
        StorageForm.save_engine_params(self, engine, **kwargs)
        rtmp = kwargs.get('rtmp', {})
        rtmp_servers = rtmp.get('known_servers', ())
        engine._data['rtmp_server_uris'] = [x for x in rtmp_servers if x]
Exemplo n.º 14
0
class PodcastForm(ListForm):
    template = 'admin/box-form.html'
    id = 'podcast-form'
    css_class = 'form'
    submit_text = None

    event = events.Admin.PodcastForm

    # required to support multiple named buttons to differentiate between Save & Delete?
    _name = 'vf'

    explicit_options = lambda: (
        ('no', ''),
        ('yes', _('Parental Advisory')),
        ('clean', _('Clean')),
    )
    category_options = [
        'Arts',
        'Arts > Design',
        'Arts > Fashion & Beauty',
        'Arts > Food',
        'Arts > Literature',
        'Arts > Performing Arts',
        'Arts > Visual Arts',
        'Business',
        'Business > Business News',
        'Business > Careers',
        'Business > Investing',
        'Business > Management & Marketing',
        'Business > Shopping',
        'Comedy',
        'Education',
        'Education > Education Technology',
        'Education > Higher Education',
        'Education > K-12',
        'Education > Language Courses',
        'Education > Training',
        'Games & Hobbies',
        'Games & Hobbies > Automotive',
        'Games & Hobbies > Aviation',
        'Games & Hobbies > Hobbies',
        'Games & Hobbies > Other Games',
        'Games & Hobbies > Video Games',
        'Government & Organizations',
        'Government & Organizations > Local',
        'Government & Organizations > National',
        'Government & Organizations > Non-Profit',
        'Government & Organizations > Regional',
        'Health',
        'Health > Alternative Health',
        'Health > Fitness & Nutrition',
        'Health > Self-Help',
        'Health > Sexuality',
        'Kids & Family',
        'Music',
        'News & Politics',
        'Religion & Spirituality',
        'Religion & Spirituality > Buddhism',
        'Religion & Spirituality > Christianity',
        'Religion & Spirituality > Hinduism',
        'Religion & Spirituality > Islam',
        'Religion & Spirituality > Judaism',
        'Religion & Spirituality > Other',
        'Religion & Spirituality > Spirituality',
        'Science & Medicine',
        'Science & Medicine > Medicine',
        'Science & Medicine > Natural Sciences',
        'Science & Medicine > Social Sciences',
        'Society & Culture',
        'Society & Culture > History',
        'Society & Culture > Personal Journals',
        'Society & Culture > Philosophy',
        'Society & Culture > Places & Travel',
        'Sports & Recreation',
        'Sports & Recreation > Amateur',
        'Sports & Recreation > College & High School',
        'Sports & Recreation > Outdoor',
        'Sports & Recreation > Professional',
        'Technology',
        'Technology > Gadgets',
        'Technology > Tech News',
        'Technology > Podcasting',
        'Technology > Software How-To',
        'TV & Film',
    ]

    fields = [
        TextField('slug',
                  label_text=N_('Permalink'),
                  validator=NotEmpty,
                  maxlength=50),
        TextField('title',
                  label_text=N_('Title'),
                  validator=TextField.validator(not_empty=True),
                  maxlength=50),
        TextField('subtitle', label_text=N_('Subtitle'), maxlength=255),
        TextField('author_name',
                  label_text=N_('Author Name'),
                  validator=TextField.validator(not_empty=True),
                  maxlength=50),
        TextField('author_email',
                  label_text=N_('Author Email'),
                  validator=email_validator(not_empty=True),
                  maxlength=50),
        XHTMLTextArea('description',
                      label_text=N_('Description'),
                      attrs=dict(rows=5, cols=25)),
        ListFieldSet('details',
                     suppress_label=True,
                     legend=N_('Podcast Details:'),
                     css_classes=['details_fieldset'],
                     children=[
                         SingleSelectField('explicit',
                                           label_text=N_('Explicit?'),
                                           options=explicit_options),
                         SingleSelectField('category',
                                           label_text=N_('Category'),
                                           options=category_options),
                         TextField('copyright',
                                   label_text=N_('Copyright'),
                                   maxlength=50),
                     ]),
        ListFieldSet('feed',
                     suppress_label=True,
                     legend=N_('Advanced Options:'),
                     css_classes=['details_fieldset'],
                     template='/admin/podcasts/feed_fieldset.html',
                     children=[
                         TextField('feed_url',
                                   maxlength=50,
                                   label_text=N_('Your Feed URL'),
                                   attrs={'readonly': True}),
                         TextField('itunes_url',
                                   validator=URL,
                                   label_text=N_('iTunes URL'),
                                   maxlength=80),
                         TextField('feedburner_url',
                                   validator=URL,
                                   label_text=N_('Feedburner URL'),
                                   maxlength=80),
                     ]),
        SubmitButton('save',
                     default=N_('Save'),
                     named_button=True,
                     css_classes=['btn', 'blue', 'f-rgt']),
        SubmitButton('delete',
                     default=N_('Delete'),
                     named_button=True,
                     css_classes=['btn']),
    ]
Exemplo n.º 15
0
class FTPStorageForm(StorageForm):
    event = events.Admin.Storage.FTPStorageForm

    fields = StorageForm.fields + [
        ListFieldSet(
            'ftp',
            suppress_label=True,
            legend=N_('FTP Server Details:'),
            children=[
                TextField('server', label_text=N_('Server Hostname')),
                TextField('user', label_text=N_('Username')),
                TextField('password', label_text=N_('Password')),
                TextField(
                    'upload_dir',
                    label_text=N_('Subdirectory on server to upload to')),
                TextField(
                    'upload_integrity_retries',
                    label_text=N_(
                        'How many times should MediaDrop try to verify the FTP upload before declaring it a failure?'
                    ),
                    validator=Int()),
                TextField(
                    'http_download_uri',
                    label_text=N_('HTTP URL to access remotely stored files')),
                TextField(
                    'rtmp_server_uri',
                    label_text=N_(
                        'RTMP Server URL to stream remotely stored files (Optional)'
                    )),
            ]),
    ] + StorageForm.buttons

    def display(self, value, engine, **kwargs):
        """Display the form with default values from the given StorageEngine.

        If the value dict is not fully populated, populate any missing entries
        with the values from the given StorageEngine's
        :attr:`_data <mediadrop.lib.storage.StorageEngine._data>` dict.

        :param value: A (sparse) dict of values to populate the form with.
        :type value: dict
        :param engine: An instance of the storage engine implementation.
        :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass

        """
        data = engine._data
        ftp = value.setdefault('ftp', {})
        ftp.setdefault('server', data.get(FTP_SERVER, None))
        ftp.setdefault('user', data.get(FTP_USERNAME, None))
        ftp.setdefault('password', data.get(FTP_PASSWORD, None))
        ftp.setdefault('upload_dir', data.get(FTP_UPLOAD_DIR, None))
        ftp.setdefault('upload_integrity_retries',
                       data.get(FTP_MAX_INTEGRITY_RETRIES, None))
        ftp.setdefault('http_download_uri', data.get(HTTP_DOWNLOAD_URI, None))
        ftp.setdefault('rtmp_server_uri', data.get(RTMP_SERVER_URI, None))
        return StorageForm.display(self, value, engine, **kwargs)

    def save_engine_params(self, engine, **kwargs):
        """Map validated field values to engine data.

        Since form widgets may be nested or named differently than the keys
        in the :attr:`mediadrop.lib.storage.StorageEngine._data` dict, it is
        necessary to manually map field values to the data dictionary.

        :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass
        :param engine: An instance of the storage engine implementation.
        :param \*\*kwargs: Validated and filtered form values.
        :raises formencode.Invalid: If some post-validation error is detected
            in the user input. This will trigger the same error handling
            behaviour as with the @validate decorator.

        """
        StorageForm.save_engine_params(self, engine, **kwargs)
        ftp = kwargs['ftp']
        engine._data[FTP_SERVER] = ftp['server']
        engine._data[FTP_USERNAME] = ftp['user']
        engine._data[FTP_PASSWORD] = ftp['password']
        engine._data[FTP_UPLOAD_DIR] = ftp['upload_dir']
        engine._data[FTP_MAX_INTEGRITY_RETRIES] = ftp[
            'upload_integrity_retries']
        engine._data[HTTP_DOWNLOAD_URI] = ftp['http_download_uri']
        engine._data[RTMP_SERVER_URI] = ftp['rtmp_server_uri']
Exemplo n.º 16
0
class AppearanceForm(ListForm):
    template = 'admin/box-form.html'
    id = 'settings-form'
    css_class = 'form'
    submit_text = None

    event = events.Admin.Settings.AppearanceForm

    fields = [
        ListFieldSet('general', suppress_label=True, legend=N_('General'),
            css_classes=['details_fieldset'],
            children=[
                FileField('appearance_logo', label_text=N_('Logo'),
                    validator=FieldStorageUploadConverter(not_empty=False,
                        label_text=N_('Upload Logo')),
                    css_classes=[],
                    default=lambda: request.settings.get('appearance_logo', \
                                                             'logo.png'),
                    template='./admin/settings/appearance_input_field.html'),
                FileField('appearance_background_image', label_text=N_('Background Image'),
                    validator=FieldStorageUploadConverter(not_empty=False,
                        label_text=N_('Upload Background')),
                    css_classes=[],
                    default=lambda: request.settings.get('appearance_background_image', \
                                                             'bg_image.png'),
                    template='./admin/settings/appearance_input_field.html'),
                TextField('appearance_background_color', maxlength=255,
                    label_text=N_('Background color'),
                    validator=Regex(hex_validation_regex, strip=True)),
                TextField('appearance_link_color', maxlength=255,
                    label_text=N_('Link color'),
                    validator=Regex(hex_validation_regex, strip=True)),
                TextField('appearance_visited_link_color', maxlength=255,
                    label_text=N_('Visited Link color'),
                    validator=Regex(hex_validation_regex, strip=True)),
                TextField('appearance_text_color', maxlength=255,
                    validator=Regex(hex_validation_regex, strip=True),
                    label_text=N_('Text color')),
                TextField('appearance_heading_color', maxlength=255,
                    label_text=N_('Heading color'),
                    validator=Regex(hex_validation_regex, strip=True)),
                SingleSelectField('appearance_navigation_bar_color',
                    label_text=N_('Color Scheme'),
                    options=navbar_colors),
            ]
        ),
        ListFieldSet('options', suppress_label=True, legend=N_('Options'),
            css_classes=['details_fieldset'],
            children=[
                CheckBox('appearance_enable_cooliris',
                    css_classes=['checkbox-left'],
                    label_text=N_('Enable Cooliris on the Explore Page'),
                    help_text=N_('Cooliris support is deprecated and will be ' + \
                        'removed in the next major version of MediaDrop ' + \
                        'unless someone is interested in maintaining it.'),
                    validator=Bool(if_missing='')),
                CheckBox(u'appearance_display_login',
                    css_classes=['checkbox-left'],
                    label_text=N_('Display login link for all users'),
                    validator=Bool(if_missing='')),
                CheckBox('appearance_enable_featured_items',
                    label_text=N_('Enable Featured Items on the Explore Page'),
                    css_classes=['checkbox-left'],
                    validator=Bool(if_missing='')),
                CheckBox('appearance_enable_podcast_tab',
                    label_text=N_('Enable Podcast Tab'),
                    css_classes=['checkbox-left'],
                    validator=Bool(if_missing='')),
                CheckBox('appearance_enable_user_uploads',
                    label_text=N_('Enable User Uploads'),
                    css_classes=['checkbox-left'],
                    validator=Bool(if_missing='')),
                CheckBox('appearance_enable_widescreen_view',
                    label_text=N_('Enable widescreen media player by default'),
                    css_classes=['checkbox-left'],
                    validator=Bool(if_missing='')),
                CheckBox('appearance_display_logo',
                    label_text=N_('Display Logo'),
                    css_classes=['checkbox-left'],
                    validator=Bool(if_missing='')),
                CheckBox('appearance_display_background_image',
                    label_text=N_('Display Background Image'),
                    css_classes=['checkbox-left'],
                    validator=Bool(if_missing='')),
                CheckBox('appearance_display_mediadrop_footer',
                    label_text=N_('Display MediaDrop Footer'),
                    css_classes=['checkbox-left'],
                    validator=Bool(if_missing='')),
                CheckBox('appearance_display_mediadrop_credits',
                    label_text=N_('Display MediaDrop Credits in Footer'),
                    css_classes=['checkbox-left'],
                    validator=Bool(if_missing='')),
            ],
            template='./admin/settings/appearance_list_fieldset.html',
        ),
        ListFieldSet('player', suppress_label=True, legend=N_('Player Menu Options'),
            css_classes=['details_fieldset'],
            children=[
                CheckBox('appearance_show_download',
                    css_classes=['checkbox-left'],
                    label_text=N_('Enable Download button on player menu bar.'),
                    validator=Bool(if_missing='')),
                CheckBox('appearance_show_share',
                    css_classes=['checkbox-left'],
                    label_text=N_('Enable Share button on player menu bar.'),
                    validator=Bool(if_missing='')),
                CheckBox('appearance_show_embed',
                    css_classes=['checkbox-left'],
                    label_text=N_('Enable Embed button on player menu bar.'),
                    validator=Bool(if_missing='')),
                CheckBox('appearance_show_widescreen',
                    css_classes=['checkbox-left'],
                    label_text=N_('Enable Widescreen toggle button on player menu bar.'),
                    validator=Bool(if_missing='')),
                CheckBox('appearance_show_popout',
                    css_classes=['checkbox-left'],
                    label_text=N_('Enable Popout button on player menu bar.'),
                    validator=Bool(if_missing='')),
                CheckBox('appearance_show_like',
                    css_classes=['checkbox-left'],
                    label_text=N_('Enable Like button on player menu bar.'),
                    validator=Bool(if_missing='')),
                CheckBox('appearance_show_dislike',
                    css_classes=['checkbox-left'],
                    label_text=N_('Enable Dislike button on player menu bar.'),
                    validator=Bool(if_missing='')),
            ],
            template='./admin/settings/appearance_list_fieldset.html',
        ),
        ListFieldSet('advanced', suppress_label=True, legend=N_('Advanced'),
            css_classes=['details_fieldset'],
            children=[
                TextArea('appearance_custom_css',
                    label_text=N_('Custom CSS'),
                    attrs=dict(rows=15, cols=25)),
                TextArea('appearance_custom_header_html',
                    label_text=N_('Custom Header HTML'),
                    attrs=dict(rows=15, cols=25)),
                TextArea('appearance_custom_footer_html',
                    label_text=N_('Custom Footer HTML'),
                    attrs=dict(rows=15, cols=25)),
                TextArea('appearance_custom_head_tags',
                    label_text=N_('Custom <head> Tags'),
                    help_text=N_('These HTML tags are inserted into the HTML '
                        '<head> section. Bad input can cause ugly rendering of '
                        'your site. You can always restore your page by '
                        'the box above.'),
                    attrs=dict(rows=15, cols=25)),
            ],
        ),
        SubmitButton('save', default=N_('Save'), css_classes=['btn', 'btn-save', 'blue', 'f-rgt']),
        SubmitButton('reset', default=N_('Reset to Defaults'),
            css_classes=['btn', 'btn-cancel', 'reset-confirm']),
    ]
Exemplo n.º 17
0
class YoutubePlayerPrefsForm(PlayerPrefsForm):
    event = events.Admin.Players.YoutubeFlashPlayerPrefsForm

    fields = [
        ListFieldSet(
            'options',
            suppress_label=True,
            legend=N_('Player Options:'),
            children=[
                RadioButtonList(
                    'version',
                    options=lambda: (
                        (2, _('Use the deprecated AS2 player.')),
                        (3, _('Use the AS3/HTML5 player.')),
                    ),
                    css_label_classes=['container-list-label'],
                    label_text=N_("YouTube player version"),
                    validator=Int,
                ),
                RadioButtonList(
                    'iv_load_policy',
                    options=lambda: (
                        (1, _('Show video annotations by default.')),
                        (3, _('Hide video annotations by default.')),
                    ),
                    css_label_classes=['container-list-label'],
                    label_text=N_("Video annotations"),
                    validator=Int,
                ),
                CheckBox(
                    'disablekb',
                    label_text=N_('Disable the player keyboard controls.'),
                    help_text=N_('Not supported by HTML5 player.')),
                CheckBox('autoplay',
                         label_text=N_(
                             'Autoplay the video when the player loads.')),
                CheckBox(
                    'modestbranding',
                    label_text=N_(
                        'Do not show YouTube logo in the player controls'),
                    help_text=N_('Not supported by AS2 player.')),
                CheckBox('fs', label_text=N_('Display fullscreen button.')),
                CheckBox(
                    'hd',
                    label_text=N_('Enable high-def quality by default.'),
                    help_text=N_(
                        'Applies only for the AS2 player, the AS3 player will choose the most appropriate version of the video version (e.g. considering the user\'s bandwidth)'
                    )),
                CheckBox(
                    'rel',
                    label_text=N_(
                        'Display related videos after playback of the initial video ends.'
                    )),
                CheckBox(
                    'showsearch',
                    label_text=N_(
                        'Show the search box when the video is minimized. The related videos option must be enabled for this to work.'
                    ),
                    help_text=N_('AS2 player only')),
                CheckBox(
                    'showinfo',
                    label_text=N_(
                        'Display information like the video title and uploader before the video starts playing.'
                    )),
                CheckBox(
                    'wmode',
                    label_text=N_('Enable window-less mode (wmode)'),
                    help_text=N_(
                        'wmode allows HTML/CSS elements to be placed over the actual Flash video but requires more CPU power.'
                    )),
                RadioButtonList(
                    'autohide',
                    options=lambda: (
                        (0, _('Always show player controls.')),
                        (1,
                         _('Autohide all player controls after a video starts playing.'
                           )),
                        (2,
                         _('Autohide only the progress bar after a video starts playing.'
                           )),
                    ),
                    css_label_classes=['container-list-label'],
                    label_text=N_("Player control hiding"),
                    validator=Int,
                ),
            ],
            css_classes=['options'],
        )
    ] + PlayerPrefsForm.buttons

    def display(self, value, player, **kwargs):
        newvalue = {}
        defaults = {'options': player.data}
        merge_dicts(newvalue, defaults, value)
        return PlayerPrefsForm.display(self, newvalue, player, **kwargs)

    def save_data(self, player, options, **kwargs):
        for field, value in options.iteritems():
            player.data[field] = int(value)
Exemplo n.º 18
0
class StorageForm(ListForm):
    template = 'admin/box-form.html'
    id = 'storage-form'
    css_class = 'form storageform'
    submit_text = None
    show_children_errors = True
    _name = 'storage-form'  # TODO: Figure out why this is required??
    params = ['engine']

    fields = [
        ListFieldSet(
            'general',
            legend=N_('General Options:'),
            suppress_label=True,
            children=[
                TextField(
                    'display_name',
                    label_text=N_('Display Name'),
                    validator=TextField.validator(not_empty=True),
                    maxlength=100,
                ),
            ],
        ),
    ]

    buttons = [
        SubmitButton(
            'save',
            default=N_('Save'),
            css_classes=['btn', 'btn-save', 'blue', 'f-rgt'],
        ),
    ]

    def display(self, value, engine, **kwargs):
        """Display the form with default values from the given StorageEngine.

        If the value dict is not fully populated, populate any missing entries
        with the values from the given StorageEngine's
        :attr:`_data <mediadrop.lib.storage.StorageEngine._data>` dict.

        :param value: A (sparse) dict of values to populate the form with.
        :type value: dict
        :param engine: An instance of the storage engine implementation.
        :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass

        """
        general = value.setdefault('general', {})
        if not general.get('display_name', None):
            general['display_name'] = engine.display_name
        return ListForm.display(self, value, engine=engine, **kwargs)

    def save_engine_params(self, engine, general, **kwargs):
        """Map validated field values to engine data.

        Since form widgets may be nested or named differently than the keys
        in the :attr:`mediadrop.lib.storage.StorageEngine._data` dict, it is
        necessary to manually map field values to the data dictionary.

        :type engine: :class:`mediadrop.lib.storage.StorageEngine` subclass
        :param engine: An instance of the storage engine implementation.
        :param \*\*kwargs: Validated and filtered form values.
        :raises formencode.Invalid: If some post-validation error is detected
            in the user input. This will trigger the same error handling
            behaviour as with the @validate decorator.

        """
        engine.display_name = general['display_name']