class FlowSubMenuItem(ActionsSubMenuItem): title = _( u'label_flow_menu', default=u'Flow', ) description = _( u'title_flow_menu', default=u'Flow form management actions', ) submenuId = 'plone_contentmenu_flow' order = 35 extra = { 'id': 'plone-contentmenu-flow', 'li_class': 'plonetoolbar-content-action', } @memoize def available(self): actions_tool = api.portal.get_tool('portal_actions') actions = actions_tool.listActionInfos( object=self.context, categories=('object_flow', ), max=1, ) return len(actions) > 0
def toFieldValue(self, value): try: return super(AccessibleAjaxSelectWidgetConverter, self).toFieldValue(value) except ConstraintNotSatisfied as e: request = getRequest() if not request: raise if IAnnotations(request).get('collective.promises'): # skip rendering when unsolved promises exist raise if not self.widget.vocabulary: raise # Somewhat enable AjaxSelectWidget to work without javascript by # providing valid suggestions on the base of the entered value. factory = getUtility( IVocabularyFactory, name=self.widget.vocabulary, ) try: results = factory(query=e.args[0]) except (IndexError, TypeError): raise e candidates = [] for term in results: candidates.append( u'"{0:s}" ({1:s})'.format( term.token, translate(term.title, context=request), ), ) if len(candidates) >= 10: break if not candidates: raise if len(candidates) == 1: raise Invalid( _( u'Did you mean ${candidate}? ' u'Separate multiple values with ";".', mapping={'candidate': candidates[0]}, ), ) else: raise Invalid( _( u'Did you mean ${candidates} ' u'or ${last_candidate}? ' u'Separate multiple values with ";".', mapping={ 'candidates': u', '.join(candidates[:-1]), 'last_candidate': candidates[-1], }, ), )
def toFieldValue(self, value): try: return super(AccessibleDatetimeWidgetConverter, self).toFieldValue(value, ) except (TypeError, ValueError): raise Invalid( _( u'Date with time must be in international ' u'numerical format (YYYY-MM-DD HH:MM).', ), )
scan(schema) scan(subfolder) scan(transforms) configure.include(package=browser, file='__init__.py') if has_package('plone.restapi'): from collective.flow import restapi import plone.rest configure.include(package=plone.rest, file='meta.zcml') scan(restapi) @configure.gs.registerProfile.post_handler( name=u'default', title=_(u'Forms, workflows and everything'), description=_(u'Activates collective.flow'), directory=u'profiles/default', provides=u'Products.GenericSetup.interfaces.EXTENSION', ) def setup(context): # Creation of schema repository is disabled until there is a real use-case # and user interfaces for it: pass # portal = api.portal.get() # if 'schemata' in portal.objectIds(): # return # portal.portal_types.FlowSchemaRepository.global_allow = True # api.content.create( # portal, # 'FlowSchemaRepository',
class SubmissionBehaviorsVocabulary(object): def __call__(self, context=None): terms = [] for reg in getUtilitiesFor(IBehavior): if reg[0].startswith('submission_'): terms.append( SimpleTerm( value=reg[0], token=reg[0], title=reg[1].title, ), ) return SimpleVocabulary(terms) @configure.plone.behavior.provides( name=u'submission_cancel_button', title=_(u'Submission cancel edit button'), description=_(u'Enables cancel button on submission edit form', ), ) class ICancelButton(Interface): """Marker interface for submission cancel button""" @configure.plone.behavior.provides( name=u'submission_save_action_buttons', title=_(u'Submission save and action buttons'), description=_(u'Enables "Save and ..." buttons on submission edit form', ), ) class ISaveAndActionButtons(Interface): """Marker interface for submission cancel button"""
from copy import deepcopy from plone.supermodel.interfaces import IDefaultFactory from venusianconfiguration import configure from zope.interface import Interface from zope.interface import provider from zope.lifecycleevent import IObjectAddedEvent from zope.location.interfaces import IContained from zope.schema._bootstrapinterfaces import IContextAwareDefaultFactory import datetime import plone.api as api @configure.plone.behavior.provides( name=u'submission_default_values', title=_(u'Submission default values burner'), description=_(u'Provides support evaluating default values on creation', ), ) class IDefaultValues(Interface): """Marker interface for submission comments behavior""" def set_contained(value, name, parent): # Set contained information of schema.Object if IContained.providedBy(value): value.__name__ = name value.__parent__ = aq_base(parent) # Set contained information of schema.List|Tuple(value_type=Object) if isinstance(value, list) or isinstance(value, tuple): for item in value: if IContained.providedBy(item):
from plone.app.versioningbehavior.behaviors import IVersioningSupport from plone.app.versioningbehavior.behaviors import Versionable from plone.supermodel.interfaces import IFieldMetadataHandler from plone.supermodel.utils import ns from Products.CMFCore.interfaces import IActionSucceededEvent from Products.CMFEditions.interfaces.IArchivist import ArchivistError from venusianconfiguration import configure from zope.container.interfaces import IContainerModifiedEvent from zope.interface import alsoProvides from zope.interface import implementer from zope.interface import Interface @configure.plone.behavior.provides( name=u'submission_versioning', title=_(u'Submission versioning'), description=_( u'Provides Form flow submission versioning support with CMFEditions', ), marker=IVersioningSupport, factory=Versionable, ) class IVersionableSubmission(IVersionable): pass class IVersionableField(Interface): """Marker interface for a field with changelog with versioning behavior""" @configure.utility.factory(name='collective.flow.versioning')
# -*- coding: utf-8 -*- from collective.flow import _ from venusianconfiguration import configure from zope.interface import Interface @configure.plone.behavior.provides( name=u'submission_buttons_top', title=_(u'Submission top buttons'), description=_( u'Provides action and workflow buttons above content', ), ) class ITopButtons(Interface): """Marker interface for top buttons behavior""" @configure.plone.behavior.provides( name=u'submission_buttons_bottom', title=_(u'Submission bottom buttons'), description=_( u'Provides action and workflow buttons above content', ), ) class IBottomButtons(Interface): """Marker interface for bottom buttons behavior"""
class IFieldCommentsForm(Interface): comments = schema.Bool( title=_(u'Enable comments'), required=False, )
class IFieldChangelogForm(Interface): changelog = schema.Bool( title=_(u'Enable changelog'), required=False, )