launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #02336
[Merge] lp:~allenap/launchpad/sub-search-ui-bug-656823-6 into lp:launchpad
Gavin Panella has proposed merging lp:~allenap/launchpad/sub-search-ui-bug-656823-6 into lp:launchpad with lp:~allenap/launchpad/sub-search-ui-bug-656823-5 as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~allenap/launchpad/sub-search-ui-bug-656823-6/+merge/46246
UI to delete a bug subscription filter.
I've added a delete button to the +edit form, and refactored the *EditView and *CreateView classes to share a common base class. Previously *CreateView inherited from *EditView.
--
https://code.launchpad.net/~allenap/launchpad/sub-search-ui-bug-656823-6/+merge/46246
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/launchpad/sub-search-ui-bug-656823-6 into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugsubscriptionfilter.py'
--- lib/lp/bugs/browser/bugsubscriptionfilter.py 2011-01-14 10:37:07 +0000
+++ lib/lp/bugs/browser/bugsubscriptionfilter.py 2011-01-14 10:37:08 +0000
@@ -74,10 +74,9 @@
return conditions
-class BugSubscriptionFilterEditView(LaunchpadEditFormView):
- """Edit view for `IBugSubscriptionFilter`."""
+class BugSubscriptionFilterEditViewBase(LaunchpadEditFormView):
+ """Base class for edit or create views of `IBugSubscriptionFilter`."""
- page_title = u"Edit filter"
schema = IBugSubscriptionFilter
field_names = (
"description",
@@ -92,11 +91,6 @@
custom_widget("importances", LabeledMultiCheckBoxWidget)
custom_widget("tags", BugTagsFrozenSetWidget, displayWidth=35)
- @action("Update", name="update")
- def update_action(self, action, data):
- """Update the bug filter with the form data."""
- self.updateContextFromData(data)
-
@property
def next_url(self):
"""Return to the user's structural subscriptions page."""
@@ -106,7 +100,32 @@
cancel_url = next_url
-class BugSubscriptionFilterCreateView(BugSubscriptionFilterEditView):
+class BugSubscriptionFilterEditView(
+ BugSubscriptionFilterEditViewBase):
+ """Edit view for `IBugSubscriptionFilter`.
+
+ :ivar context: A provider of `IBugSubscriptionFilter`.
+ """
+
+ page_title = u"Edit filter"
+
+ @action("Update", name="update")
+ def update_action(self, action, data):
+ """Update the bug filter with the form data."""
+ self.updateContextFromData(data)
+
+ @action("Delete", name="delete")
+ def delete_action(self, action, data):
+ """Delete the bug filter."""
+ self.context.delete()
+
+
+class BugSubscriptionFilterCreateView(
+ BugSubscriptionFilterEditViewBase):
+ """View to create a new `IBugSubscriptionFilter`.
+
+ :ivar context: A provider of `IStructuralSubscription`.
+ """
page_title = u"Create new filter"
=== modified file 'lib/lp/bugs/browser/tests/test_bugsubscriptionfilter.py'
--- lib/lp/bugs/browser/tests/test_bugsubscriptionfilter.py 2011-01-14 10:37:07 +0000
+++ lib/lp/bugs/browser/tests/test_bugsubscriptionfilter.py 2011-01-14 10:37:08 +0000
@@ -422,6 +422,18 @@
self.assertTrue(
self.subscription_filter.find_all_tags)
+ def test_delete(self):
+ # The filter can be deleted by using the delete action.
+ form = {
+ "field.actions.delete": "Delete",
+ }
+ with person_logged_in(self.owner):
+ view = create_initialized_view(
+ self.subscription_filter, name="+edit", form=form)
+ self.assertEqual([], view.errors)
+ # The subscription filter has been deleted.
+ self.assertEqual([], list(self.subscription.bug_filters))
+
class TestBugSubscriptionFilterCreateView(TestCaseWithFactory):