Merge lp:~sinzui/launchpad/list-urls-bug-463444 into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Approved by: Guilherme Salgado
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~sinzui/launchpad/list-urls-bug-463444
Merge into: lp:launchpad
Diff against target: 209 lines
2 files modified
lib/canonical/launchpad/emailtemplates/team-list-subscribe-block.txt (+1/-1)
lib/canonical/launchpad/mailnotification.py (+33/-27)
To merge this branch: bzr merge lp:~sinzui/launchpad/list-urls-bug-463444
Reviewer Review Type Date Requested Status
Guilherme Salgado (community) code Approve
Review via email: mp+14186@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

This is my branch to fix team join emails have bad mailing list url.

    lp:~sinzui/launchpad/list-urls-bug-463444
    Diff size: 35
    Launchpad bug: https://bugs.launchpad.net/bugs/463444
    Test command: ./bin/test -vv -t teammembership-email-notification
    Pre-implementation: no one
    Target release: 3.1.10

= Fix team join emails have bad mailing list url =

The URL provided for subscribing to team emails is a launchpad.dev email.

== Rules ==

emailtemplates/team-list-subscribe-block has the server hard coded
teammembership-email-notification.txt will always pass.

    * Change the email template to use a %(editemails_url)s
      * Watch the test fail.
    * Add code to interpolar "+editemails" % canonical_url(person)
      * Watch the test pass.

== QA ==

    * Open the staging mailbox and mark all email read.
    * Add someone to your team on staging.
    * Update the mailbox and read the email to the new member.
    * Verify that the email's edit URL is:
      https://staging.launchpad.net/people/+me/+editemails

== Lint ==

Linting changed files:
  lib/canonical/launchpad/mailnotification.py
  lib/canonical/launchpad/emailtemplates/team-list-subscribe-block.txt

== Test ==

lp/registry/doc/teammembership-email-notification.txt did not change because
it was already testing for the correct result. The email template was
hard coded to always return the correct URL.

The test failed when the substitution variable was added. It passed after
a few trials make the URL from ILaunchpadRoot.

== Implementation ==

    * lib/canonical/launchpad/emailtemplates/team-list-subscribe-block.txt
      * Replaced the hard coded URL with a substiution variable.
    * lib/canonical/launchpad/mailnotification.py
      * Updated the code to create a URL from ILaunchpadRoot and to
        interpolate that into the team-list-subscribe-block text.

Revision history for this message
Guilherme Salgado (salgado) wrote :

This looks good, but you could use webapp.urlappend() to construct the URL to the +editemails page.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/emailtemplates/team-list-subscribe-block.txt'
--- lib/canonical/launchpad/emailtemplates/team-list-subscribe-block.txt 2009-08-24 03:53:19 +0000
+++ lib/canonical/launchpad/emailtemplates/team-list-subscribe-block.txt 2009-10-30 13:10:25 +0000
@@ -1,4 +1,4 @@
11
2If you would like to subscribe to the team list, use the link below2If you would like to subscribe to the team list, use the link below
3to update your Mailing List Subscription preferences.3to update your Mailing List Subscription preferences.
4 <http://launchpad.dev/people/+me/+editemails>4 <%(editemails_url)s>
55
=== modified file 'lib/canonical/launchpad/mailnotification.py'
--- lib/canonical/launchpad/mailnotification.py 2009-08-24 03:53:19 +0000
+++ lib/canonical/launchpad/mailnotification.py 2009-10-30 13:10:25 +0000
@@ -36,6 +36,7 @@
36 IStructuralSubscriptionTarget, ITeamMembershipSet, IUpstreamBugTask,36 IStructuralSubscriptionTarget, ITeamMembershipSet, IUpstreamBugTask,
37 TeamMembershipStatus)37 TeamMembershipStatus)
38from lp.bugs.interfaces.bugchange import IBugChange38from lp.bugs.interfaces.bugchange import IBugChange
39from canonical.launchpad.interfaces.launchpad import ILaunchpadRoot
39from canonical.launchpad.interfaces.message import (40from canonical.launchpad.interfaces.message import (
40 IDirectEmailAuthorization, QuotaReachedError)41 IDirectEmailAuthorization, QuotaReachedError)
41from canonical.launchpad.interfaces.structuralsubscription import (42from canonical.launchpad.interfaces.structuralsubscription import (
@@ -45,7 +46,8 @@
45from lp.services.mail.mailwrapper import MailWrapper46from lp.services.mail.mailwrapper import MailWrapper
46from lp.services.mail.notificationrecipientset import (47from lp.services.mail.notificationrecipientset import (
47 NotificationRecipientSet)48 NotificationRecipientSet)
48from canonical.launchpad.webapp import canonical_url49from canonical.launchpad.webapp.publisher import canonical_url
50from canonical.launchpad.webapp.url import urlappend
4951
5052
51CC = "CC"53CC = "CC"
@@ -74,6 +76,7 @@
74 IBug.getBugNotificationRecipients().76 IBug.getBugNotificationRecipients().
75 """77 """
76 implements(INotificationRecipientSet)78 implements(INotificationRecipientSet)
79
77 def __init__(self, duplicateof=None):80 def __init__(self, duplicateof=None):
78 """Constructs a new BugNotificationRecipients instance.81 """Constructs a new BugNotificationRecipients instance.
7982
@@ -191,7 +194,7 @@
191194
192def format_rfc2822_date(date):195def format_rfc2822_date(date):
193 """Formats a date according to RFC2822's desires."""196 """Formats a date according to RFC2822's desires."""
194 return formatdate(rfc822.mktime_tz(date.utctimetuple() + (0,)))197 return formatdate(rfc822.mktime_tz(date.utctimetuple() + (0, )))
195198
196199
197class BugNotificationBuilder:200class BugNotificationBuilder:
@@ -461,8 +464,7 @@
461 get_bugmail_error_address(), [config.launchpad.errors_address],464 get_bugmail_error_address(), [config.launchpad.errors_address],
462 'Unhandled Email: %s' % file_alias_url,465 'Unhandled Email: %s' % file_alias_url,
463 template % {'url': file_alias_url, 'error_msg': message},466 template % {'url': file_alias_url, 'error_msg': message},
464 headers={'X-Launchpad-Unhandled-Email': message}467 headers={'X-Launchpad-Unhandled-Email': message})
465 )
466468
467469
468def generate_bug_add_email(bug, new_recipients=False, reason=None,470def generate_bug_add_email(bug, new_recipients=False, reason=None,
@@ -505,12 +507,12 @@
505507
506 mailwrapper = MailWrapper(width=72)508 mailwrapper = MailWrapper(width=72)
507 content_substitutions = {509 content_substitutions = {
508 'visibility' : visibility,510 'visibility': visibility,
509 'bug_url' : canonical_url(bug),511 'bug_url': canonical_url(bug),
510 'bug_info': "\n".join(bug_info),512 'bug_info': "\n".join(bug_info),
511 'bug_title': bug.title,513 'bug_title': bug.title,
512 'description': mailwrapper.format(bug.description),514 'description': mailwrapper.format(bug.description),
513 'notification_rationale': reason515 'notification_rationale': reason,
514 }516 }
515517
516 if new_recipients:518 if new_recipients:
@@ -571,13 +573,11 @@
571 # which begin with '?'.573 # which begin with '?'.
572 text_diff = [574 text_diff = [
573 diff_line for diff_line in text_diff575 diff_line for diff_line in text_diff
574 if not diff_line.startswith('?')576 if not diff_line.startswith('?')]
575 ]
576 # Add a whitespace between the +/- and the text line.577 # Add a whitespace between the +/- and the text line.
577 text_diff = [578 text_diff = [
578 re.sub('^([\+\- ])(.*)', r'\1 \2', line)579 re.sub('^([\+\- ])(.*)', r'\1 \2', line)
579 for line in text_diff580 for line in text_diff]
580 ]
581 text_diff = '\n'.join(text_diff)581 text_diff = '\n'.join(text_diff)
582 return text_diff582 return text_diff
583583
@@ -585,9 +585,9 @@
585def _get_task_change_row(label, oldval_display, newval_display):585def _get_task_change_row(label, oldval_display, newval_display):
586 """Return a row formatted for display in task change info."""586 """Return a row formatted for display in task change info."""
587 return u"%(label)13s: %(oldval)s => %(newval)s\n" % {587 return u"%(label)13s: %(oldval)s => %(newval)s\n" % {
588 'label' : label.capitalize(),588 'label': label.capitalize(),
589 'oldval' : oldval_display,589 'oldval': oldval_display,
590 'newval' : newval_display}590 'newval': newval_display}
591591
592592
593def _get_task_change_values(task_change, displayattrname):593def _get_task_change_values(task_change, displayattrname):
@@ -614,7 +614,7 @@
614 """614 """
615 changes = {}615 changes = {}
616616
617 for field_name in ("title", "description", "name", "private",617 for field_name in ("title", "description", "name", "private",
618 "security_related", "duplicateof", "tags"):618 "security_related", "duplicateof", "tags"):
619 # fields for which we show old => new when their values change619 # fields for which we show old => new when their values change
620 old_val = getattr(old_bug, field_name)620 old_val = getattr(old_bug, field_name)
@@ -786,7 +786,7 @@
786 bug=bug,786 bug=bug,
787 bugurl=canonical_url(bug),787 bugurl=canonical_url(bug),
788 user=IPerson(event.user),788 user=IPerson(event.user),
789 attachment={'new' : bugattachment, 'old': None})789 attachment={'new': bugattachment, 'old': None})
790790
791 add_bug_change_notifications(bug_delta)791 add_bug_change_notifications(bug_delta)
792792
@@ -799,7 +799,7 @@
799 bug=bug,799 bug=bug,
800 bugurl=canonical_url(bug),800 bugurl=canonical_url(bug),
801 user=IPerson(event.user),801 user=IPerson(event.user),
802 attachment={'old' : bugattachment, 'new': None})802 attachment={'old': bugattachment, 'new': None})
803803
804 add_bug_change_notifications(bug_delta)804 add_bug_change_notifications(bug_delta)
805805
@@ -908,8 +908,12 @@
908 "You received this email because you are the new member.")908 "You received this email because you are the new member.")
909909
910 if team.mailing_list is not None:910 if team.mailing_list is not None:
911 list_instructions = get_email_template(911 template = get_email_template(
912 'team-list-subscribe-block.txt')912 'team-list-subscribe-block.txt')
913 editemails_url = urlappend(
914 canonical_url(getUtility(ILaunchpadRoot)),
915 'people/+me/+editemails')
916 list_instructions = template % dict(editemails_url=editemails_url)
913 else:917 else:
914 list_instructions = ''918 list_instructions = ''
915919
@@ -990,6 +994,7 @@
990 """Format the email subject line for a specification."""994 """Format the email subject line for a specification."""
991 return '[Blueprint %s] %s' % (spec.name, spec.title)995 return '[Blueprint %s] %s' % (spec.name, spec.title)
992996
997
993@block_implicit_flushes998@block_implicit_flushes
994def notify_specification_modified(spec, event):999def notify_specification_modified(spec, event):
995 """Notify the related people that a specification has been modifed."""1000 """Notify the related people that a specification has been modifed."""
@@ -1061,7 +1066,6 @@
1061 simple_sendmail_from_person(user, address, subject, body)1066 simple_sendmail_from_person(user, address, subject, body)
10621067
10631068
1064
1065@block_implicit_flushes1069@block_implicit_flushes
1066def notify_specification_subscription_created(specsub, event):1070def notify_specification_subscription_created(specsub, event):
1067 """Notify a user that they have been subscribed to a blueprint."""1071 """Notify a user that they have been subscribed to a blueprint."""
@@ -1074,12 +1078,13 @@
1074 'You are now subscribed to the blueprint '1078 'You are now subscribed to the blueprint '
1075 '%(blueprint_name)s - %(blueprint_title)s.\n\n'1079 '%(blueprint_name)s - %(blueprint_title)s.\n\n'
1076 '--\n %(blueprint_url)s' %1080 '--\n %(blueprint_url)s' %
1077 {'blueprint_name' : spec.name,1081 {'blueprint_name': spec.name,
1078 'blueprint_title' : spec.title,1082 'blueprint_title': spec.title,
1079 'blueprint_url' : canonical_url(spec)})1083 'blueprint_url': canonical_url(spec)})
1080 for address in get_contact_email_addresses(person):1084 for address in get_contact_email_addresses(person):
1081 simple_sendmail_from_person(user, address, subject, body)1085 simple_sendmail_from_person(user, address, subject, body)
10821086
1087
1083@block_implicit_flushes1088@block_implicit_flushes
1084def notify_specification_subscription_modified(specsub, event):1089def notify_specification_subscription_modified(specsub, event):
1085 """Notify a subscriber to a blueprint that their1090 """Notify a subscriber to a blueprint that their
@@ -1103,10 +1108,10 @@
1103 '%(blueprint_name)s - %(blueprint_title)s '1108 '%(blueprint_name)s - %(blueprint_title)s '
1104 'has changed to [%(specsub_type)s].\n\n'1109 'has changed to [%(specsub_type)s].\n\n'
1105 '--\n %(blueprint_url)s' %1110 '--\n %(blueprint_url)s' %
1106 {'blueprint_name' : spec.name,1111 {'blueprint_name': spec.name,
1107 'blueprint_title' : spec.title,1112 'blueprint_title': spec.title,
1108 'specsub_type' : specsub_type,1113 'specsub_type': specsub_type,
1109 'blueprint_url' : canonical_url(spec)})1114 'blueprint_url': canonical_url(spec)})
1110 for address in get_contact_email_addresses(person):1115 for address in get_contact_email_addresses(person):
1111 simple_sendmail_from_person(user, address, subject, body)1116 simple_sendmail_from_person(user, address, subject, body)
11121117
@@ -1184,6 +1189,7 @@
1184 template % replacements, force_wrap=True)1189 template % replacements, force_wrap=True)
1185 simple_sendmail(from_address, address, subject, body)1190 simple_sendmail(from_address, address, subject, body)
11861191
1192
1187@block_implicit_flushes1193@block_implicit_flushes
1188def notify_new_ppa_subscription(subscription, event):1194def notify_new_ppa_subscription(subscription, event):
1189 """Notification that a new PPA subscription can be activated."""1195 """Notification that a new PPA subscription can be activated."""
@@ -1290,7 +1296,7 @@
1290 u'',1296 u'',
1291 u'-- ',1297 u'-- ',
1292 u'This message was sent from Launchpad by the user',1298 u'This message was sent from Launchpad by the user',
1293 u'%s (%s)' % (sender_name , canonical_url(sender)),1299 u'%s (%s)' % (sender_name, canonical_url(sender)),
1294 u'using %s.',1300 u'using %s.',
1295 u'For more information see',1301 u'For more information see',
1296 u'https://help.launchpad.net/YourAccount/ContactingPeople',1302 u'https://help.launchpad.net/YourAccount/ContactingPeople',