def getAvailableWorkflows(self): placeful = getToolByName(self.context, 'portal_placeful_workflow', None) if not placeful: return json.dumps({'status': 'error', 'msg': 'placeful workflow not installed'}) return executeAsManager(self.context, self._getAvailableWorkflows, placeful)
def assignWorkflowHere(self, id): if self.request.get("REQUEST_METHOD", 'GET') != 'POST': return json.dumps({'status': 'error', 'msg': 'Must be POST request.'}) placeful = getToolByName(self.context, 'portal_placeful_workflow', None) if not placeful: return json.dumps({'status': 'error', 'msg': 'placeful workflow not installed'}) wf_tool = getToolByName(self.context, 'portal_workflow') if id not in wf_tool.objectIds(): return json.dumps({'status': 'error', 'msg': 'Not a valid workflow.'}) executeAsManager(self.context, self.setWorkflowPolicy, placeful, id) return json.dumps({'status': 'success'})
def onSuccess(self, fields, REQUEST=None, loopstop=False): """ Triggered on successful form submission. Creates a data content entry, adds form contents to it, reindexes and sends an event to notify subscribers of the new entry. """ obj = self._createEntry() obj.setFormAdapter(self) form = aq_parent(aq_inner(self)) for field in self.fgFields(): widget_macro = getattr(getattr(field, 'widget', None), 'macro', None) name = field.getName() value = REQUEST.form.get(name) if field.__class__ == DataGridField: # clean up datagrid field for issues... if type(value) in (tuple, set, list): newval = [] for values in value: values = dict(values) if values.get('orderindex_', None) == \ 'template_row_marker': del values['orderindex_'] newval.append(values) value = newval elif widget_macro == 'donationfield_widget': # need to get the value from different request variables value = REQUEST.form.get('%s_level' % name) if not value: value = REQUEST.form.get('%s_amount' % name) if field.__class__ == FileField: fieldobj = form.findFieldObjectByName(name) isImField = fieldobj and fieldobj.getField('isImage') if isImField and isImField.get(fieldobj): field = obj.getField(name) name += '_file' value = REQUEST.form.get(name) if hasattr(value, 'filename') and value.filename: field.set(obj, value) else: field.set(obj, value) # rename id now... if self.getNiceIds(): if self.getAvoidSecurityChecks(): executeAsManager(self, obj._renameAfterCreation, check_auto_id=False) else: obj._renameAfterCreation(check_auto_id=False) obj.reindexObject() notify(ObjectInitializedEvent(obj)) # dispatch the event for others to use, with referrer last_referer = REQUEST.form.get('last_referer', None) parsed = urlparse(last_referer) pth = getattr(parsed, 'path', parsed[2]) referrer = self.restrictedTraverse(pth.strip('/').split('/'), None) evt = FormSaveData2ContentEntryFinalizedEvent(obj, referrer) notify(evt) # set values on request so others can know what object was # just created REQUEST.environ['d2c-obj-created-url'] = obj.absolute_url() REQUEST.environ['d2c-obj-created-uid'] = obj.UID()