コード例 #1
0
    def addresses(self):
        """
        Upon activity for the given issue, get the list of email
        addresses to which notifications should be sent. May return an
        empty list if notification is turned off. If issue is given, the
        issue poster and any watchers will also be included.

        Taken from PoiTracker.

        Note that we currently return only email addresses, without
        any full names.  That is what Poi has been doing, and it makes
        a few things simpler.
        """
        if not self.send_emails:
            return ()

        # make sure no duplicates are added
        addresses = sets.Set()

        context = aq_inner(self.context)
        memship = getToolByName(context, 'portal_membership', None)
        if memship is None:
            # Okay, either we are in a simple unit test, or someone is
            # using this package outside of CMF/Plone.  We should
            # assume the watchers are simple email addresses.
            addresses.union_update(self.watchers)
        else:
            addresses.union_update([get_member_email(w, memship)
                                    for w in self.watchers])
        addresses.union_update(self.extra_addresses)

        # Discard invalid addresses:
        addresses.discard(None)
        # Discard current user:
        email = get_member_email()
        addresses.discard(email)

        if self.allow_recursive:
            # Get addresses from parent (might be recursive).
            parent_list = IWatcherList(aq_parent(context), None)
            if parent_list is not None:
                addresses.union_update(parent_list.addresses)

        return tuple(addresses)
コード例 #2
0
ファイル: events.py プロジェクト: CMcStone/Products.Poi
def add_contact_to_issue_watchers(object, event=None):
    """Add the contactEmail of the issue to the watchers.

    Try to add the userid instead of the email.

    Called when an issue has been initialized or edited.
    """
    value = object.getContactEmail()
    if not value:
        return
    member_email = get_member_email()
    if member_email == value:
        # We can add the userid instead of the email.
        portal_membership = getToolByName(object, 'portal_membership')
        member = portal_membership.getAuthenticatedMember()
        value = member.getId()
    watchers = list(object.getWatchers())
    if value in watchers:
        return
    logger.info('Adding contact %s to watchers of issue %r.', value, object)
    watchers.append(value)
    object.setWatchers(tuple(watchers))
コード例 #3
0
ファイル: events.py プロジェクト: sixfeetup/Products.Poi
def add_contact_to_issue_watchers(object, event=None):
    """Add the contactEmail of the issue to the watchers.

    Try to add the userid instead of the email.

    Called when an issue has been initialized or edited.
    """
    value = object.getContactEmail()
    if not value:
        return
    member_email = get_member_email()
    if member_email == value:
        # We can add the userid instead of the email.
        portal_membership = getToolByName(object, 'portal_membership')
        member = portal_membership.getAuthenticatedMember()
        value = member.getId()
    watchers = list(object.getWatchers())
    if value in watchers:
        return
    logger.info('Adding contact %s to watchers of issue %r.', value, object)
    watchers.append(value)
    object.setWatchers(tuple(watchers))
コード例 #4
0
 def getDefaultContactEmail(self):
     """Get the default email address, that of the creating user"""
     return get_member_email()
コード例 #5
0
 def getDefaultContactEmail(self):
     """Get the default email address, that of the creating user"""
     return get_member_email()