Exemple #1
0
class EditPage(form.EditForm):
    """ Edit page
    """
    fields = field.Fields(IEEAVersionsPortalType)
    fields['last_assigned_version_number'].mode = DISPLAY_MODE

    def nextURL(self):
        """ Next
        """
        return "../@@view"

    @button.buttonAndHandler(_(u"label_apply", default=u"Apply"), name='apply')
    def handleApply(self, action):
        """ Apply button
        """
        data = self.extractData()[0]
        valid_input = input_is_valid(self, data)
        if not valid_input:
            return
        reset_triggered = self.reset_version_number(data)
        if reset_triggered:
            return self.request.response.redirect(self.nextURL())
        super(EditPage, self).handleApply(self, action)
        self.request.response.redirect(self.nextURL())

    def reset_version_number(self, data):
        """ reset version number if title is different
        """
        title = data.get('title')
        if title and self.context.title == title:
            return False
        current_id = self.context.id
        tool = self.context.aq_parent
        # 72521 Folderish content type fails when calling manage_renameObject
        # with operation is not supported and a simple change of id
        # will keep the object with the previous id as such we need to recreate
        # it and then delete the previous object
        self.context._setId(title)
        tool._setObject(str(title), self.context)
        tool._delObject(current_id)
        data['last_assigned_version_number'] = 0
        changes = self.applyChanges(data)
        if changes:
            self.status = self.successMessage
        else:
            self.status = self.noChangesMessage
        return True

    @button.buttonAndHandler(_(u"label_cancel", default=u"Cancel"),
                             name='cancel_add')
    def handleCancel(self, action):
        """ Cancel button
        """
        self.request.response.redirect(self.nextURL())
        return ''
Exemple #2
0
def input_is_valid(self, data):
    """ Flag input as invalid if both search_type and searc_interface is set
    """
    if data.get('search_type') and data.get('search_interface'):
        self.status = _("Cannot add both Portal type and "
                        "Provided Interface")
        self.formErrorsMessage = self.status
        return False
    return True
Exemple #3
0
def input_is_valid(self, data):
    """ Flag input as invalid if both search_type and searc_interface is set
    """
    if data.get('search_type') and data.get('search_interface'):
        self.status = _("Cannot add both Portal type and "
                        "Provided Interface")
        self.formErrorsMessage = self.status
        return False
    return True
Exemple #4
0
    def migrate(self, **kwargs):
        """ Migrate button
        """
        ids = kwargs.get('ids', [])
        if not ids:
            IStatusMessage(self.context.REQUEST).addStatusMessage(
                _("You need to select a custom portal type for migration"),
                type="error")
        for vid in ids:
            context = self.context
            version_tool = context
            vobj = version_tool.get(vid)
            vtitle = vobj.title
            migration_view = context.restrictedTraverse('@@migrateVersions')
            migration_view(prefix=vtitle)

        IStatusMessage(self.context.REQUEST).addStatusMessage(
            _("Migration for %s completed" % ",".join(ids)),
            type="info")
        self.request.response.redirect('@@view')
Exemple #5
0
    def migrate(self, **kwargs):
        """ Migrate button
        """
        ids = kwargs.get('ids', [])
        if not ids:
            IStatusMessage(self.context.REQUEST).addStatusMessage(
                _("You need to select a custom portal type for migration"),
                type="error")
        for vid in ids:
            context = self.context
            version_tool = context
            vobj = version_tool.get(vid)
            vtitle = vobj.title
            migration_view = context.restrictedTraverse('@@migrateVersions')
            migration_view(prefix=vtitle)

        IStatusMessage(self.context.REQUEST).addStatusMessage(_(
            "Migration for %s completed" % ",".join(ids)),
                                                              type="info")
        self.request.response.redirect('@@view')
Exemple #6
0
class IEEAVersionsPortalType(Interface):
    """ EEAVersions settings
    """
    title = schema.TextLine(
        title=_(u'Title'),
        description=_(u'Prefix title used for construction of version id'),
        required=True)

    search_interface = schema.Choice(
        title=_(u'Provided interface'),
        description=_(u'Interface to search for'),
        vocabulary="eea.versions.vocabularies.ObjectProvides",
        required=False)

    search_type = schema.Choice(
        title=_(u'Portal type'),
        description=_(u'Portal type to search for'),
        vocabulary="plone.app.vocabularies.ReallyUserFriendlyTypes",
        required=False)

    show_version_id = schema.Bool(
        title=_(u'Display in document byline'),
        description=_(u'Boolean if global id is visible in byline'),
        default=True)

    prefix_with_language = schema.Bool(
        title=_(u'Append language prefix to version id'),
        description=_(u'Boolean if language prefix is added to versionId'),
        default=False)

    last_assigned_version_number = schema.Int(
        title=_(u'Last version number'),
        description=_(u'Set automatically and incremented when a new version'
                      u' is assigned'),
        default=0,
        required=False)