def real_boolean_radiobuttonlist(name, **kwargs): # TODO: replace uses of boolean_radiobuttonlist with this, then scrap the old one. return RadioButtonList(name, options=lambda: ((True, _('Yes')), (False, _('No'))), validator=StringBool, **kwargs)
def boolean_radiobuttonlist(name, **kwargs): return RadioButtonList( name, options=lambda: (('true', _('Yes')), ('false', _('No'))), validator=OneOf(['true', 'false']), **kwargs )
class CommentsForm(ListForm): template = 'admin/box-form.html' id = 'settings-form' css_class = 'form' submit_text = None 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: http://www.facebook.com/developers/createapp.php')), ]), SubmitButton('save', default=N_('Save'), css_classes=['btn', 'btn-save', 'blue', 'f-rgt']), ]
class HTML5OrFlashPrefsForm(PlayerPrefsForm): fields = [ RadioButtonList( 'prefer_flash', options=lambda: ( (False, _('Yes, use the Flash Player when the device supports it.')), (True, _('No, use the HTML5 Player when the device supports it.')), ), css_classes=['options'], label_text=N_('Prefer the Flash Player when possible'), validator=StringBool, ), ] + PlayerPrefsForm.buttons event = events.Admin.Players.HTML5OrFlashPrefsForm def display(self, value, player, **kwargs): value.setdefault('prefer_flash', player.data.get('prefer_flash', False)) return PlayerPrefsForm.display(self, value, player, **kwargs) def save_data(self, player, prefer_flash, **kwargs): player.data['prefer_flash'] = prefer_flash
def boolean_radiobuttonlist(name, **kwargs): return RadioButtonList( name, options=lambda: ((True, _('Yes')), (False, _('No'))), validator=StringBool, **kwargs )
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']), ]
class GeneralForm(ListForm): template = 'admin/box-form.html' id = 'settings-form' css_class = 'form' submit_text = None 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, ), # NOTE: Commented out, pending removal in v0.9.1 if no one complains its gone. # ListFieldSet('default_wording', suppress_label=True, legend=N_('Administrative notes on Media:'), css_classes=['details_fieldset'], children=[ # CheckBox('wording_display_administrative_notes', # label_text=N_('Display notes'), # validator=Bool(if_missing='')), # TextArea('wording_administrative_notes', label_text=N_('Administrative Notes'), attrs=dict(rows=3, cols=25)), # ]), ]), SubmitButton('save', default=N_('Save'), css_classes=['btn', 'btn-save', 'blue', 'f-rgt']), ]
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)