Ejemplo n.º 1
0
class OcchielloSettingsControlPanelEditForm(controlpanel.RegistryEditForm):
    """Occhiello settings form.
    """
    schema = IOcchielloSettings
    id = "OcchielloSettingsEditForm"
    label = _(u"Occhiello settings")
    description = _(u"help_occhiello_settings_editform",
                    default=u"Manage site configuration for half-title field")

    @button.buttonAndHandler(_('Save'), name='save')
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        self.applyChanges(data)
        IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
                                                      "info")
        self.context.REQUEST.RESPONSE.redirect("@@occhiello-settings")

    @button.buttonAndHandler(_('Cancel'), name='cancel')
    def handleCancel(self, action):
        IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"),
                                                      "info")
        self.request.response.redirect(
            "%s/%s" % (self.context.absolute_url(), self.control_panel_view))
Ejemplo n.º 2
0
 def handleSave(self, action):
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     self.applyChanges(data)
     IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
                                                   "info")
     self.context.REQUEST.RESPONSE.redirect("@@occhiello-settings")
Ejemplo n.º 3
0
 def handleSave(self, action):
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     self.applyChanges(data)
     IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
                                                   "info")
     self.context.REQUEST.RESPONSE.redirect("@@occhiello-settings")
Ejemplo n.º 4
0
class IOcchielloSettings(Interface):
    """
    Settings used in the control panel for Occhiello
    """

    enabled_types = schema.Tuple(
        title=_(u"Content types to apply half-title to"),
        required=False,
        default=DEFAULT_TYPES,
        value_type=schema.Choice(
            vocabulary='plone.app.vocabularies.ReallyUserFriendlyTypes'))
Ejemplo n.º 5
0
class OcchielloExtender(object):
    adapts(IBaseObject)
    implements(IOrderableSchemaExtender, IBrowserLayerAwareExtender)

    layer = IOcchielloLayer

    fields = [
        ExtensionStringField(
            'occhiello',
            widget=atapi.StringWidget(
                label=_(u"Half title"),
                description=u"",
            ),
            required=False,
            searchable=True,
        ),
    ]

    def __init__(self, context):
        self.context = context

    @property
    @memoize
    def enabled_types(self):
        registry = queryUtility(IRegistry)
        settings = registry.forInterface(IOcchielloSettings, check=False)
        return settings.enabled_types

    def getFields(self):
        if self.context.portal_type in self.enabled_types:
            return self.fields
        return []

    def getOrder(self, schematas):
        """Occhiello must be in the first schemata, before title
        """
        if self.context.portal_type in self.enabled_types:
            default = schematas["default"]
            default.remove('occhiello')
            default.insert(default.index('title'), 'occhiello')
        return schematas
Ejemplo n.º 6
0
 def handleCancel(self, action):
     IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"),
                                                   "info")
     self.request.response.redirect("%s/%s" % (self.context.absolute_url(),
                                               self.control_panel_view))
Ejemplo n.º 7
0
 def handleCancel(self, action):
     IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"),
                                                   "info")
     self.request.response.redirect(
         "%s/%s" % (self.context.absolute_url(), self.control_panel_view))