← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] ~pappacena/launchpad:bugfix-email-change-error-msg-1907173 into launchpad:master

 


Diff comments:

> diff --git a/lib/lp/registry/browser/team.py b/lib/lp/registry/browser/team.py
> index c309d57..d10af5a 100644
> --- a/lib/lp/registry/browser/team.py
> +++ b/lib/lp/registry/browser/team.py
> @@ -520,8 +521,10 @@ class TeamContactAddressView(MailingListTeamBaseView):
>                      # We need to wrap this in structured, so that the
>                      # markup is preserved.  Note that this puts the
>                      # responsibility for security on the exception thrower.
> -                    self.setFieldError('contact_address',
> -                                       structured(str(error)))
> +                    msg = error.args[0]
> +                    if not isinstance(msg, structured):

Ok!

> +                        msg = structured(six.text_type(msg))
> +                    self.setFieldError('contact_address', msg)
>          elif data['contact_method'] == TeamContactMethod.HOSTED_LIST:
>              mailing_list = getUtility(IMailingListSet).get(self.context.name)
>              if mailing_list is None or not mailing_list.is_usable:
> diff --git a/lib/lp/registry/browser/tests/test_team.py b/lib/lp/registry/browser/tests/test_team.py
> index 672c59d..44a1d63 100644
> --- a/lib/lp/registry/browser/tests/test_team.py
> +++ b/lib/lp/registry/browser/tests/test_team.py
> @@ -967,3 +970,28 @@ class TestPersonIndexVisibilityView(TestCaseWithFactory):
>              'private team link', 'a',
>              attrs={'href': '/~private-team', 'class': 'sprite team private'},
>              text='Private Team'))
> +
> +
> +class TestTeamContactAddressView(TestCaseWithFactory):
> +
> +    layer = DatabaseFunctionalLayer
> +
> +    def test_team_change_contact_address_to_existing_address(self):
> +        # Test that a team can change the contact address.

Ok!

> +        someone_email = "someone@xxxxxxxxxxxxx"
> +        someone = self.factory.makePerson(
> +            displayname="Unicode Person \xc9", email=someone_email)
> +        someone_url = canonical_url(someone)
> +        team = self.factory.makeTeam(email="team@xxxxxxxxxxxxx")
> +        with admin_logged_in():
> +            form = {
> +                'field.contact_method': 'EXTERNAL_ADDRESS',
> +                'field.contact_address': 'someone@xxxxxxxxxxxxx',
> +                'field.actions.change': 'Change',
> +            }
> +            view = create_initialized_view(team, '+contactaddress', form=form)
> +            expected_msg = (
> +                '%s is already registered in Launchpad and is associated '
> +                'with <a href="%s">Unicode Person \xc9</a>.')
> +            expected_msg %= (someone_email, someone_url)
> +            self.assertEqual([expected_msg], view.errors)


-- 
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/395036
Your team Launchpad code reviewers is subscribed to branch ~pappacena/launchpad:bugfix-email-change-error-msg-1907173.


References