Merge lp:~rvb/maas/bug-1287310 into lp:~maas-committers/maas/trunk
Proposed by
Raphaël Badin
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Raphaël Badin | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 2135 | ||||
Proposed branch: | lp:~rvb/maas/bug-1287310 | ||||
Merge into: | lp:~maas-committers/maas/trunk | ||||
Diff against target: |
188 lines (+82/-22) 6 files modified
src/maasserver/clusterrpc/power_parameters.py (+5/-0) src/maasserver/clusterrpc/tests/test_power_parameters.py (+5/-0) src/maasserver/forms.py (+1/-1) src/maasserver/forms_settings.py (+1/-21) src/maasserver/utils/forms.py (+37/-0) src/maasserver/utils/tests/test_forms.py (+33/-0) |
||||
To merge this branch: | bzr merge lp:~rvb/maas/bug-1287310 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella (community) | Approve | ||
Review via email: mp+211336@code.launchpad.net |
Commit message
Fix the 'invalid choice' message for JSON-generated field so that the list of valid choices is included in the error message.
Description of the change
Drive-by fixes:
- move the utility compose_
- fix the message generated by compose_
To post a comment you must log in.
Looks good, nice improvement.
[1]
146 + return "'%s' is not a valid %s. It should be one of: %s." % (
147 + "%(value)s",
148 + choice_of_what,
149 + ", ".join("'%s'" % name for name, value in valid_choices),
150 + )
Consider using englist_list() from Launchpad to produce an even better
string of choices. I suspect Django has something similar though.
[2]
148 + choice_of_what,
149 + ", ".join("'%s'" % name for name, value in valid_choices),
150 + )
Is valid_choices sorted?
[3]
146 + return "'%s' is not a valid %s. It should be one of: %s." % (
147 + "%(value)s",
Or double-up the percent symbol:
return "'%%(value)s' is not a valid %s. It should be one of: %s." % (
[4]
182 + choices = [ make_name( 'value' ), factory. make_name( 'key'))
183 + (factory.
184 + for _ in range(2)]
I think value and key are the wrong way round here.