launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #14775
[Merge] lp:~jcsackett/launchpad/no-releases-for-projectmilestone into lp:launchpad
j.c.sackett has proposed merging lp:~jcsackett/launchpad/no-releases-for-projectmilestone into lp:launchpad.
Commit message:
Fixes milestone views to handle projectmilestonetags, which don't have a product_release attr.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1087274 in Launchpad itself: "ProjectGroupMilestoneTag:+index ForbiddenAttribute: product_release"
https://bugs.launchpad.net/launchpad/+bug/1087274
For more details, see:
https://code.launchpad.net/~jcsackett/launchpad/no-releases-for-projectmilestone/+merge/139221
Summary
=======
ProjectMilestoneTags do not have a product_release attr, but the view assumes
the context will always have this if they are of type IMilestoneData. This
leads to an OOPS.
The view should simply set the release data to None if the attribute doesn't
exist, and shouldn't assume the attribute does exist.
Preimp
======
None.
Implementation
==============
The assignment of `self.release = context.product_release` has been replaced
with an assignment to the result of getattr on the context, defaulting to None
if the atter doesn't exist.
Tests
=====
bin/test -vvct test_projectgroup_milestone
QA
==
Load the url in the OOPS; it should load.
LoC
===
Part of private projects.
Lint
====
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/registry/browser/milestone.py
lib/lp/registry/browser/tests/test_milestonetag.py
--
https://code.launchpad.net/~jcsackett/launchpad/no-releases-for-projectmilestone/+merge/139221
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jcsackett/launchpad/no-releases-for-projectmilestone into lp:launchpad.
=== modified file 'lib/lp/registry/browser/milestone.py'
--- lib/lp/registry/browser/milestone.py 2012-10-19 03:01:32 +0000
+++ lib/lp/registry/browser/milestone.py 2012-12-11 15:04:59 +0000
@@ -377,7 +377,7 @@
super(MilestoneView, self).__init__(context, request)
if IMilestoneData.providedBy(context):
self.milestone = context
- self.release = context.product_release
+ self.release = getattr(context, "product_release", None)
else:
self.milestone = context.milestone
self.release = context
=== added file 'lib/lp/registry/browser/tests/test_milestonetag.py'
--- lib/lp/registry/browser/tests/test_milestonetag.py 1970-01-01 00:00:00 +0000
+++ lib/lp/registry/browser/tests/test_milestonetag.py 2012-12-11 15:04:59 +0000
@@ -0,0 +1,22 @@
+# Copyright 2012 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Test projectmilestone tag views."""
+
+__metaclass__ = type
+
+from lp.services.webapp import canonical_url
+from lp.testing import TestCaseWithFactory
+from lp.testing.layers import DatabaseFunctionalLayer
+
+
+class TestProjectMilestoneTagView(TestCaseWithFactory):
+
+ layer = DatabaseFunctionalLayer
+
+ def test_projectgroup_milestone(self):
+ # The projectgroup milestone tag page loads without errors.
+ group = self.factory.makeProject()
+ url = canonical_url(group) + "/+tags/fab/+index"
+ browser = self.getUserBrowser(url=url)
+ self.assertTrue('fab' in browser.contents)