Merge lp:~newell-jensen/maas/bulk-node-actions-messages-bug-1387968 into lp:~maas-committers/maas/trunk

Proposed by Newell Jensen
Status: Merged
Approved by: Newell Jensen
Approved revision: no longer in the source branch.
Merged at revision: 3327
Proposed branch: lp:~newell-jensen/maas/bulk-node-actions-messages-bug-1387968
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 53 lines (+10/-6)
2 files modified
src/maasserver/views/nodes.py (+5/-4)
src/maasserver/views/tests/test_nodes.py (+5/-2)
To merge this branch: bzr merge lp:~newell-jensen/maas/bulk-node-actions-messages-bug-1387968
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+240217@code.launchpad.net

Commit message

This branch gives the bulk node action message(s) the correct color for the given message(s).

Description of the change

Currently, some action messages should be yellow for warnings or red for errors, but instead are blue. This branch takes the highest severity (precedence) out of all the concatenated messages and uses this color. If we were going to make it so each message was going to have its own color instead of concatenating the messages as `message_from_form_stats` currently does, we would need to have specific node information (such as hostnames), to distinguish them, instead of just the number of nodes as how it is done now. If further distinguishing is desired, this branch could potentially be modified to do that.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

No tests?

Also the commit message is a little long. I would give exactly what this does or fixes. Explaining the better way in the description.

review: Needs Fixing
Revision history for this message
Newell Jensen (newell-jensen) wrote :

No new separate test but I did update a test that was already there for the
functionality that I introduced.

On Mon, Nov 3, 2014 at 10:44 AM, Blake Rouse <email address hidden>
wrote:

> Review: Needs Fixing
>
> No tests?
>
> Also the commit message is a little long. I would give exactly what this
> does or fixes. Explaining the better way in the description.
> --
>
> https://code.launchpad.net/~newell-jensen/maas/bulk-node-actions-messages-bug-1387968/+merge/240217
> You are the owner of
> lp:~newell-jensen/maas/bulk-node-actions-messages-bug-1387968.
>

Revision history for this message
Blake Rouse (blake-rouse) wrote :

Okay. Looks good.

review: Approve
Revision history for this message
Julian Edwards (julian-edwards) wrote :

On Monday 03 November 2014 18:44:02 you wrote:
> Also the commit message is a little long.

There is no such thing as a commit message that is too long, we're not using
CVS. This format is fine:

"""
Short sentence describing overall change.

Longer sentence
possibly going over
multiple lines to
explain why this change
is needed.
"""

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/views/nodes.py'
--- src/maasserver/views/nodes.py 2014-10-24 23:45:33 +0000
+++ src/maasserver/views/nodes.py 2014-10-31 07:22:03 +0000
@@ -146,7 +146,7 @@
146 (not_actionable, not_actionable_templates),146 (not_actionable, not_actionable_templates),
147 (not_permitted, not_permitted_templates)]147 (not_permitted, not_permitted_templates)]
148 message = []148 message = []
149 for number, message_templates in number_message:149 for index, (number, message_templates) in enumerate(number_message):
150 singular, plural = message_templates150 singular, plural = message_templates
151 if number != 0:151 if number != 0:
152 message_template = singular if number == 1 else plural152 message_template = singular if number == 1 else plural
@@ -154,7 +154,8 @@
154 # Override the action name so that only the first sentence will154 # Override the action name so that only the first sentence will
155 # contain the full name of the action.155 # contain the full name of the action.
156 action_name = 'It'156 action_name = 'It'
157 return ' '.join(message)157 level = index
158 return ' '.join(message), ('info', 'warning', 'error')[level]
158159
159160
160def prefetch_nodes_listing(nodes_query):161def prefetch_nodes_listing(nodes_query):
@@ -293,8 +294,8 @@
293 action_class = SetZoneBulkAction294 action_class = SetZoneBulkAction
294 else:295 else:
295 action_class = ACTIONS_DICT[form.cleaned_data['action']]296 action_class = ACTIONS_DICT[form.cleaned_data['action']]
296 message = message_from_form_stats(action_class, *stats)297 message, level = message_from_form_stats(action_class, *stats)
297 messages.info(self.request, message)298 getattr(messages, level)(self.request, message)
298 return super(NodeListView, self).form_valid(form)299 return super(NodeListView, self).form_valid(form)
299300
300 def _compose_sort_order(self):301 def _compose_sort_order(self):
301302
=== modified file 'src/maasserver/views/tests/test_nodes.py'
--- src/maasserver/views/tests/test_nodes.py 2014-10-29 04:34:42 +0000
+++ src/maasserver/views/tests/test_nodes.py 2014-10-31 07:22:03 +0000
@@ -1827,10 +1827,13 @@
1827 % Delete.display_bulk,),1827 % Delete.display_bulk,),
1828 ),1828 ),
1829 ]1829 ]
1830 for params, snippets in params_and_snippets:1830 # level precedence is worst-case for the concantenation of messages
1831 message = message_from_form_stats(*params)1831 levels = ['error', 'info', 'error', 'error']
1832 for index, (params, snippets) in enumerate(params_and_snippets):
1833 message, level = message_from_form_stats(*params)
1832 for snippet in snippets:1834 for snippet in snippets:
1833 self.assertIn(snippet, message)1835 self.assertIn(snippet, message)
1836 self.assertEqual(level, levels[index])
18341837
18351838
1836class NodeEnlistmentPreseedViewTest(MAASServerTestCase):1839class NodeEnlistmentPreseedViewTest(MAASServerTestCase):