Merge lp:~sinzui/launchpad/ml-moderate-view-0 into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 11964
Proposed branch: lp:~sinzui/launchpad/ml-moderate-view-0
Merge into: lp:launchpad
Diff against target: 58 lines (+21/-3)
2 files modified
lib/lp/registry/browser/team.py (+4/-2)
lib/lp/registry/browser/tests/test_team.py (+17/-1)
To merge this branch: bzr merge lp:~sinzui/launchpad/ml-moderate-view-0
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+41548@code.launchpad.net

Description of the change

This is my branch to redirect users from the mailing list moderation view.

    lp:~sinzui/launchpad/ml-moderate-view-0
    Diff size: 60
    Launchpad bug: https://bugs.launchpad.net/bugs/680009
    Test command: ./bin/test -vv \
        -t TestModeration -t stories/mailinglists/moderation
    Pre-implementation: no one
    Target release: 10.12

Redirect users from the mailing list moderation view
-----------------------------------------------------

The user hacked the url to access the +mailinglist-moderate view. I think we
want to replace the assert in TeamMailingListModerationView with a redirect to
the team page and add a notification to explain the team does not have a
mailing list.

Rules
-----

    * Like the +contact-user page, the view should issue a redirect and
      notification to explain why the page is not available.

QA
--

    * Visit https://launchpad.net/~elementaryos/+mailinglist-moderate
    * Verify you are redirected to https://launchpad.net/~elementaryos
    * Verify there is a notification stating that ~elementaryos does not
      have a mailing list.

Lint
----

Linting changed files:
  lib/lp/registry/browser/team.py
  lib/lp/registry/browser/tests/test_team.py

Implementation
--------------

Replaced the assert with a guard. Issue a notification and a redirect when
there is no mailing list.
    lib/lp/registry/browser/team.py
    lib/lp/registry/browser/tests/test_team.py

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

JFDI

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/registry/browser/team.py'
--- lib/lp/registry/browser/team.py 2010-11-11 21:30:09 +0000
+++ lib/lp/registry/browser/team.py 2010-11-23 04:57:01 +0000
@@ -801,8 +801,10 @@
801 super(TeamMailingListModerationView, self).__init__(context, request)801 super(TeamMailingListModerationView, self).__init__(context, request)
802 list_set = getUtility(IMailingListSet)802 list_set = getUtility(IMailingListSet)
803 self.mailing_list = list_set.get(self.context.name)803 self.mailing_list = list_set.get(self.context.name)
804 assert(self.mailing_list is not None), (804 if self.mailing_list is None:
805 'No mailing list: %s' % self.context.name)805 self.request.response.addInfoNotification(
806 '%s does not have a mailing list.' % self.context.displayname)
807 return self.request.response.redirect(canonical_url(self.context))
806808
807 @cachedproperty809 @cachedproperty
808 def hold_count(self):810 def hold_count(self):
809811
=== modified file 'lib/lp/registry/browser/tests/test_team.py'
--- lib/lp/registry/browser/tests/test_team.py 2010-11-11 22:43:01 +0000
+++ lib/lp/registry/browser/tests/test_team.py 2010-11-23 04:57:01 +0000
@@ -3,6 +3,7 @@
33
4__metaclass__ = type4__metaclass__ = type
55
6from canonical.launchpad.webapp.publisher import canonical_url
6from canonical.testing.layers import DatabaseFunctionalLayer7from canonical.testing.layers import DatabaseFunctionalLayer
7from lp.registry.browser.person import TeamOverviewMenu8from lp.registry.browser.person import TeamOverviewMenu
8from lp.testing import (9from lp.testing import (
@@ -12,7 +13,10 @@
12 )13 )
13from lp.testing.matchers import IsConfiguredBatchNavigator14from lp.testing.matchers import IsConfiguredBatchNavigator
14from lp.testing.menu import check_menu_links15from lp.testing.menu import check_menu_links
15from lp.testing.views import create_initialized_view16from lp.testing.views import (
17 create_initialized_view,
18 create_view,
19 )
1620
1721
18class TestTeamMenu(TestCaseWithFactory):22class TestTeamMenu(TestCaseWithFactory):
@@ -55,6 +59,18 @@
55 view.held_messages,59 view.held_messages,
56 IsConfiguredBatchNavigator('message', 'messages'))60 IsConfiguredBatchNavigator('message', 'messages'))
5761
62 def test_no_mailing_list_redirect(self):
63 team = self.factory.makeTeam()
64 login_person(team.teamowner)
65 view = create_view(team, name='+mailinglist-moderate')
66 response = view.request.response
67 self.assertEqual(302, response.getStatus())
68 self.assertEqual(canonical_url(team), response.getHeader('location'))
69 self.assertEqual(1, len(response.notifications))
70 self.assertEqual(
71 '%s does not have a mailing list.' % (team.displayname),
72 response.notifications[0].message)
73
5874
59class TestTeamMemberAddView(TestCaseWithFactory):75class TestTeamMemberAddView(TestCaseWithFactory):
6076