示例#1
0
 def form_fields(self):
     '''
     The fields for this form
     '''
     ff = FormFields(IVacationBooking)
     ff['start_date'].field.default = date.today()
     if not self.context.getGates():
         ff = ff.omit('gate')
     return ff
示例#2
0
 def form_fields(self):
     form_fields = FormFields(ISearchReplaceForm)
     container = aq_parent(self.context)
     if not self.context.isPrincipiaFolderish and not isDefaultPage(
             container, self.context):
         form_fields = form_fields.omit("searchSubfolders")
     form_fields["findWhat"].custom_widget = TwoLineTextAreaWidget
     form_fields["replaceWith"].custom_widget = TwoLineTextAreaWidget
     return form_fields
 def form_fields(self):
     '''
     The fields for this form
     '''
     ff = FormFields(IAddForm)
     ff = ff.omit('captcha')
     ff['email'].field.required = False
     ff['mobile'].field.constraint = check_mobile_number
     return ff
 def form_fields(self):
     form_fields = FormFields(ISearchReplaceForm)
     container = aq_parent(self.context)
     if not self.context.isPrincipiaFolderish and not isDefaultPage(
             container, self.context):
         form_fields = form_fields.omit('searchSubfolders')
     form_fields['findWhat'].custom_widget = TwoLineTextAreaWidget
     form_fields['replaceWith'].custom_widget = TwoLineTextAreaWidget
     return form_fields
示例#5
0
 def test_externalKeywordTest(self):
     fields = FormFields(ISEOConfigletSchema)
     ffield = fields.get("external_keywords_test")
     self.assertTrue(ffield is not None, 'Not found "external_keywords_test" '\
         'field in ISEOConfigletSchema interface')
     self.assertTrue(IBool.providedBy(ffield.field),
         '"external_keywords_test" is not boolean type field')
     self.assertTrue(ffield.field.default == False,
         '"external_keywords_test" field default value is not set to False')
 def form_fields(self):
     '''
     The fields for this form
     '''
     ff = FormFields(IAddForm)
     if not self.context.restrictedTraverse('plone_portal_state/anonymous')():
         ff = ff.omit('captcha')
     else:
         ff['captcha'].custom_widget = CaptchaWidget
     return ff
示例#7
0
 def form_fields(self):
     '''
     The fields for this form
     '''
     ff = FormFields(IAddForm)
     if not self.context.restrictedTraverse(
             'plone_portal_state/anonymous')():
         ff = ff.omit('captcha')
     else:
         ff['captcha'].custom_widget = CaptchaWidget
     return ff
 def form_fields(self):
     '''
     The fields for this form
     '''
     ff = FormFields(IAddForm)
     if not self.is_anonymous:
         ff = ff.omit('captcha')
     else:
         ff['captcha'].custom_widget = CaptchaWidget
     ff['tipology'].custom_widget = TipologyWidget
     return ff
示例#9
0
 def test_externalKeywordTest(self):
     fields = FormFields(ISEOConfigletSchema)
     ffield = fields.get("external_keywords_test")
     self.assertTrue(
         ffield is not None, 'Not found "external_keywords_test" field in '
         'ISEOConfigletSchema interface')
     self.assertTrue(IBool.providedBy(ffield.field),
                     '"external_keywords_test" is not boolean type field')
     self.assertTrue(
         ffield.field.default is False,
         '"external_keywords_test" field default value '
         'is not set to False')
 def mergedFields(self):
     """ merge all fields from registered extensions
     """
     form_fields = FormFields()
     sections = []
     extensions = [x for x in getUtilitiesFor(IDavizSection)]
     pos = 0
     for extension in extensions:
         if hasattr(extension[1], "form_fields"):
             form_fields = \
                 form_fields.__add__(extension[1].form_fields)
             sections.append(
                 (extension[1].prefix, extension[1].title, pos))
             pos += len(extension[1].form_fields)
     return {'form_fields':form_fields, 'sections': sections}
示例#11
0
class ExhibitSection(object):
    """ Simile Exhibit Settings Section
    """
    implements(IDavizSection)

    prefix = 'exhibit'
    title = 'Simile Exhibit Settings'
    form_fields = FormFields(
        schema.Choice(
            __name__='exhibit.framework',
            title=_(u'Version'),
            description=_(u"use the following version of Simile Exhibit "
                          "Framework"),
            required=True,
            default=3,
            vocabulary=SimpleVocabulary([
                SimpleTerm(2, 2, u"2.2.0"),
                SimpleTerm(3, 3, u"3.0.0"),
            ])
        ),
        schema.Bool(
            __name__='exhibit.ieForceExhibit2',
            title=_(u"Force Exhibit 2 for Internet Explorer"),
            description=_(u"force Simile Exhibit 2 for "
                          "Internet Explorer users as Simile Exhibit 3 is not "
                          "stable on this browser, yet. "
                          "Leave this option selected if you're unsure."),
            required=False,
            default=True
        )
    )
示例#12
0
class ImagingControlPanel(ControlPanelForm):

    form_fields = FormFields(IImagingSchema)

    label = _('Image handling settings')
    description = _('Settings to configure image handling in Plone.')
    form_name = _('Imaging scaling')
class OtherLicenseForm(AddForm):
    """ Other License Form """

    form_fields = FormFields(IOtherLicenseForm)
    label = _(u'Create License')
    description = _(u'Create a new license for use with your content types.')

    @action(_(u'Submit'), name=u'Submit')
    def action_submit(self, action, data):
        """ Submit new fields for a license """
        #        context = aq_inner(self.context)
        #        nl = (data['license_name'], data['license_name'], data['license_url'], data['license_image'])
        #        clutils = getUtility(IContentLicensingUtility)
        #        clutils.setRightsLicense(context, nl)
        #        IStatusMessage(self.request).addStatusMessage(_(u'Copyright License Changed.'), type='info')
        #        self.request.response.redirect('%s/insert_license' %self.context.absolute_url())
        return ''

    @action(_(u'Cancel'), validator=null_validator, name=u'Cancel')
    def action_cancel(self, action, data):
        """ Cancel create other license. """
        #        context = aq_inner(self.context)
        #        IStatusMessage(self.request).addStatusMessage(_(u'Copyright License change cancelled.'), type='info')
        #        self.request.response.redirect(context.absolute_url())
        return ''
示例#14
0
class SolrControlPanel(ControlPanelForm):

    form_fields = FormFields(ISolrSchema)

    label = _('Solr settings')
    description = _('Settings to enable and configure Solr integration.')
    form_name = _('Solr settings')
示例#15
0
    def __init__(self):
        def validateDefaultFolder(value):
            """ DefaultFolder Validation"""
            if value == "":
                return True
            portal = getSite()
            try:
                folder = portal.restrictedTraverse(value.encode('utf8'))
                allowedContentTypes = folder.allowedContentTypes()
                for allowedContentType in allowedContentTypes:
                    if allowedContentType.id == "DavizVisualization":
                        return True

            except (KeyError, AttributeError):
                raise InvalidDavizFolder(value)
            raise InvalidDavizFolder(value)

        self.form_fields = FormFields(
            schema.TextLine(
                __name__='daviz.defaultfolder',
                title=_(u'Default Folder for Visualizations'),
                description=_(u"""Default location where
                                  Visualizations are created"""),
                constraint=validateDefaultFolder,
                required=False)
            )
class RecaptchaSettingsForm(EditForm):
    schema = IRecaptchaSettings
    label = _(u"Recaptcha settings")

    if FormFields:
        # formlib missing (Plone 5?)
        form_fields = FormFields(IRecaptchaSettings)
示例#17
0
 def __init__(self, context, request):
     super(RenameForm, self).__init__(context, request)
     for name, value in self.request.form.items():
         self.request.form[name] = safe_unicode(value)
     self.form_fields = FormFields(IRenameForm)
     self.form_name = '%s (%s)' % (self.context.Title(), self.context.getId())
     mtool = getToolByName(self.context, 'portal_membership')
     title = self.context.Schema()['title']
     self.id = self.context.getId()
     self.languages = {}
     if (IMultilanguageField.providedBy(title) or
         not mtool.checkPermission(DeleteObjects, self.context) or
         not mtool.checkPermission(copy_or_move, self.context)):
         self.form_fields = self.form_fields.omit('id')
     if (IMultilanguageField.providedBy(title) or
         not mtool.checkPermission(ModifyPortalContent, self.context)):
         self.form_fields = self.form_fields.omit('title')
     if IMultilanguageField.providedBy(title):
         self.handler = IMultilanguageURLHandler(aq_parent(aq_inner(self.context)), None)
         for lang in title.getAvailableLanguages(self.context):
             self.languages[lang['name']] = lang['title']
             self.form_fields = self.form_fields + FormFields(
                 schema.TextLine(
                     __name__=lang['name'],
                     title=lang['title'],
                     default=self.handler.get_translated_id(self.id, lang['name']),
                     required=True
                 )
             )
             self.form_fields[lang['name']].interface = IRenameForm
class SecurityControlPanel(ControlPanelForm):

    form_fields = FormFields(ISecuritySchema)

    label = _("Security settings")
    description = _("Security settings for this site.")
    form_name = _("Security settings")
示例#19
0
class ImportForm(EditForm):
    """ Render the import form  """

    implements(IImport)
    form_fields = FormFields(IImport)
    form_fields['filename'].custom_widget = FileWidget
    label = u"Import Zip File"
    description = u"This form will import content from files contained in a .zip file. From the zip file: Folders will become Spaces, Image files (.jpg, .png, .gif, etc.) will become Images and HTML files (.html) will become Wiki Pages."

    def __init__(self, context, request):
        self.context = context
        self.request = request
        self.zft_util = getUtility(IZipFileTransportUtility)

    @action(_(u'label_import', default=u'Import'), name=u'Import')
    def action_import(self, action, data):
        file_obj = self.context.REQUEST['form.filename']
        description = self.context.REQUEST['form.description']
        contributors = ''
        overwrite = self.context.REQUEST.has_key('form.overwrite')
        categories = self.context.REQUEST['form.categories']

        self.zft_util.importContent(file=file_obj,
                                    context=self.context,
                                    description=description,
                                    contributors=contributors,
                                    overwrite=overwrite,
                                    categories=categories)

        self.request.response.redirect('./folder_contents')
class DropdownControlPanel(ControlPanelForm):
    form_fields = FormFields(IDropdownConfiguration)

    label = _(u"A dropdown menu configuration.")
    description = _(
        u'Settings to configure dropdown menus for global navigation.')
    form_name = _(u'Dropdown menu settings')
示例#21
0
class ProvidersControlPanel(ControlPanelForm):
    """ """
    template = ViewPageTemplateFile('likes.pt')
    form_fields = FormFields(IProvidersSchema)

    form_fields['enabled_portal_types'].custom_widget = MultiSelectWidget
    form_fields['plugins_enabled'].custom_widget = MultiSelectWidget

    label = _('Social: Like Actions settings')
    description = _('Configure settings for social like actions.')
    form_name = _('Social: Like Actions')

    def plugins_configs(self):
        """ Return Plugins and their configuration pages """
        context = aq_inner(self.context)
        portal_url = getToolByName(context, 'portal_url')()
        registered = dict(getUtilitiesFor(IPlugin))
        plugins = []
        for name in registered:
            plugin = registered[name]
            config_view = plugin.config_view()
            if config_view:
                url = '%s/%s' % (portal_url, config_view)
                plugins.append({'name': name, 'url': url})
        return plugins
示例#22
0
def additional_user_fields():
    "List of fields that the User schema has been extended with"
    fields = []
    for ext in component.getUtilitiesFor(IUserSchemaExtension):
        for field in ext[1].fields:
            if not field.__name__ == 'objectClass':
                fields.append(field)
    return FormFields(*fields)
示例#23
0
class PropertyEditForm(LDAPEditForm):
    """An edit form for LDAP properties.
    """
    form_fields = FormFields(ILDAPPropertyConfiguration)
    label = _(u"Edit Property")
    description = _(u"Edit a LDAP property.")
    form_name = _(u"Configure property")
    fieldset = "schema"
示例#24
0
class SitesAdminConfigForm(ControlPanelForm):

    form_fields = FormFields(ISitesAdminConfig)

    label = u"Configuration Panel for Sites Admin"
    description = u'This panel will be used to config'

    form_name = u'Hide Unnessary Add-on Products'
示例#25
0
class ServerEditForm(LDAPEditForm):
    """An edit form for LDAP servers.
    """
    form_fields = FormFields(ILDAPServerConfiguration)
    label = _(u"Edit Server")
    description = _(u"Edit a LDAP or ActiveDirectory server.")
    form_name = _(u"Configure server")
    fieldset = "servers"
示例#26
0
class SillyConfigurationForm(ControlPanelForm):

    form_fields = FormFields(ISillyConfiguration)

    label = _(u"A silly settings form")
    description = _(u'Put details description here!')

    form_name = _(u'Section Name',
                  default=u'Attributes')
class CalendarControlPanel(ControlPanelForm):

    form_fields = FormFields(ICalendarSchema)
    form_fields['firstweekday'].custom_widget = WeekdayWidget
    form_fields['calendar_states'].custom_widget = MultiCheckBoxVocabularyWidget

    label = _("Calendar settings")
    description = None
    form_name = _("Calendar settings")
class UserGroupsSettingsControlPanel(ControlPanelForm):

    base_template = ControlPanelForm.template
    template = ZopeTwoPageTemplateFile('usergroupssettings.pt')

    form_fields = FormFields(IUserGroupsSettingsSchema)

    label = _("User/Groups settings")
    description = _("User and groups settings for this site.")
    form_name = _("User/Groups settings")
示例#29
0
class LanguageControlPanel(ControlPanelForm):

    form_fields = FormFields(ILanguageSelectionSchema)
    form_fields['default_language'].custom_widget = LanguageDropdownChoiceWidget

    label = _(u"heading_language_settings", default="Language Settings")
    description = _(u"description_language_settings",
                    default="Settings related to interface languages and "
                            "content translations.")
    form_name = _(u"heading_language_settings", default="Language Settings")
示例#30
0
 def _prependKeepMilestoneActiveField(self):
     keep_milestone_active_checkbox = FormFields(
         Bool(
             __name__='keep_milestone_active',
             title=_("Keep the %s milestone active." % self.context.name),
             description=_(
                 "Only select this if bugs or blueprints still need "
                 "to be targeted to this project release's milestone.")),
         render_context=self.render_context)
     self.form_fields = keep_milestone_active_checkbox + self.form_fields
示例#31
0
class VersioningSettingsConfiglet(ControlPanelForm):
    """The formlib class for the versioning settings page"""

    form_fields = FormFields(IVersioningSettingsSchema)
    form_fields[
        'versionable_types'].custom_widget = MultiCheckBoxVocabularyWidget

    label = _("Upfront Versioning Settings")
    description = _("")
    form_name = _("Upfront Versioning Settings")
示例#32
0
 def __init__(self):
     self.form_fields = FormFields(
         schema.Text(__name__='data.annotations',
                     title=_(u"Annotations"),
                     description=_(
                         "Data annotations - lowercase - to be "
                         "ignored/handled as annotations when processing "
                         "data tables. One per line "
                         "(e.g. 'n/a', 'n.a.', ':')"),
                     required=False), )
示例#33
0
class MapsControlPanel(ControlPanelForm):

    form_fields = FormFields(IMapsSchema)
    label = _("Maps settings")
    description = None
    form_name = _("Maps settings")

    def _on_save(self, data):
        # This ensures the change is reflected on the served javascripts
        jstool = getToolByName(self.context, 'portal_javascripts')
        jstool.cookResources()
示例#34
0
class BarraControlPanel(ControlPanelForm):
    ''' Implementacao do painel de controle da Barra de Identidade '''
    # Define quais serao os campos a serem exibidos (IBarraConfSchema)
    form_fields = FormFields(IBarraConfSchema)

    # Define o titulo deste painel de controle
    label = _(u'Brasil.gov.br: Barra de identidade')
    # Define a descricao deste painel de controle
    description = _(u'Configurações do comportamento da barra de identidade')
    # Define o titulo do formulario deste painel de controle
    form_name = _(u'Configuração visual')
class ControlPanel(ControlPanelForm):
    form_fields = FormFields(ITransformSchema)
    form_fields["enabled_transforms"].custom_widget = MultiCheckBoxVocabularyWidget

    label = _("ploneboard_configuration",
            default="Ploneboard configuration")
    description = _("description_ploneboard_config",
            default="Here you can configure site settings for Ploneboard.")

    form_name = _("ploneboard_transform_panel",
            default="Text transformations")
class EasyslideshowControlPanel(ControlPanelForm):
    form_fields = FormFields(IEasyslideshowConfiguration)

    label = _(u"EasySlideshow configuration.")
    description = _(u"Settings to configure the slideshow. "
                    "The slideshow will work best if all images are "
                    "the exact same size, and that size should match "
                    "the width and height below. Otherwise, you may get "
                    "some unexpected behavior based on which transition "
                    "is chosen.")
    form_name = _(u'Slideshow settings')
示例#37
0
class RenameForm(EditForm):

    label = _p(u'heading_rename_item', default=u'Rename item')
    description = _p(u'description_rename_item',
                    default=u'Each item has a Short Name and a Title, which you can change '
                             'by entering the new details below.')

    def __init__(self, context, request):
        super(RenameForm, self).__init__(context, request)
        for name, value in self.request.form.items():
            self.request.form[name] = safe_unicode(value)
        self.form_fields = FormFields(IRenameForm)
        self.form_name = '%s (%s)' % (self.context.Title(), self.context.getId())
        mtool = getToolByName(self.context, 'portal_membership')
        title = self.context.Schema()['title']
        self.id = self.context.getId()
        self.languages = {}
        if (IMultilanguageField.providedBy(title) or
            not mtool.checkPermission(DeleteObjects, self.context) or
            not mtool.checkPermission(copy_or_move, self.context)):
            self.form_fields = self.form_fields.omit('id')
        if (IMultilanguageField.providedBy(title) or
            not mtool.checkPermission(ModifyPortalContent, self.context)):
            self.form_fields = self.form_fields.omit('title')
        if IMultilanguageField.providedBy(title):
            self.handler = IMultilanguageURLHandler(aq_parent(aq_inner(self.context)), None)
            for lang in title.getAvailableLanguages(self.context):
                self.languages[lang['name']] = lang['title']
                self.form_fields = self.form_fields + FormFields(
                    schema.TextLine(
                        __name__=lang['name'],
                        title=lang['title'],
                        default=self.handler.get_translated_id(self.id, lang['name']),
                        required=True
                    )
                )
                self.form_fields[lang['name']].interface = IRenameForm

    def validate(self, action, data):
        errors = super(RenameForm, self).validate(action, data)
        for field in self.form_fields:
            name = field.field.getName()
            if name == 'title':
                continue
            value = data.get(name, u'')
            check_id = getattr(self.context, 'check_id', None)
            if ((name == 'id' and not value == self.id) or
                (name in self.languages.keys() and not value == self.handler.get_translated_id(self.id, name) and
                 not value == self.id and not self.id == self.handler.get_actual_id(value)) and
                check_id is not None):
                error = check_id(str(value), required=1)
                if error:
                    widget = self.widgets[name]
                    widget._error = WidgetInputError(widget.name, widget.label, InvalidIDError(error))
                    errors.append(widget._error)
        return errors

    @action(_p(u'label_rename_all', default=u'Rename All'), name=u'rename')
    def handle_rename_action(self, action, data):
        context = aq_inner(self.context)
        oldid = context.getId()
        oldtranslatedids = self.handler.get_translated_ids(oldid)
        descriptions = applyData(context, self.form_fields, data, self.adapters)
        statusmessage = IStatusMessage(self.request)
        if descriptions:
            statusmessage.addStatusMessage(_p(u'Changes saved.'), u'success');
        else:
            statusmessage.addStatusMessage(_p(u'No changes made.'));
        self.request.RESPONSE.redirect(context.absolute_url())