launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06858
[Merge] lp:~rvb/maas/maas-edit-node-owner into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/maas-edit-node-owner into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rvb/maas/maas-edit-node-owner/+merge/98887
Owner should not be required on the "Edit node" page.
--
https://code.launchpad.net/~rvb/maas/maas-edit-node-owner/+merge/98887
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/maas-edit-node-owner into lp:maas.
=== modified file 'src/maasserver/forms.py'
--- src/maasserver/forms.py 2012-03-22 16:32:50 +0000
+++ src/maasserver/forms.py 2012-03-22 17:36:24 +0000
@@ -98,7 +98,8 @@
class UIAdminNodeEditForm(ModelForm):
after_commissioning_action = forms.ChoiceField(
choices=NODE_AFTER_COMMISSIONING_ACTION_CHOICES)
- owner = forms.ModelChoiceField(queryset=UserProfile.objects.all_users())
+ owner = forms.ModelChoiceField(
+ queryset=UserProfile.objects.all_users(), required=False)
class Meta:
model = Node
=== modified file 'src/maasserver/tests/test_forms.py'
--- src/maasserver/tests/test_forms.py 2012-03-22 14:12:17 +0000
+++ src/maasserver/tests/test_forms.py 2012-03-22 17:36:24 +0000
@@ -222,6 +222,27 @@
self.assertEqual(power_type, node.power_type)
self.assertEqual(owner, node.owner)
+ def test_UIAdminNodeEditForm_changes_node_empty_owner(self):
+ node = factory.make_node()
+ hostname = factory.getRandomString()
+ after_commissioning_action = factory.getRandomChoice(
+ NODE_AFTER_COMMISSIONING_ACTION_CHOICES)
+ power_type = factory.getRandomChoice(POWER_TYPE_CHOICES)
+ form = UIAdminNodeEditForm(
+ data={
+ 'hostname': hostname,
+ 'after_commissioning_action': after_commissioning_action,
+ 'power_type': power_type,
+ },
+ instance=node)
+ form.save()
+
+ self.assertEqual(hostname, node.hostname)
+ self.assertEqual(
+ after_commissioning_action, node.after_commissioning_action)
+ self.assertEqual(power_type, node.power_type)
+ self.assertEqual(None, node.owner)
+
def test_UIAdminNodeEditForm_owner_choices_contains_active_users(self):
form = UIAdminNodeEditForm()
user = factory.make_user()