class DefaultTestContent(AlphaFlowed, atapi.BaseContent): portal_type = archetype_name = meta_type = 'DefaultTestContent' schema = atapi.BaseSchema + atapi.Schema( (atapi.TextField('body', default='foo'), )) def manage_afterAdd(self, item, container): super(DefaultTestContent, self).manage_afterAdd(item, container) self.body = 'during_add'
class NTaskActivity(BaseAssignableActivity): zope.interface.implements(INTaskActivity) zope.interface.classProvides(IActivityClass) security = ClassSecurityInfo() meta_type = "AlphaFlow NTask Activity" activity_type = "ntask" icon = "misc_/AlphaFlow/ntask" schema_to_validate = INTaskActivity configurationSchema = atapi.Schema( (atapi.TextField( "task", widget=atapi.TextAreaWidget( label="Description of the task", description="Provide a description of the task, so that the " "assigned user knows what to do.", description_msgid="description_task_activity", i18n_domain="alphaflow")), )) + BaseAssignableActivity.configurationSchema
from Products.PlonePAS.tools.memberdata import MemberDataTool as BaseTool # gcommons from gcommons.Users.interfaces import IgcUserContainer from gcommons.Users import UsersMessageFactory as _ from gcommons.Users.config import PROJECTNAME logger = logging.getLogger("gcommons.Users.tools.gcUserContainer") gcUserContainerSchema = atapi.BaseFolderSchema.copy() + atapi.Schema(( # use MetadataStorage so as not to conflict w/ the 'description' # property used for old-school MemberData objects atapi.TextField( 'description', default='Container for Members', widget=atapi.TextAreaWidget(rows=5), ), )) search_catalog = 'membrane_tool' class gcUserContainer(atapi.BaseBTreeFolder, BaseTool): """Tool for gcommons Users.""" """ Default container for remember Member objects. Members don't actually need to live here any more, but for BBB reasons we are still storing them here. """ id = 'portal_gcommons_users' archetype_name = meta_type = portal_type = 'gcUserContainer'
searchable=False, widget=atpublic.StringWidget( label=_(u"Sous titre"), )), atpublic.StringField("typeRessourceExterne", required=True, accessor="getTypeRessourceExterne", searchable=False, default="", vocabulary=ressourceType, widget=atpublic.SelectionWidget( label=_(u"Type de la Ressource Externe"), format="select", )), atpublic.TextField("auteurs", required=True, accessor="getAuteurs", searchable=False, widget=atpublic.TextAreaWidget(label=_(u"Auteurs"), )), atpublic.StringField("volume", required=False, accessor="getVolume", searchable=False, widget=atpublic.StringWidget(label=_(u"Volume"), )), atpublic.StringField("lieu", required=False, accessor="getLieu", searchable=False, widget=atpublic.StringWidget(label=_(u"Lieu"), )), atpublic.StringField("editeur", required=False, accessor="getEditeur",
write_permission=permissions.EDIT_PROPERTIES_PERMISSION, vocabulary='getSiteLanguages', user_property=True, widget=atapi.SelectionWidget( label='Language', label_msgid='label_language', description="Your preferred language.", description_msgid='help_language', i18n_domain='plone')), atapi.TextField('description', default='', searchable=1, accessor="Description", user_property=True, widget=atapi.TextAreaWidget( label='Biography', label_msgid='label_biography', description='A short overview of who you are and what ' 'you do. Will be displayed on the your author page, ' 'linked from the items you create.', description_msgid='help_biography', i18n_domain='plone')), )) ################## # SECURITY_SCHEMA ################## # password fields show up (or not) by virtue of the # 'showPasswordField' method on the member object security_schema = atapi.Schema((
from Products.CMFCore.utils import getToolByName from Products.PlonePAS.tools.memberdata import MemberDataTool \ as BaseTool from Products.Archetypes import public as atapi from Products.remember.config import DEFAULT_MEMBER_TYPE from Products.remember.interfaces import IMemberDataContainer schema = atapi.BaseFolderSchema.copy() + atapi.Schema(( # use MetadataStorage so as not to conflict w/ the 'description' # property used for old-school MemberData objects atapi.TextField( 'description', default='Container for Members', widget=atapi.TextAreaWidget(rows=5), storage=atapi.MetadataStorage(), ), )) search_catalog = 'membrane_tool' class MemberDataContainer(atapi.BaseBTreeFolder, BaseTool): """ Default container for remember Member objects. Members don't actually need to live here any more, but for BBB reasons we are still storing them here. """ implements(IMemberDataTool, IMemberDataContainer)
class ProcurementRequest(afapi.AlphaFlowed, BaseContent): """A procurement request. """ zope.interface.implement(IAlphaFlowed) schema = atapi.BaseSchema.copy() + atapi.Schema(( atapi.StringField( "article", required=True, widget=atapi.StringWidget( label="Article", description="XXX", ), ), atapi.StringField( "account", required=False, vocabulary=config.accounts, widget=atapi.SelectionWidget( label="Account", description="XXX", ), ), atapi.TextField( "reason", required=False, widget=atapi.TextAreaWidget( label="Reason", description="XXX", ), ), atapi.FloatField( "price", required=True, ), atapi.DateTimeField( "due", required=True, ), )) schema["id"].widget.visible = \ schema["title"].widget.visible = { 'edit':'hidden', 'view':'hidden' } schema["title"].required = False content_icon = "file_icon.gif" # XXX global_allow = 0 archetype_name = "Procurement Request" portal_type = meta_type = "ProcurementRequest" include_default_actions = False actions = ( { 'id': 'view', 'name': 'View', 'action': 'string:${object_url}/base_view', }, { 'id': 'edit', 'name': 'Edit', 'action': 'string:${object_url}/base_edit', }, ) def Title(self): """DC title.""" return self.getArticle() def manage_afterAdd(self, item, container): ProcurementRequest.inheritedAttribute('manage_afterAdd')(self, item, container) if len(self.getAllInstances()) > 0: return wftool = getToolByName(self, "workflow_manager") process = wftool.processes['procurement'].current() self.assignProcess(process) self.getInstance().start("Workflow started by request creation.") def getAccountGroup(self): """Return the name of the group responsible for this request's account.""" return utils.getGroupFromAccount(self.getAccount())
from zope.component import getMultiAdapter from Products.TinyMCE.tests.base import FunctionalTestCase from Products.TinyMCE.tests.base import HAS_AT if HAS_AT: from Products.Archetypes import public as atapi # https://github.com/plone/Products.TinyMCE/blob/master/docs/source/usage.rst AT_FIELD = atapi.TextField( 'testfield', widget=atapi.RichWidget( allow_buttons=( # Real button which appears in the output 'bold-button', # Should not appear in the output as this button does not exist # in the orignal TinyMCE config 'autodefenestration-button', ), ), ) class WidgetSettingTestCase(FunctionalTestCase): """ Test widget specific TinyMCE settings """ def mockAtContent(self): """ Return faked context object for AT rich text field. Create a content with one field which contains only one button set.
widget=atapi.StringWidget( label=_(u'Relation type'), i18n_domain='cirb.relex', ), ), atapi.StringField( 'organisationtype', widget=atapi.StringWidget( label=_(u'Organisation type'), i18n_domain='cirb.relex', ), ), atapi.TextField( 'content_fr', widget=atapi.TextAreaWidget( label=_(u"Content FR"), i18n_domain="cirb.relex", ), ), atapi.TextField( 'content_en', widget=atapi.TextAreaWidget( label=_(u"Content EN"), i18n_domain="cirb.relex", ), ), atapi.TextField( 'content_nl', widget=atapi.TextAreaWidget( label=_(u"Content NL"), i18n_domain="cirb.relex",
class BaseWorkItem(DynamicLocalRoleSupport, ContentObjectRetrieverBase, LifeCycleObjectBase): zope.interface.implements( IWorkItem, zope.app.annotation.interfaces.IAttributeAnnotatable) alphaflow_type = "workitem" security = ClassSecurityInfo() global_allow = False content_object = None activity_type = "" activity_id = "" generated_by = None generated_workitems = () completed_by = None log_name = "work item" log_children_name = "checkpoints" schema = LifeCycleObjectBase.schema.copy() + atapi.Schema( (atapi.TextField("comment", widget=atapi.TextAreaWidget( description="Please enter any comments you " "have for this work item.")), atapi.StringField( "action", vocabulary="getActionVocabulary", widget=atapi.SelectionWidget( label="Workflow action", description="Select an action to perform after saving this " "form.")))) schema["id"].widget.visible = \ schema["title"].widget.visible = { 'edit':'hidden', 'view':'hidden' } schema["id"].write_permission = permissions.ManagePortal schema["title"].required = False schema["title"].write_permission = permissions.ManagePortal manage_options = \ ({'label' : 'Overview', 'action' : 'manage_overview'},) + \ LifeCycleObjectBase.manage_options local_role_fake_class = WorkItemLocalRoleFake _af_notified = True security.declareProtected(config.WORK_WITH_PROCESS, '__init__') def __init__(self, id, activity_id, content_object=None): BaseWorkItem.inheritedAttribute('__init__')(self, id) self.activity_id = activity_id self.content_object = content_object self.checkpoints_passed = persistent.list.PersistentList() def __repr__(self): try: state = ILifeCycleController(self).state except TypeError: state = 'n/a' return '<%s for %r (%s)>' % (self.__class__.__name__, self.activity_id, state) security.declarePrivate("getWorkItem") def getWorkItem(self): return self.aq_inner security.declarePublic('getCharset') def getCharset(self): """this is a skin method of archetypes returning the site encoding """ return config.SITE_ENCODING security.declarePublic('reindexObject') def reindexObject(self, idxs=[]): """workitems are very explicitly indexed""" pass security.declarePrivate('reindexWorkitem') def reindexWorkitem(self): BaseWorkItem.inheritedAttribute('reindexObject')(self) security.declarePrivate("beforeCreationItems") def beforeCreationItems(self, items, parent): """Trigger that gets called before new work items get active. Other work items can veto on the creation of those items and return a list of ids as a veto. After all work items have been triggered, the vetoed work items get removed again and never become active. """ return [] ######################### # ZMI convenience methods security.declareProtected(config.MANAGE_WORKFLOW, 'manage_userAction') def manage_userAction(self, actionId, REQUEST): """Performs an action defined by the activity.""" action = self.getActionById(actionId) action() REQUEST.RESPONSE.redirect(self.absolute_url() + "/manage_overview", lock=True) # IWorkItem security.declareProtected(config.WORK_WITH_PROCESS, 'getActions') def getActions(self): "Return a list of actions the user may perform on this work item." return [] security.declareProtected(config.WORK_WITH_PROCESS, 'getActionById') def getActionById(self, id): for action in self.getActions(): if action.id == id: return action raise KeyError(id) security.declareProtected(config.WORK_WITH_PROCESS, 'getGeneratedWorkItems') def getGeneratedWorkItems(self): inst = self.getInstance() wis = [inst[x] for x in self.generated_workitems] return wis security.declareProtected(config.WORK_WITH_PROCESS, 'isRelevant') def isRelevant(self, user): return user in self.listRelevantUsers() security.declareProtected(config.WORK_WITH_PROCESS, 'listRelevantUsers') def listRelevantUsers(self): return [] security.declareProtected(config.WORK_WITH_PROCESS, 'isChildOf') def isChildOf(self, workitem_id=None, workitem=None): """Returns True if the given work item is a predecessor of this work item (in regard to 'was generated by'). You only may give either workitem_id or workitem. """ if workitem_id is None: workitem_id = workitem.getId() if self.id == workitem_id: return False if self.generated_by == workitem_id: return True if self.generated_by == None: return False parent = self.getParent() if hasattr(parent, 'isChildOf'): return parent.isChildOf(workitem_id) return False security.declareProtected(config.WORK_WITH_PROCESS, 'getParent') def getParent(self): """Returns the parent WorkItem or None if this is a root workitem. """ if self.generated_by is None: return None parent = self.getInstance()[self.generated_by] # XXX This is a work-around; generated_by should never contain # the id of an instance. if not IWorkItem.providedBy(parent): return None else: return parent security.declareProtected(config.WORK_WITH_PROCESS, 'getShortInfo') def getShortInfo(self): """Returns a short information text.""" return "%s is in %s state" % (self.getId(), ILifeCycleController(self).state) security.declareProtected(config.WORK_WITH_PROCESS, 'getStatusInfo') def getStatusInfo(self): """Returns a short status information text.""" return ("WorkItems current status: %s" % ILifeCycleController(self).state) def onStart(self): self.passCheckpoint(config.CHECKPOINT_START) def onCompletion(self): self.passCheckpoint(config.CHECKPOINT_COMPLETE) self.completed_by = getSecurityManager().getUser().getUserName() security.declarePublic("getActivity") # XXX .... yurks def getActivity(self): activity = getattr(self, '_v_my_activity', None) if activity is None: process = self.getInstance().getProcess() if not hasattr(process, self.activity_id): ILifeCycleController(self).fail( "Could not find activity definition `%s` for workitem." % self.activity_id) raise AttributeError(self.activity_id) activity = getattr(process, self.activity_id) self._v_my_activity = activity activity = self._v_my_activity # wrapping magic return activity security.declarePublic("getActivityTitleOrId") def getActivityTitleOrId(self): try: activity = self.getActivity() except AttributeError: title = 'n/a' else: title = activity.title_or_id() return title security.declareProtected(config.WORK_WITH_PROCESS, "getDetailStatus") def getDetailStatus(self): """Return a (single line) string that describes the current status a bit more verbose.""" return ILifeCycleController(self).state security.declareProtected(config.WORK_WITH_PROCESS, 'getActionVocabulary') def getActionVocabulary(self): actions = [(action.id, action.title) for action in self.getActions() if action.enabled] # XXX This seems junk: actions.append(("", "No action")) return actions def absolute_url(self, inner=False): """A hackish way to use content objects as views. If this object is (directly) wrapped into an IAlphaFlowed, it will return the url of the IAlphaFlowed object""" absurl = BaseWorkItem.inheritedAttribute("absolute_url") if inner: return absurl(self) if not hasattr(self, 'aq_chain'): return absurl(self) if len(self.aq_chain) < 2: return absurl(self) if IAlphaFlowed.providedBy(self.aq_chain[1]): return self.aq_chain[1].absolute_url() return absurl(self) security.declareProtected(config.WORK_WITH_PROCESS, "getActivityConfiguration") def getActivityConfiguration(self, field, default=None): """Retrieves the configuration for this activity in the context of this instance. """ instance = self.getInstance() return instance.getActivityConfiguration(field, self.activity_id, default=default) security.declarePrivate("createWorkItems") def createWorkItems(self, activity_ids, content_object=None): """Creates a new workitem for the activity with the given name. Raises KeyError if any activity with the names is not known. """ instance = self.getInstance() return instance.createWorkItems(activity_ids, self, content_object=content_object) security.declarePrivate("notifyWorkItemStateChange") def notifyWorkItemStateChange(self, workitem): """Receives a notification that the work item <workitem> has changed it's state """ pass security.declarePrivate("notifyAssigneesChange") def notifyAssigneesChange(self): """notifies the workitem that the assignees might have changed """ alf = getToolByName(self, 'workflow_manager') alf.updateCacheByWorkItem(self) security.declarePrivate('passCheckpoint') def passCheckpoint(self, name): checkpoint = self.createChild(self.getActivity()[name]) self.checkpoints_passed.append(name) ILifeCycleController(checkpoint).start("Started by work item.") return checkpoint.generated_workitems ######################### # IContentObjectRetriever # Force acquisition of getContentObject by context instead of containment security.declareProtected(config.WORK_WITH_PROCESS, 'getContentObject') def getContentObject(self): if self.content_object is None: instance = self.getInstance() ob = instance.getContentObject() else: rc = getToolByName(self, "reference_catalog") ob = rc.lookupObject(self.content_object) return ob security.declareProtected(config.WORK_WITH_PROCESS, 'getContentObjectUID') def getContentObjectUID(self): if self.content_object is None: instance = self.getInstance() uid = instance.getContentObjectUID() else: uid = self.content_object return uid
JalonFileSchema = ATDocumentSchema.copy() + atpublic.Schema(( BlobField('file', widget=atpublic.FileWidget(label='A file', description='Some file'), required=True, ), atpublic.StringField("actif", required=False, accessor="getActif", searchable=False, default="actif", widget=atpublic.StringWidget(label=_(u"Actif"), )), atpublic.TextField("correction", required=True, accessor="getCorrection", searchable=False, widget=atpublic.TextAreaWidget(label=_(u"Correction"), )), atpublic.StringField("note", required=False, accessor="getNote", searchable=False, widget=atpublic.StringWidget(label=_(u"Note ou appréciation"), )), )) class JalonFile(ATDocumentBase): """ Un fichier pour une boite de dépot d'un cours Jalon """
)), atpublic.StringField( "premier-auteur", required=True, accessor="getPremierAuteur", searchable=False, widget=atpublic.StringWidget( label=_(u"label_premierAuteur", default=u"premier Auteur"), description=_(u"desc_premierAuteur", default=u"Description du premier Auteur"), )), atpublic.TextField( "autres-auteurs", required=False, accessor="getAutresAuteurs", searchable=False, widget=atpublic.TextAreaWidget( label=_(u"label_autresAuteurs", default=u"autres Auteurs"), description=_(u"desc_autresAuteurs", default=u"Description des autres Auteurs"), )), atpublic.StringField("volume", required=False, accessor="getVolume", searchable=False, widget=atpublic.StringWidget( label=_(u"label_volume", default=u"Volume"), description=_(u"desc_volume", default=u"Description du volume"), )), atpublic.StringField("lieu", required=False,