class WickedDoc(ATDocument): """ A page in the portal; supports wiki linking. """ implements(IAmWicked, IAttributeAnnotatable) archetype_name = 'Wicked Doc' portal_type = meta_type = 'WickedDoc' global_allow = True schema = ATDocument.schema.copy() + atapi.Schema(( WikiField('text', required=True, searchable=True, primary=True, filters=('Wicked Filter',), validators = ('isTidyHtmlWithCleanup',), default_content_type = ATDOCUMENT_CONTENT_TYPE, default_output_type = 'text/html', allowable_content_types = ('text/structured', 'text/x-rst', 'text/html', 'text/plain', 'text/plain-pre', 'text/python-source',), widget = atapi.RichWidget(description = "The body text "\ "of the document.", description_msgid = "help_body_text", label = "Body text", label_msgid = "label_body_text", rows = 25, i18n_domain = "plone")), ))
class AlarmActivity(BaseAutomaticActivity): zope.interface.implements(IAlarmActivity) zope.interface.classProvides(Products.AlphaFlow.interfaces.IActivityClass) meta_type = "AlphaFlow Alarm Activity" activity_type = "alarm" icon = "misc_/AlphaFlow/alarm" # The following defaults for schema fields are needed to avoid attribute # errors. However, they will not validate by default to force users to # fill in data. due = None schema_to_validate = IAlarmActivity configurationSchema = atapi.Schema(( atapi.DateTimeField("due", widget=atapi.CalendarWidget( label="Alarm date and time", description="Select a date and time " "when the alarm should trigger.", description_msgid="description_alarm_activity", i18n_domain="alphaflow" )), ))
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 IronicWiki(atapi.BaseContent): """ Ironic wiki Portal Content """ implements(IAmWicked, IAttributeAnnotatable) archetype_name = portal_type = meta_type = 'IronicWiki' schema = atapi.BaseSchema.copy() + atapi.Schema((WikiField( "body", primary=True, filters=('Wicked Filter', ), default_content_type='text/structured', default_output_type='text/html', allowable_content_types=('text/structured', 'text/restructured', 'text/html', 'text/plain', 'text/plain-pre'), widget=atapi.RichWidget(description="The body text of the document.", description_msgid="help_body_text", label="Body text", label_msgid="label_body_text", rows=25, i18n_domain="plone")), ))
class EMailActivity(BaseAutomaticActivity): zope.interface.implements(IEMailActivity) zope.interface.classProvides(IActivityClass) meta_type = "AlphaFlow EMail Activity" activity_type = "email" icon = "misc_/AlphaFlow/email" recipient_modes = () template = "" mailSubject = None schema_to_validate = IEMailActivity configurationSchema = atapi.Schema((atapi.LinesField( "recipients", widget=atapi.TextAreaWidget( label="Email recipients", description="""Enter the email addresses of all persons """ """that should receive this notification.""", i18n_domain="alphaflow")), ))
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
class FormSubmissionFolderAdapter( folder.ATFolder, saveDataAdapter.FormSaveDataAdapter): """ A form action adapter that saves form submissions as content in a folder. """ schema = folder.ATFolder.schema.copy( ) + public.Schema(( saveDataAdapter.FormSaveDataAdapter.schema['showFields'].copy(), public.StringField( 'titleField', vocabulary='allFieldDisplayList', default_method='getDefaultTitleField', required=0, searchable=0, widget=public.SelectionWidget( label=_(u'label_titlefield_text', default=u"Title Field"), description=_( u'help_titlefield_text', default=u"""\ You may select a form field to be used as the submissions Plone title. If left empty, the title will be left blank."""))), public.StringField( 'submissionType', required=0, searchable=0, default='Document', vocabulary='getFolderAddableTypes', widget=public.SelectionWidget( label=_(u'label_submissiontype_text', default=u"Submission Type"), description=_( u'help_submissiontype_text', default=u"""\ You may select another content type to create for form submissions. Note that the content type's schema will be overridden by the schema defined by the form, so choosing a non-default content type will only work as much as the form schema matches the content type's schema"""))), public.ReferenceField( 'submissionFolder', relationship='submissionFolder', allowed_types_method='getFolderishTypes', default_method='getSubmissionFolderDefault', required=0, searchable=0, widget=public.ReferenceWidget( label=_(u'label_submissionfolder_text', default=u"Submission Folder"), description=_( u'help_submissionfolder_text', default=u"""\ You may select a folder in which submissions will be saved. If left blank, submissions will be saved inside this adapter."""))), public.LinesField( 'submissionTransitions', vocabulary='getAvilableSubmissionTransitions', widget=public.PicklistWidget( label=_(u'label_submissiontransitions_text', default='Submission Workflow Transitions'), description=_(u'help_submissiontransitions_text', default=u"""\ Select a sequence of workflow transitions to be applied on the newly created submission object. If the Submission Type workflow doesn't start out in a private state, it is important to choose the right transitons to keep form submissions from being publicly available."""))), )) meta_type = 'FormSubmissionFolderAdapter' portal_type = 'FormSubmissionFolderAdapter' archetype_name = 'Submission Folder Adapter' immediate_view = default_view = 'folder_listing' suppl_views = ('folder_contents', ) security = ClassSecurityInfo() security.declarePrivate('onSuccess') def onSuccess(self, fields, REQUEST, loopstop=False): """ Add a Form Submission object to the folder on success. Manually check if the user has permission. If anonymous users have permissions to add submissions, then make sure the submission is owned by the adapter owner to prevent security issues such as various anonymous users accessing each others submissions. """ folder = self.getSubmissionFolder() portal_type = self.getSubmissionType() types = getToolByName(self, 'portal_types') allowed = types[portal_type].isConstructionAllowed(folder) membership = getToolByName(self, 'portal_membership') user = getSecurityManager().getUser() owner = self.getWrappedOwner() is_anon = membership.isAnonymousUser() try: if not allowed or is_anon: newSecurityManager(REQUEST, owner) submission, changed = self.addSubmission( REQUEST, folder, portal_type) finally: if not allowed or is_anon: newSecurityManager(REQUEST, user) if not allowed and not is_anon: submission.changeOwnership(user, recursive=1) submission.manage_setLocalRoles(user.getId(), ('Owner', )) if 'controller_state' in REQUEST: # Record the submission object where the CMFFormController # machinery can get at it. REQUEST['controller_state'].kwargs.update(**changed) # Use the catalog brain for anonymous access in TAL expressions catalog = getToolByName(self, 'portal_catalog') REQUEST['form_submission'] = catalog._catalog[ catalog.getrid('/'.join(submission.getPhysicalPath()))] def addSubmission(self, REQUEST, folder, portal_type): """ Perform content operations as the appropriate user. """ form = aq_parent(aq_inner(self)) if folder is None: folder = self order = folder.getOrdering() if not hasattr(order, '__contains__'): order = folder.contentIds() title_field_name = self.getTitleField() or 'title' changed = {} if title_field_name in form: # Get the title from a form field in the submission title_field = form[title_field_name] title, kwargs = title_field.fgField.widget.process_form( title_field, title_field.fgField, REQUEST.form) changed[title_field_name] = title else: # Generate a title from the form title title = '{0} Submission'.format(form.Title()) # Generate an id from the title, adding a suffix if existing id_ = str(norm_ifaces.IUserPreferredURLNormalizer( REQUEST).normalize(title)) if id_ in order: # Exising objects have the id, find the next index suffix order_idx = len(folder) - 1 base_id = id_ idx = 0 while id_ in order: while order_idx >= 0: # Start at the end to try and find the highest index order_id = order[order_idx] if order_id.startswith(base_id + '-'): idx = int(order_id[len(base_id + '-'):]) break order_idx -= 1 id_ = '{0}-{1}'.format(base_id, (idx + 1)) new_id = folder.invokeFactory(portal_type, id_, title=title) submission = folder[new_id] submission.addReference(self, relationship='submissionFolderAdapter') # Mark the item as a form submission so the schema is extended with the # form schema interface.alsoProvides(submission, IFormSubmission) # Set the submission field values now that the extender applies extender.disableCache(REQUEST) schema = submission.Schema() for field in schema.fields(): if field.__name__ in ('id', 'title'): # skip factory arguments continue result = field.widget.process_form( submission, field, REQUEST.form, empty_marker=BaseObject._marker, validating=False) if result is BaseObject._marker or result is None: continue changed[field.__name__] = result[0] if field.__name__ in ('id', 'title'): # already set in the factory continue field.set(submission, result[0], **result[1]) # Apply workflow transitions workflow = getToolByName(submission, 'portal_workflow') for transition in self.getSubmissionTransitions(): try: workflow.doActionFor(submission, transition) except WorkflowCore.WorkflowException: logger.exception( 'Workflow transition {0!r} failed on form submission: {1}' .format(transition, self.absolute_url)) submission.setLayout('base_view') return submission, changed security.declarePrivate('setDefaults') def getDefaultTitleField(self): """ Use the first form field as the default title field. """ form = aq_parent(aq_inner(self)) return form.fgFields()[0].__name__ security.declarePrivate('setDefaults') def getSubmissionFolderDefault(self): """ Use the adapter itself as the default submission folder. """ return self # TODO Currently there is a chicken and egg between finding out which types # can be added to the submission folder before we select the submission # folder and also which workflow transitions are available for the type. # In the future it would be nice to have AJAX support for updating the # other when one changes. security.declarePrivate('setDefaults') def getFolderishTypes(self, instance): """ List all portal types that allow creating the submission type. """ types = getToolByName(self, 'portal_types') return [self.getPortalTypeName()] + [ typeinfo.getId() for typeinfo in types.objectValues() if typeinfo.global_allow and not typeinfo.filter_content_types] security.declarePrivate('setDefaults') def getFolderAddableTypes(self): """ Return the allowed form submission types. """ # TODO See above # return self.getSubmissionFolder().allowedContentTypes() types = getToolByName(self, 'portal_types') return [ (typeinfo.getId(), typeinfo.title_or_id()) for typeinfo in types.objectValues() if typeinfo.global_allow] security.declarePrivate('setDefaults') def getAvilableSubmissionTransitions(self): """ List all the possible transitions for the submission type's workflow. """ workflow = getToolByName(self, 'portal_workflow') workflows = set() workflows.update(*[ workflow.getChainForPortalType(portal_type) for portal_type in self.Vocabulary('submissionType')[0].keys()]) # TODO See above # workflows = workflow.getChainForPortalType(self.getSubmissionType()) transitions = {} for workflow_id in workflows: workflow_obj = workflow[workflow_id] for state in workflow_obj.states.objectValues(): for transition in workflow_obj.transitions.objectValues(): transitions[transition.getId()] = ( transition.actbox_name or transition.title_or_id()) return transitions.items()
id_schema = atapi.Schema(( atapi.StringField( 'id', required=1, accessor='getId', mutator='setId', mode='rw', read_permission=permissions.VIEW_PUBLIC_PERMISSION, write_permission=permissions.EDIT_ID_PERMISSION, default=None, index=('membrane_tool/ZCTextIndex,lexicon_id=member_lexicon,' 'index_type=Cosine Measure|TextIndex:brains', 'FieldIndex:brains'), regfield=1, # this field is part of the registration form user_property=True, widget=atapi.IdWidget( label='User name', label_msgid='label_user_name', size=10, maxlength=25, description="Enter a user name, usually something like " "'jsmith'. No spaces or special characters. User " "names and passwords are case sensitive, make sure " "the capslock key is not enabled. This is the name " "used to log in.", description_msgid='help_user_name_creation_casesensitive', i18n_domain='plone', display_autogenerated=0, macro='memid')), atapi.ComputedField('title', searchable=1, expression='context.fileAs() or context.getId()', accessor='Title', user_property=True, widget=atapi.ComputedWidget(label_msgid="label_title", i18n_domain="plone")), ))
u"Exemple".encode("utf-8"), u"Complément".encode("utf-8"), u"En savoir plus".encode("utf-8"), u"Explication".encode("utf-8"), u"Définition".encode("utf-8"), u"Remarque".encode("utf-8"), u"Méthode".encode("utf-8"), u"Rappel".encode("utf-8"), u"Attention".encode("utf-8"), u"Syntaxe".encode("utf-8"), u"Conseil".encode("utf-8"), u"Confère".encode("utf-8"), u"Citation".encode("utf-8"), u"Activité".encode("utf-8") ] DocumentSemantiqueSchema = ATDocumentSchema.copy() + atpublic.Schema( (atpublic.StringField("typeSemantique", required=False, accessor="getTypeSemantique", default=0, searchable=False, vocabulary=contenuDocumentSemantique, widget=atpublic.SelectionWidget( label=_(u"label_typeSemantique", default=u"Type"), description=_(u"desc_typeSemantique", default=u"Description du type"), format="select")), )) class DocumentSemantique(ATDocumentBase): """ Un document sémantique pour JalonEdit """ implements(IDocumentSemantique) meta_type = 'DocumentSemantique' schema = DocumentSemantiqueSchema
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())
class BaseAssignableActivity(BaseActivity): "Workflow activity instances of which may be assigned to a member." zope.interface.implements(IAssignableActivity) contentRoles = () completionUrlExpression = "" security = ClassSecurityInfo() configurationSchema = atapi.Schema((atapi.LinesField( "assignees", vocabulary="getPossibleAssignees", enforceVocabulary=True, required=True, default_method='_get_assignees_default', widget=atapi.MultiSelectionWidget( label="Assigned users", description="Select one or more users for this task", ), ), )) showInWorkList = True assigneesKind = "possible" assigneesExpression = None groups = () roles = () schema_to_validate = IAssignableActivity security.declareProtected(config.WORK_WITH_PROCESS, "getPossibleAssignees") def getPossibleAssignees(self): """Returns a list of possible users. Works only for roles and groups! """ if self.roles: member_ids = list(self._get_assignees_by_roles()) elif self.groups: gt = getToolByName(self, 'portal_groups') member_ids = utils.expandGroups(gt, self.groups) else: member_ids = [] member_ids.sort() return zip(member_ids, member_ids) security.declarePrivate("getConfigurationSchema") def getConfigurationSchema(self, content): """Getter method to retrieve the configuration schema. This also allows for different activities to have programmatic influence over how configuration schemas look like. """ schema = self.configurationSchema if schema is not None: schema = schema.copy() if self.assigneesKind == 'actual': # if assigneesKind is actual this field can't get configured schema.delField('assignees') return schema ######### # private security.declarePrivate('_get_assignees_default') def _get_assignees_default(self): return [getSecurityManager().getUser().getUserName()] security.declarePrivate('_get_assignees_by_roles') def _get_assignees_by_roles(self): content_object = self.getContentObject() if content_object is None: role_context = self roles = () else: role_context = content_object roles = self.roles members = utils.listMembersWithLocalRoles(role_context, roles) return members
JalonConnectSchema = ATDocumentSchema.copy() + atpublic.Schema(( atpublic.StringField( 'dateAjout', required = False, accessor = 'getDateAjout', searchable = False, widget = atpublic.StringWidget( label = _(u"Date de création sur Adobe Connect") )), atpublic.StringField( "duree", required = False, accessor = "getDuree", searchable = False, widget = atpublic.StringWidget( label = _(u"Durée"), )), atpublic.StringField( "dateUS", required = False, accessor = "getDateUS", searchable = False, widget = atpublic.StringWidget( label = _(u"La date US"), )), atpublic.StringField( "urlEnr", required = False, accessor = "getUrlEnr", searchable = False, widget = atpublic.StringWidget( label = _(u"URL de l'enregistrement Connect"), )), ))
BibliographieSchema = ATDocumentSchema.copy() + atpublic.Schema(( atpublic.StringField( "sous-titre", required=False, accessor="getSousTitre", searchable=False, widget=atpublic.StringWidget( label=_(u"label_sousTitreWebographie", default=u"sous Titre Webographie"), description=_(u"desc_sousTitreWebographie", default=u"Description du sous Titre Webographie"), )), 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, accessor="getLieu", searchable=False, widget=atpublic.StringWidget( label=_(u"label_lieu", default=u"Lieu"), description=_(u"desc_lieu", default=u"Description du lieu"), )), atpublic.StringField("editeur", required=True, accessor="getEditeur", searchable=False, widget=atpublic.StringWidget( label=_(u"label_editeur", default=u"Editeur"), description=_( u"desc_editeur", default=u"Description de l'editeur"), )), atpublic.IntegerField("annee", required=True, accessor="getAnnee", searchable=False, widget=atpublic.IntegerWidget( label=_(u"label_annee", default=u"Annee"), description=_(u"desc_annee", default=u"Description de l'annee"), )), atpublic.StringField( "pagination", required=False, accessor="getPagination", searchable=False, widget=atpublic.StringWidget( label=_(u"label_pagination", default=u"Pagination"), description=_(u"desc_pagination", default=u"Description de la pagination"), )), atpublic.StringField( "collection", required=False, accessor="getCollection", searchable=False, widget=atpublic.StringWidget( label=_(u"label_collection", default=u"Collection"), description=_(u"desc_collection", default=u"Description de la collection"), )), atpublic.StringField("isbn", required=False, accessor="getISBN", searchable=False, widget=atpublic.StringWidget( label=_(u"label_isbn", default=u"ISBN"), description=_(u"desc_isbn", default=u"Description de l'isbn"), )), atpublic.StringField( "urlbiblio", required=False, accessor="getURLWEB", searchable=False, widget=atpublic.StringWidget( label=_(u"label_urlbiblio", default=u"URL bibliographie"), description=_(u"desc_urlbiblio", default=u"Description de l'URL bibliographie"), )), atpublic.TextField("autre", required=False, accessor="getAutre", searchable=False, widget=atpublic.TextAreaWidget( label=_(u"label_autre", default=u"Autre"), description=_(u"desc_autre", default=u"Description de autre"), )), ))
JalonRessourceExterneSchema = ATDocumentSchema.copy() + atpublic.Schema(( atpublic.StringField("sousTitre", required=False, accessor="getSousTitre", 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", searchable=False, widget=atpublic.StringWidget(label=_(u"Editeur"), )), atpublic.IntegerField("annee", required=False, accessor="getAnnee", searchable=False, widget=atpublic.IntegerWidget(label=_(u"Année"), )), atpublic.StringField("pagination", required=False, accessor="getPagination", searchable=False, widget=atpublic.StringWidget( label=_(u"Pagination"), )), atpublic.StringField("collection", required=False, accessor="getCollection", searchable=False, widget=atpublic.StringWidget( label=_(u"Collection"), )), atpublic.StringField("isbn", required=False, accessor="getISBN", searchable=False, widget=atpublic.StringWidget(label=_(u"ISBN"), )), atpublic.StringField("urlbiblio", required=True, accessor="getURLWEB", searchable=False, widget=atpublic.StringWidget(label=_(u"URL"), )), atpublic.TextField("lecteur", required=True, accessor="getLecteur", searchable=False, widget=atpublic.TextAreaWidget( label=_(u"Lecteur exportable"), )), atpublic.StringField( "videourl", required=False, accessor="getVideourl", searchable=False, widget=atpublic.StringWidget( label=_(u"Slug de la vidéo sur le serveur de vidéo"), )), atpublic.StringField("videoauteur", required=False, accessor="getVideoauteur", searchable=False, widget=atpublic.StringWidget( label=_(u"Auteur de la vidéo"), )), atpublic.StringField("videoauteurname", required=False, accessor="getVideoauteurname", searchable=False, widget=atpublic.StringWidget( label=_(u"Nom de l'auteur de la vidéo"), )), atpublic.StringField("videothumbnail", required=False, accessor="getVideothumbnail", searchable=False, widget=atpublic.StringWidget( label=_(u"Vignette de la vidéo"), )), ))
import jalon_utils 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):
ProjectSchema = atct.ATContentTypeSchema.copy() + atapi.Schema( ( atapi.StringField( 'code', widget=atapi.StringWidget( label=_(u'Code'), i18n_domain='cirb.relex', ), ), atapi.StringField( 'name_fr', widget=atapi.StringWidget( label=_(u'Name FR'), i18n_domain='cirb.relex', ), ), atapi.StringField( 'name_en', widget=atapi.StringWidget( label=_(u'Name EN'), i18n_domain='cirb.relex', ), ), atapi.StringField( 'name_nl', widget=atapi.StringWidget( label=_(u'Name NL'), i18n_domain='cirb.relex', ), ), atapi.DateTimeField( 'start', widget=atapi.CalendarWidget( label=_(u'Start'), show_hm=False, i18n_domain='cirb.relex', ), ), atapi.DateTimeField( 'end', widget=atapi.CalendarWidget( label=_(u'End'), show_hm=False, i18n_domain='cirb.relex', ), ), atapi.StringField( 'url', widget=atapi.StringWidget( label=_(u'URL'), i18n_domain='cirb.relex', ), ), atapi.StringField( 'relationtype', 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", ), ), atapi.TextField( 'comments', widget=atapi.TextAreaWidget( label=_(u"Comments"), i18n_domain="cirb.relex", ), ), atapi.LinesField( 'themes', widget=atapi.LinesWidget( label=_(u"Themes"), i18n_domain="cirb.relex", ), ), atapi.LinesField( 'keywords', widget=atapi.LinesWidget( label=_(u"Keywords"), i18n_domain="cirb.relex", ), ), atapi.LinesField( 'brusselspartners', widget=atapi.LinesWidget( label=_(u"Brussels partners"), i18n_domain="cirb.relex", ), ), atapi.LinesField( 'countries', widget=atapi.LinesWidget( label=_(u"Countries"), i18n_domain="cirb.relex", ), ), atapi.LinesField( 'regions', widget=atapi.LinesWidget( label=_(u"Regions"), i18n_domain="cirb.relex", ), ), atapi.LinesField( 'cities', widget=atapi.LinesWidget( label=_(u"Cities"), i18n_domain="cirb.relex", ), ), atapi.LinesField( 'contacts', widget=atapi.LinesWidget( label=_(u"Contacts"), i18n_domain="cirb.relex", ), ), ), marshall=atapi.RFC822Marshaller())
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
from Products.CMFCore import permissions as cmfcore_permissions from Products.CMFCore.utils import getToolByName 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. """
from jalon.content import contentMessageFactory as _ from jalon.content.config import PROJECTNAME from jalon.content.interfaces import IJalonForum import jalon_utils JalonForumSchema = ATDocumentSchema.copy() + atpublic.Schema(( atpublic.StringField( "dateAff", required=False, accessor="getDateAff", searchable=False, widget=atpublic.StringWidget( label=_(u"Date d'affichage"), description=_(u"Description de la date d'affichage"), )), atpublic.StringField( "dateMasq", required=False, accessor="getDateMasq", searchable=False, widget=atpublic.StringWidget( label=_(u"Date à laquelle cette activité est masquée"), description=_(u"Date servant à masquer cette activité"), )), )) class JalonForum(ATDocumentBase): """ un forum pour Jalon """