示例#1
0
 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
示例#2
0
 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
示例#3
0
def set_tracker_uid(context):
    """set _tracker_uid on Issues
    """

    issues = api.content.find(portal_type="Issue")
    for issue in issues:
        obj = issue.getObject()
        if ITracker.providedBy(obj.aq_parent):
            obj._tracker_uid = obj.aq_parent.UID()
            transaction.commit()
示例#4
0
def set_tracker_uid(context):
    """set _tracker_uid on Issues
    """

    issues = api.content.find(portal_type="Issue")
    for issue in issues:
        obj = issue.getObject()
        if ITracker.providedBy(obj.aq_parent):
            obj._tracker_uid = obj.aq_parent.UID()
            transaction.commit()
示例#5
0
    def getTracker(self):
        """Return the tracker.

        This gets around the problem that the aq_parent of an issue
        that is being created is not the tracker, but a temporary
        folder.
        """
        for parent in aq_chain(self):
            if ITracker.providedBy(parent):
                return parent
        raise Exception("Could not find PoiTracker in acquisition chain of %r" % self)
示例#6
0
    def getTracker(self):
        """Return the tracker.

        This gets around the problem that the aq_parent of an issue
        that is being created is not the tracker, but a temporary
        folder.
        """
        for parent in aq_chain(self):
            if ITracker.providedBy(parent):
                return parent
        raise Exception(
            "Could not find PoiTracker in acquisition chain of %r" % self)