Merge lp:~adiroiban/launchpad/bug-61081 into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Michael Nelson on 2010-04-23 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | not available |
| Proposed branch: | lp:~adiroiban/launchpad/bug-61081 |
| Merge into: | lp:launchpad |
| Diff against target: |
96 lines (+48/-1) 2 files modified
lib/lp/translations/browser/potemplate.py (+17/-0) lib/lp/translations/stories/standalone/xx-potemplate-edit.txt (+31/-1) |
| To merge this branch: | bzr merge lp:~adiroiban/launchpad/bug-61081 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Michael Nelson (community) | code ui | 2010-04-21 | Approve on 2010-04-23 |
|
Review via email:
|
|||
Commit Message
Check that on potemplate updates, the priority value is in a certain range.
Description of the Change
= Bug 61081 =
Entering a big priority value in POTemplate +edit pages generates and OOPS
== Proposed fix ==
Validate priority value to be in a certain range (0..100000 suggested by Danilo).
== Pre-implementation notes ==
15:16 danilos : adiroiban, fyi, on staging: http://
15:19 adiroiban : danilos: shoud I use those limits? Maybe -100 ... 5000000 ?
15:20 danilos : adiroiban, there is only one potemplate (pyroom) that has this priority, all the others are lower than 10k
15:20 danilos : adiroiban, as for negative ones, that sounds wrong and we should probably just reset them
15:21 danilos : adiroiban, 6 templates have negative priorities
15:23 adiroiban : danilos: what values do you suggest for the priority range?
15:23 danilos : adiroiban, I guess 0-100000 (i.e. 10x10000 to leave some room there)
15:24 adiroiban : danilos: ok. we can reset the values... but I suppose that user will be warned when the want to update
15:26 adiroiban : danilos: is there anything on this bug that is worth mentioning or it is ready to code or I should just
15:26 danilos : adiroiban, yeah, we can notify them as well
15:26 danilos : adiroiban, no, it should be ready to code; I'll add a comment to the bug explaining my "findings"
== Implementation details ==
I ried writing a LaunchpadZopele
potemplate = factory.
view = POTemplateEditV
view.initialize()
ComponentLookup
Also, any hints regarding the 'make lint' import errors is much appreciated.
== Tests ==
lp-tt potemplate-edit
== Demo and Q/A ==
Login as admin and go to:
1. http://
2. Fill in 'Priority': 999999999999 or -21
3. Click 'Change'
4. You should see an error message telling you that the priority value should be in a specific range.
Same steps for
http://
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files:
lib/lp/
lib/lp/
== Pylint notices ==
lib/lp/
37: [F0401] Unable to import 'canonical.
39: [F0401] Unable to import 'canonical.
40: [F0401] Unable to import 'canonical.
41: [F0401] Unable to import 'canonical.
42: [F0401] Unable to import 'lp.translation
43: [F0401] Unable to import 'lp.registry.
44: [F0401] Unable to import 'lp.translation
45: [F0401] Unable to import 'lp.registry.
46: [F0401] Unable to import 'lp.registry.
47: [F0401] Unable to import 'lp.registry.
48: [F0401] Unable to import 'lp.translation
49: [F0401] Unable to import 'lp.translation
53: [F0401] Unable to import 'lp.translation
55: [F0401] Unable to import 'lp.translation
57: [F0401] Unable to import 'canonical.
61: [F0401] Unable to import 'canonical.
62: [F0401] Unable to import 'canonical.
63: [F0401] Unable to import 'canonical.
64: [F0401] Unable to import 'canonical.
245: [F0401, POTemplateView.
594: [E1002, POTemplateAdmin
| Michael Nelson (michael.nelson) wrote : | # |
Oh, and from a UI-point-of-view, I think you need to add an error for the field itself, rather than for the Launchpad form, so that the error is displayed in context, rather than at the top of the screen.
| Adi Roiban (adiroiban) wrote : | # |
Hi and many thanks for the review!
I have added a field error and change the message into a sentence.
Here is the latest diff:
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -1,5 +1,6 @@
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
+# pylint: disable-msg=F0401
"""Browser code for PO templates."""
@@ -547,8 +548,9 @@
if (priority < self.PRIORITY_
- self.addError(
- "Priority value must be between %s and %s" % (
+ self.setFieldError(
+ 'priority',
+ 'The priority value must be between %s and %s.' % (
return
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -145,8 +145,8 @@
Priority range
--------------
-Priority value must be between 0 and 100000. When entering a priority that is
-not in this range the form validation will inform users about what values
+The priority value must be between 0 and 100000. When entering a priority that
+is not in this range the form validation will inform users about what values
are accepted for the priority field.
>>> admin_browser.open(
@@ -157,9 +157,9 @@
>>> print browser.url
http://
- >>> print_errors(
+ >>> print_feedback_
There is 1 error.
- Priority value must be between ...
+ The priority value must be between ...
>>> admin_browser.open(
... 'http://
@@ -169,9 +169,9 @@
>>> print browser.url
http://
- >>> print_errors(
+ >>> print_feedback_
There is 1 error.
- Priority value must be between ...
+ The priority value must be between ...
Change and cancel actions
------

> == Implementation details == ssLayer test but I was not able to get a proper view. I have no idea why POTemplateEditView is giving this error. makePOTemplate( ) iew(potemplate, LaunchpadTestRe quest() ) Error: ((<zope. schema. _field. Choice object at 0xd9ae5ec>, <canonical. launchpad. webapp. servers. LaunchpadTestRe quest instance URL=http:// 127.0.0. 1>), <InterfaceClass zope.app. form.interfaces .IInputWidget> , u'')
>
> I ried writing a LaunchpadZopele
>
> potemplate = factory.
> view = POTemplateEditV
> view.initialize()
> ComponentLookup
>
> Also, any hints regarding the 'make lint' import errors is much appreciated.
Grepping for F0401 in the code shows that it's disabled for many files - I assume it's safe to do so here too. Not sure about the component lookup error though - reproduced it in a harness, but didn't spend too much time investigating since you've written the test anyway.
> launchpad. dev/products/ evolution/ trunk/+ pots/evolution- 2.2/+edit
> == Tests ==
>
> lp-tt potemplate-edit
>
> == Demo and Q/A ==
> Login as admin and go to:
> 1. http://
ah, missed the translations. launchpad. .. got it now :)
> 2. Fill in 'Priority': 999999999999 or -21 launchpad. dev/products/ evolution/ trunk/+ pots/evolution- 2.2/+admin
> 3. Click 'Change'
> 4. You should see an error message telling you that the priority value should be in a specific range.
>
> Same steps for
> http://
Great, my only suggestion would be a minor modification to the error message, see below.
> self.addError(
> "Priority value must be between %s and %s" % (
Just to turn it into a sentence, add 'The' and '.', eg "The priority value must be between %s and %s."
Thanks!