def applyChanges(self, data): context = aq_inner(self.context) assert IPressRelease.providedBy(context) item = createContentInContainer(context, 'pressapp.presscontent.fileattachment', checkConstraints=True, **data) modified(item) item.reindexObject(idxs='modified') IStatusMessage(self.request).addStatusMessage( _(u"A new attachment was successfully added"), type='info') return self.request.response.redirect(context.absolute_url() + '/view')
def applyChanges(self, data): context = aq_inner(self.context) assert IPressRelease.providedBy(context) base_string = u'assets-' random_key = self.generate_random_key() new_title = base_string + random_key data['title'] = new_title item = createContentInContainer(context, 'pressapp.presscontent.imageattachment', checkConstraints=True, **data) item.setDescription(data['description']) modified(item) item.reindexObject(idxs='modified') IStatusMessage(self.request).addStatusMessage( _(u"A new image attachment was successfully been added"), type='info') return self.request.response.redirect(context.absolute_url() + '/view')