Exemplo n.º 1
0
    def execute(self, bug, current_event):
        """See IEmailCommand."""
        if isinstance(bug, CreateBugParams):
            # Return the input because there is not yet a bug to
            # unsubscribe too.
            return bug, current_event

        string_args = list(self.string_args)
        if len(string_args) == 1:
            person = get_person_or_team(string_args.pop())
        elif len(string_args) == 0:
            # Subscribe the sender of the email.
            person = getUtility(ILaunchBag).user
        else:
            raise EmailProcessingError(
                get_error_message('unsubscribe-too-many-arguments.txt',
                                  error_templates=error_templates))

        if bug.isSubscribed(person):
            try:
                bug.unsubscribe(person, getUtility(ILaunchBag).user)
            except UserCannotUnsubscribePerson:
                raise EmailProcessingError(
                    get_error_message('user-cannot-unsubscribe.txt',
                                      error_templates=error_templates,
                                      person=person.displayname))
        if bug.isSubscribedToDupes(person):
            bug.unsubscribeFromDupes(person, person)

        return bug, current_event
Exemplo n.º 2
0
 def test_team_by_email(self):
     # The team's contact email address can also be used to get the team.
     owner = self.factory.makePerson()
     team = self.factory.makeTeam(owner=owner,
                                  email='*****@*****.**')
     self.assertEqual(team,
                      get_person_or_team('*****@*****.**'))
Exemplo n.º 3
0
 def test_team_by_email(self):
     # The team's contact email address can also be used to get the team.
     owner = self.factory.makePerson()
     team = self.factory.makeTeam(
         owner=owner, email='*****@*****.**')
     self.assertEqual(
         team, get_person_or_team('*****@*****.**'))
Exemplo n.º 4
0
    def execute(self, bug, current_event):
        """See IEmailCommand."""
        if isinstance(bug, CreateBugParams):
            # Return the input because there is not yet a bug to
            # unsubscribe too.
            return bug, current_event

        string_args = list(self.string_args)
        if len(string_args) == 1:
            person = get_person_or_team(string_args.pop())
        elif len(string_args) == 0:
            # Subscribe the sender of the email.
            person = getUtility(ILaunchBag).user
        else:
            raise EmailProcessingError(
                get_error_message(
                    'unsubscribe-too-many-arguments.txt',
                    error_templates=error_templates))

        if bug.isSubscribed(person):
            try:
                bug.unsubscribe(person, getUtility(ILaunchBag).user)
            except UserCannotUnsubscribePerson:
                raise EmailProcessingError(
                    get_error_message(
                        'user-cannot-unsubscribe.txt',
                        error_templates=error_templates,
                        person=person.displayname))
        if bug.isSubscribedToDupes(person):
            bug.unsubscribeFromDupes(person, person)

        return bug, current_event
Exemplo n.º 5
0
    def convertArguments(self, context):
        """See EmailCommand."""
        person_name_or_email = self.string_args[0]

        # "nobody" is a special case that means assignee == None.
        if person_name_or_email == "nobody":
            return {self.name: None}

        return {self.name: get_person_or_team(person_name_or_email)}
Exemplo n.º 6
0
    def convertArguments(self, context):
        """See EmailCommand."""
        person_name_or_email = self.string_args[0]

        # "nobody" is a special case that means assignee == None.
        if person_name_or_email == "nobody":
            return {self.name: None}

        return {self.name: get_person_or_team(person_name_or_email)}
Exemplo n.º 7
0
    def parseReviewRequest(klass, op_name, string_args):
        if len(string_args) == 0:
            raise EmailProcessingError(
                get_error_message('num-arguments-mismatch.txt',
                                  command_name=op_name,
                                  num_arguments_expected='one or more',
                                  num_arguments_got='0'))

        # Pop the first arg as the reviewer.
        reviewer = get_person_or_team(string_args.pop(0))
        if len(string_args) > 0:
            review_tags = ' '.join(string_args)
        else:
            review_tags = None
        return (reviewer, review_tags)
Exemplo n.º 8
0
    def parseReviewRequest(klass, op_name, string_args):
        if len(string_args) == 0:
            raise EmailProcessingError(
                get_error_message(
                    'num-arguments-mismatch.txt',
                    command_name=op_name,
                    num_arguments_expected='one or more',
                    num_arguments_got='0'))

        # Pop the first arg as the reviewer.
        reviewer = get_person_or_team(string_args.pop(0))
        if len(string_args) > 0:
            review_tags = ' '.join(string_args)
        else:
            review_tags = None
        return (reviewer, review_tags)
Exemplo n.º 9
0
    def execute(self, bug, current_event):
        """See IEmailCommand."""
        string_args = list(self.string_args)
        # preserve compatibility with the original command that let you
        # specify a subscription type
        if len(string_args) == 2:
            # Remove the subscription_name
            string_args.pop()

        user = getUtility(ILaunchBag).user

        if len(string_args) == 1:
            person = get_person_or_team(string_args.pop())
        elif len(string_args) == 0:
            # Subscribe the sender of the email.
            person = user
        else:
            raise EmailProcessingError(
                get_error_message(
                    'subscribe-too-many-arguments.txt',
                    error_templates=error_templates))

        if isinstance(bug, CreateBugParams):
            if len(bug.subscribers) == 0:
                bug.subscribers = [person]
            else:
                bug.subscribers.append(person)
            return bug, current_event

        if bug.isSubscribed(person):
            # but we still need to find the subscription
            for bugsubscription in bug.subscriptions:
                if bugsubscription.person == person:
                    break

        else:
            bugsubscription = bug.subscribe(person, user)
            notify(ObjectCreatedEvent(bugsubscription))

        return bug, current_event
Exemplo n.º 10
0
    def execute(self, bug, current_event):
        """See IEmailCommand."""
        string_args = list(self.string_args)
        # preserve compatibility with the original command that let you
        # specify a subscription type
        if len(string_args) == 2:
            # Remove the subscription_name
            string_args.pop()

        user = getUtility(ILaunchBag).user

        if len(string_args) == 1:
            person = get_person_or_team(string_args.pop())
        elif len(string_args) == 0:
            # Subscribe the sender of the email.
            person = user
        else:
            raise EmailProcessingError(
                get_error_message('subscribe-too-many-arguments.txt',
                                  error_templates=error_templates))

        if isinstance(bug, CreateBugParams):
            if len(bug.subscribers) == 0:
                bug.subscribers = [person]
            else:
                bug.subscribers.append(person)
            return bug, current_event

        if bug.isSubscribed(person):
            # but we still need to find the subscription
            for bugsubscription in bug.subscriptions:
                if bugsubscription.person == person:
                    break

        else:
            bugsubscription = bug.subscribe(person, user)
            notify(ObjectCreatedEvent(bugsubscription))

        return bug, current_event
Exemplo n.º 11
0
 def test_by_email(self):
     # The user's launchpad name can be used to get them.
     eric = self.factory.makePerson(email="*****@*****.**")
     self.assertEqual(eric, get_person_or_team('*****@*****.**'))
Exemplo n.º 12
0
 def test_team_by_name(self):
     # A team can also be gotten by name.
     owner = self.factory.makePerson()
     team = self.factory.makeTeam(owner=owner, name='fooix-devs')
     self.assertEqual(team, get_person_or_team('fooix-devs'))
Exemplo n.º 13
0
 def test_by_email(self):
     # The user's launchpad name can be used to get them.
     eric = self.factory.makePerson(email="*****@*****.**")
     self.assertEqual(eric, get_person_or_team('*****@*****.**'))
Exemplo n.º 14
0
 def test_by_name(self):
     # The user's launchpad name can be used to get them.
     eric = self.factory.makePerson(name="eric")
     self.assertEqual(eric, get_person_or_team('eric'))
Exemplo n.º 15
0
 def test_team_by_name(self):
     # A team can also be gotten by name.
     owner = self.factory.makePerson()
     team = self.factory.makeTeam(owner=owner, name='fooix-devs')
     self.assertEqual(team, get_person_or_team('fooix-devs'))
Exemplo n.º 16
0
 def test_me(self):
     # The special case of "me" refers to the logged-in user, that is,
     # the user who sent the email being processed.
     me = getUtility(IPersonSet).getByEmail('*****@*****.**')
     self.assertEqual(me, get_person_or_team('me'))
Exemplo n.º 17
0
 def test_by_name(self):
     # The user's launchpad name can be used to get them.
     eric = self.factory.makePerson(name="eric")
     self.assertEqual(eric, get_person_or_team('eric'))