def modifiedNewStyleResponse(object, event): """A response is modified or created so update its parent. """ if len(event.descriptions) > 0: parent = event.descriptions[0] if IIssue.providedBy(parent): merge_response_changes_to_issue(parent)
def addedNewStyleResponse(object, event): """A response has been added. """ issue = event.newParent if IIssue.providedBy(issue): merge_response_changes_to_issue(issue) sendResponseNotificationMail(issue)
def options(self): # Options to pass to the templates. We used to return an empty # dictionary by default, but we might as well return something useful # for most cases. context = aq_inner(self.context) portal = getSite() fromName = portal.getProperty('email_from_name', '') portal_membership = getToolByName(portal, 'portal_membership') member = portal_membership.getAuthenticatedMember() memberInfo = portal_membership.getMemberInfo(member.getUserName()) stateChanger = member.getUserName() if memberInfo: stateChanger = memberInfo['fullname'] or stateChanger # We expect to be called with an issue as context, but perhaps there # are other use cases, like a tracker or a brain or a response. # Get hold of the tracker if we can. if IIssue.providedBy(context): tracker = context.getTracker() elif ITracker.providedBy(context): tracker = context else: # This would be strange. tracker = None if tracker is None: tracker_title = '' else: tracker_title = tracker.title_or_id() mapping = dict( issue_title=su(context.title_or_id()), tracker_title=su(tracker_title), response_author=su(stateChanger), issue_url=su(context.absolute_url()), from_name=su(fromName)) return mapping
def options(self): # Options to pass to the templates. We used to return an empty # dictionary by default, but we might as well return something useful # for most cases. context = aq_inner(self.context) portal = getSite() fromName = portal.getProperty('email_from_name', '') portal_membership = getToolByName(portal, 'portal_membership') member = portal_membership.getAuthenticatedMember() memberInfo = portal_membership.getMemberInfo(member.getUserName()) stateChanger = member.getUserName() if memberInfo: stateChanger = memberInfo['fullname'] or stateChanger # We expect to be called with an issue as context, but perhaps there # are other use cases, like a tracker or a brain or a response. # Get hold of the tracker if we can. if IIssue.providedBy(context): tracker = context.getTracker() elif ITracker.providedBy(context): tracker = context else: # This would be strange. tracker = None if tracker is None: tracker_title = '' else: tracker_title = tracker.title_or_id() mapping = dict(issue_title=su(context.title_or_id()), tracker_title=su(tracker_title), response_author=su(stateChanger), issue_url=su(context.absolute_url()), from_name=su(fromName)) return mapping
def addedNewStyleResponse(object, event): """A response has been added. """ issue = event.newParent if IIssue.providedBy(issue): issue.reindexObject(idxs=['SearchableText']) issue.notifyModified() sendResponseNotificationMail(issue, object)
def modifiedNewStyleResponse(object, event): """A response is modified or created so update its parent. """ if len(event.descriptions) > 0: parent = event.descriptions[0] if IIssue.providedBy(parent): parent.reindexObject(idxs=['SearchableText']) parent.notifyModified()
def replace_old_with_new_responses(issue): if not IIssue.providedBy(issue): return responses = issue.contentValues(filter={'portal_type': 'PoiResponse'}) folder = IResponseContainer(issue) try: request = issue.REQUEST except AttributeError: # When called via prefs_install_products_form (Plone 3.3) we # have no REQUEST object here. We will use a dummy then. request = TestRequest() createview = Create(issue, request) path = '/'.join(issue.getPhysicalPath()) logger.debug("Migrating %s responses for issue at %s", len(responses), path) if not responses: return for old_response in responses: field = old_response.getField('response') text = field.getRaw(old_response) new_response = Response(text) new_response.mimetype = field.getContentType(old_response) new_response.creator = old_response.Creator() new_response.date = old_response.CreationDate() new_response.type = createview.determine_response_type(new_response) changes = old_response.getIssueChanges() for change in changes: new_response.add_change(**change) attachment_field = old_response.getField('attachment') attachment = attachment_field.getRaw(old_response) if attachment.get_size() > 0: new_response.attachment = attachment folder.add(new_response) issue._delObject(old_response.getId()) # This seems a good time to reindex the issue for good measure. issue.reindexObject()
def removedResponse(object, event): issue = event.oldParent if IIssue.providedBy(issue): merge_response_changes_to_issue(issue)
def removedResponse(object, event): issue = event.oldParent if IIssue.providedBy(issue): issue.reindexObject(idxs=['SearchableText']) issue.notifyModified()