Merge lp:~adiroiban/launchpad/bug-201749 into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Henning Eggers on 2010-04-12 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | not available |
| Proposed branch: | lp:~adiroiban/launchpad/bug-201749 |
| Merge into: | lp:launchpad |
| Diff against target: |
926 lines (+608/-86) 11 files modified
lib/canonical/launchpad/javascript/translations/pofile.js (+119/-18) lib/lp/translations/browser/tests/translationmessage-views.txt (+98/-0) lib/lp/translations/browser/translationmessage.py (+17/-0) lib/lp/translations/interfaces/potmsgset.py (+12/-0) lib/lp/translations/model/potmsgset.py (+41/-13) lib/lp/translations/model/translationmessage.py (+2/-2) lib/lp/translations/stories/standalone/xx-pofile-translate-needs-review-flags-preserved.txt (+62/-3) lib/lp/translations/templates/pofile-translate.pt (+1/-27) lib/lp/translations/templates/translationmessage-translate.pt (+1/-19) lib/lp/translations/tests/test_potmsgset.py (+83/-0) lib/lp/translations/windmill/tests/test_pofile_translate.py (+172/-4) |
| To merge this branch: | bzr merge lp:~adiroiban/launchpad/bug-201749 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Henning Eggers (community) | code | 2010-03-12 | Approve on 2010-03-31 |
|
Review via email:
|
|||
Commit Message
Allow reseting the review state for local suggestions of a potmsgset. Landed by henninge.
Description of the Change
= Bug 201749 =
Take for example this string:
This has been translated by an approved translator, but it's impossibile
to set it with the "Someone should review this translation". I did try a
moment ago, setting it and the filtering with the "need review" filter
in the "Show" drop-down list.
Another example:
I marked with "Someone should..." number 15 and 16 and saved, but they
never show up with the "need review" filter.
== Proposed fix ==
If a reviewer is only ticking „needs review”, or submitting an empty translations together with marking it as „needs review”, reset the review state for the current message so that all suggestions can be viewed.
Submitting a new translation (different than the current one) will add it as a new suggestion and will not reset the reviewed translations.
== Pre-implementation notes ==
The logs are pasted on this bug report
https:/
== Implementation details ==
potmsgset.
translationmess
I am not sure what changes should I make on a potmsgset to be listed again as „needs review”.
The current implementation just updated the date_created ... but maybe there is a better way of doing that without faking the date_created.
== Tests ==
./bin/test -t potmsgset -t translationmessage
== Demo and Q/A ==
Login in launchpad translation as an reviewer (or admin).
Go to a translation, ie:
https:/
Submit a new translation ie „some bla bla”, without ticking the „Someone should review this translation” checkbox.
Press „Save and continue” and you should see that „some bla bla” is the current translation.
Not submit a new translation „other bla bla”, but this time tick „Someone should review this translation”.
The current translation should remain „some bla bla” but you should see „other bla bla” listed as a suggestion.
Tick „Confirm this translation and dismiss all suggestions.”
„some bla bla” should be the current translation, why there will be no suggestions.
Next, tick „Someone should review this translation” but without adding any new translation.
The current translation should be empty, while „some bla bla” and „other bla bla” are listed as suggestions.
Add a new translation „diverged bla bla” without ticking „Someone should review this translation”.
You should see that „diverged bla bla” is the current translation, and for the new suggestion you only have the „Someone should review this translation” option, while „Make this translation specific to Ubuntu hoary” is no longer available.
Reset the translation one again by submitting a new empty translation „” (the empty string) and ticking „Someone should review this translation”.
You should see that current translation is empty, while all previously entered translations are listed as suggestions.
| Данило Шеган (danilo) wrote : | # |
Henning said:
> So, this brings up all old translations? Is that really what we want?
I suggested Adi work in phases: this _might_ be the first step, but the natural next step would be to set the newly set empty message as "date_reviewed = previous_
That's the other option, without making this too complex, but I leave that to the two of you to decide which is better.
| Adi Roiban (adiroiban) wrote : | # |
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Am 12.03.2010 16:42, Adi Roiban schrieb:
> Hi Adi,
> thanks for tackling this. There seem to have been some misunderstanding
> about how this option worked, judging by the comments in the bug.
>
> I am a little concerned about the behaviour. Shouldn't the radio button
> in front of the input box need to be activated (see below)? Also, I am
> not sure if really _all_ old suggestions should be brought up again. But
> that may be OK.
This implementation should reset the current translation as there is no other workaround for the following use case:
https:/
In an ideal world, we would have a "is_reviewed" field for each translation message, a dedicated "reset translation" checkbox and a way to see all previously entered suggestions.
I was thinking there is no need to force a user to add an empty text and mark it as a suggestion and it should be enough to just tick the "needs review" checkbox.
> I also have some other suggestions. Please look at them and we can talk
> again tomorrow.
Many thanks for your review.
Please see my inline comments.
[snip]
> > +Reseting current translation
>
> Resetting ...
Fixed.
> > +------
> > +
> > +The current translation can be resetted by submiting an empty translation
> or
> > +a translation similar to the current one, while forcing the suggestions.
>
> The current translation can be reset by submitting an empty translation
> or a translation similar to the current one while forcing suggestions.
Fixed.
> > +
> > + >>> # We need to force timestamp update, since suggestions are
> submitted
> > + >>> # to fast
>
> Please don't put comments in doc tests. Whatever goes into the comment
> can go into the normal text. It's "too fast", btw. ;)
Done.
> > + >>> year_tick = 2100
> > + >>> def submit_
> > + ... global year_tick
> > + ... translationmessage = TranslationMess
>
> I find this very obscure. I think it would be clearer to pass
> translationmessage as a parameter into the function. If you want "any"
> TranslationMessage object, use the factory outside and pass the object
> into the function.
I was getting the translation message with id 1 to simplify the form submission, since
the form names depend on the id, and also since translation permission were already there.
I have rewritten the code to take a translation message as parameter and only use generated data.
[snip]
> > +
> > +Same happens if we force the submission of a suggestion similar with the
>
> ... similar to the ...
Done.
[snip]
> > + if (force_suggestion and
> > + self.user_
> > + (self._
> > + (translationmessage is not None and
> > + self._areSugges
> > + translationmess
>
> This is not very easy to read, right? I suggest you create a few
> intermediate boolean values so that they all fit on one li...
| Henning Eggers (henninge) wrote : | # |
Thanks Adi,
you have done a good job restructering the test, I did not intend to put that much extra work on you. Thanks.
Two suggestions on the patch:
* msgset_stem is not clear to me. Is that a Hungarian word there? ;-) Just msgset_id would be clearer, I gues.
* Maybe _isNoTranslatio
Ok, about the remaining problem.
> I was thinking there is no need to force a user to add an empty
> text and mark it as a suggestion and it should be enough to just
> tick the "needs review" checkbox.
Yes, we agree here. But still the radio button should move to the empty input field, I think. This way it is clear that the current translation will change - to nothing.
There is this big misunderstanding that you and others had about the meaning of "Someone should review..." because it was always only intended for newly entered translations. The use that you added now is a new feature, not a fix of a buggy feature.
That is why I think moving the radio button down to the input field will keep the original intention that the checkbox relates to the input box, not the current translation, while adding the extra feature of resetting the current translatoin.
I know this requires some javascript. I don't know how comfortable you are with writing that. If you want to you can file an extra bug for it which should be fixed this cycle. You can land this branch as it is (see above suggestions) but it would be great if that extra javascript would be in it. ;-)
Cheers,
Henning
| Adi Roiban (adiroiban) wrote : | # |
> Thanks Adi,
> you have done a good job restructering the test, I did not intend to put that
> much extra work on you. Thanks.
>
> Two suggestions on the patch:
> * msgset_stem is not clear to me. Is that a Hungarian word there? ;-) Just
> msgset_id would be clearer, I gues.
I have renamed it to msgset_id.
I was using „stem” as root, (linguistics) the form of a word after all affixes are removed; "thematic vowels are part of the stem"
> * Maybe _isNoTranslatio
> you use it now, i.e. outside an "if" statement looks much better. I'd suggest
> doing the same thing at the other call site and rename it to
> "_maybeRaiseTra
> first because it is clear that this may raise an exception.
Renamed to _maybeRaiseTran
> Ok, about the remaining problem.
> > I was thinking there is no need to force a user to add an empty
> > text and mark it as a suggestion and it should be enough to just
> > tick the "needs review" checkbox.
>
> Yes, we agree here. But still the radio button should move to the empty input
> field, I think. This way it is clear that the current translation will change
> - to nothing.
> There is this big misunderstanding that you and others had about the meaning
> of "Someone should review..." because it was always only intended for newly
> entered translations. The use that you added now is a new feature, not a fix
> of a buggy feature.
> That is why I think moving the radio button down to the input field will keep
> the original intention that the checkbox relates to the input box, not the
> current translation, while adding the extra feature of resetting the current
> translatoin.
Yes, this is a new functionality and maybe I should open a new bug for this branch.
While we don't have the „is_reviewed” field in the DB and the +translate page is not redesigned, this can be a workaround for this bug.
> I know this requires some javascript. I don't know how comfortable you are
> with writing that. If you want to you can file an extra bug for it which
> should be fixed this cycle. You can land this branch as it is (see above
> suggestions) but it would be great if that extra javascript would be in it.
> ;-)
I have added the required javascript.
I don't know how to include the windmill test since it depends on this branch https:/
Maybe I will have to wait for the landing of that branch and then merge the windmill test for this branch and do a bit of refactoring for the initilization of Javascript code on this page.
Here is the latest diff
=== modified file 'lib/canonical/
--- lib/canonical/
+++ lib/canonical/
@@ -321,12 +321,41 @@
}
}
-}
+};
+var initializeReset
+ for (var key = 0; key < fields.length; key++) {
+ var html_parts ...
| Adi Roiban (adiroiban) wrote : | # |
Here are the Windmill tests and the changes in the pofile and translation +message javascript initialization.
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -50,3 +50,132 @@
# Check that the associated radio button is selected.
+
+ def _check_
+ self, client, checkbox, singular_select, singular_current,
+ plural_
+ """Checks that the new translation select radio buttons are checked
+ when ticking 'Someone should review this translation' checkbox.
+ """
+
+ client.
+ id=checkbox, timeout=
+ client.
+ id=singular_select, timeout=
+ if plural_select is not None:
+ client.
+ id=plural_select, timeout=
+
+ # Check that initialy the checkbox is not checked and
+ # that the radio buttons are not selected.
+ client.
+ client.
+ client.
+ if plural_select is not None:
+ client.
+
+ # Check the checkbox
+ client.
+
+ # Check that the checkbox and the new translation radio buttons are
+ # selected.
+ client.
+ client.
+ client.
+ if plural_select is not None:
+ client.
+
+ # We select the current translation for the singular form.
+ client.
+
+ # Then then we uncheck the 'Someone needs to review this translation'
+ # checkbox.
+ client.
+
+ # Unchecking the 'Someone needs to review this translation' checkbox
+ # will not change the state of the radio buttons.
+ client.
+ client.
+ client.
+ if plural_select is not None:
+ client.
+
+ def test_pofile_
+ """Test for automatically selecting new translation when
+ 'Someone needs to review this translations' is checked.
+ """
+ client = self.client
+ user = lpuser.
+
+ # Go to the zoom in page for a translation with plural forms.
+ self.client.open(
+ url='http://
+ 'ubuntu/
+ 'evolution-
| Henning Eggers (henninge) wrote : | # |
m 23.03.2010 01:31, schrieb Adi Roiban:
> Here are the Windmill tests and the changes in the pofile and translation +message javascript initialization.
Thanks Adi, looks very good to me. I just have one request.
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -50,3 +50,132 @@
>
> # Check that the associated radio button is selected.
> client.
> +
> + def _check_
[...]
> + # Then then we uncheck the 'Someone needs to review this translation'
> + # checkbox.
> + client.
> +
> + # Unchecking the 'Someone needs to review this translation' checkbox
> + # will not change the state of the radio buttons.
I think that this will lead to accidental unsetting of translations. Someone going through translations and clicking on "Someone should ..." but then changes his mind will most likely forget to move the radio button back to preserve the current translation. The radio button should jump back to the current translation if the text field is empty (only then!).
See the code below.
> + client.
> + client.
> + client.
> + if plural_select is not None:
> + client.
> +
> + def test_pofile_
[...]
> === modified file 'lib/lp/
> === modified file 'lib/lp/
Thanks for moving the code out of the templates!
> === modified file 'lib/canonical/
[...]
> +
> +var initializeReset
> + for (var key = 0; key< fields.length; key++) {
> + var html_parts = fields[
> + var msgset_id = html_parts[0] + '_' + html_parts[1];
> + var node = Y.one('#' + msgset_id + '_force_
> + if (node === null) {
> + // If we don't have a force_suggestion checkbox associated with
> + // this field, just continue to the next field.
> + break;
> + }
> + Y.on(
> + 'click',
> + function (e, translation_id) {
> + if (this === null) {
> + // Don't do nothing if we don't have a context object.
> + return;
> + }
> + if (this.get(
> + var select = Y.one('#' + translation_id + '_select');
> + if (select !== null) {
> + select.
> + }
I was thinking about how this would be done and came up with this code. Feel free to use it or find your own solution ... ;-)
} else {
| Adi Roiban (adiroiban) wrote : | # |
Hi Henning,
I'm back in business.
Here are the changes after applying your JS code and updating the windmill tests.
I have also merged with devel.
If everything is ok, can you please send this branch to ec2-test?
Thanks!
=== modified file 'lib/canonical/
--- lib/canonical/
+++ lib/canonical/
@@ -374,10 +374,25 @@
}
if (this.get(
+ // When checking the "Need review" checkbox the new
+ // translation should be automatically checked.
+ } else {
+ // When unchecking the "Need review" checkbox and the new
+ // translation is empty, the current translation should be
+ // automatically selected.
+ var inputfield = Y.one('#' + translation_id);
+ if (inputfield !== null && inputfield.
+ var current_radio_id = translation_
+ /_new$/, '_radiobutton');
+ var current_radio = Y.one('#' + current_radio_id);
+ if (current_radio !== null) {
+ current_
+ }
+ }
}
},
node , node, fields[key]
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -52,8 +52,8 @@
def _check_
- self, client, checkbox, singular_select, singular_current,
- plural_
+ self, client, checkbox, singular_
+ singular_
"""Checks that the new translation select radio buttons are checked
when ticking 'Someone should review this translation' checkbox.
"""
@@ -61,44 +61,61 @@
- id=singular_select, timeout=
- if plural_select is not None:
- client.
- id=plural_select, timeout=
+ id=singular_
+ client.
+ id=singular_
+ if plural_new_select is not None:
+ client.
+ id=plural_
| Henning Eggers (henninge) wrote : | # |
Am 12.04.2010 02:39, schrieb Adi Roiban:
> I'm back in business.
Good to hear! ;-)
>
> Here are the changes after applying your JS code and updating the windmill tests.
Thanks for updating those tests. I actually forgot to try my code on plural
forms but I am glad to see that works, too. ;-)
>
> I have also merged with devel.
>
> If everything is ok, can you please send this branch to ec2-test?
I will but I have two little commenting and naming complaints that you should
please take care of first.
>
> Thanks!
You are most welcome! ;-)
Henning
> === modified file 'lib/canonical/
> --- lib/canonical/
> +++ lib/canonical/
> @@ -374,10 +374,25 @@
> return;
> }
> if (this.get(
> + // When checking the "Need review" checkbox the new
> + // translation should be automatically checked.
Please don't use "should" in comments, this is not a test. ;-)
Also, it is not necessary to explain what the code does unless the code is
really complicated or some special condition/
known to understand the code.
Generally, the code should speak for itself. If you feel the code does not,
maybe a variable needs a more descriptive name?
> var select = Y.one('#' + translation_id + '_select');
> if (select !== null) {
> select.
> }
> + } else {
> + // When unchecking the "Need review" checkbox and the new
> + // translation is empty, the current translation should be
> + // automatically selected.
Same here.
> + var inputfield = Y.one('#' + translation_id);
> + if (inputfield !== null&& inputfield.
> + var current_radio_id = translation_
> + /_new$/, '_radiobutton');
> + var current_radio = Y.one('#' + current_radio_id);
> + if (current_radio !== null) {
> + current_
> + }
> + }
> }
> },
> node , node, fields[key]
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -52,8 +52,8 @@
> client.
>
> def _check_
Sorry, I did not notice this before. Methods are always camelCase, functions
and variables use_underscores. It's in the style guide ... ;-)
def _checkResetTran
That's all.
| Adi Roiban (adiroiban) wrote : | # |
I have renamed the method.
I have also added a test for pt_BR, since the use of „_” in language code and as a separator for form fields can generated errors.
I have removed „user.ensure_
Do we really need to call it after each page load?
I have renamed the variables and remove the comment. Many thanks for this review!
=== modified file 'lib/canonical/
--- lib/canonical/
+++ lib/canonical/
@@ -374,23 +374,20 @@
}
if (this.get(
- // When checking the "Need review" checkbox the new
- // translation should be automatically checked.
- var select = Y.one('#' + translation_id + '_select');
- if (select !== null) {
- select.
+ var new_translation
+ '#' + translation_id + '_select');
+ if (new_translatio
+ new_translation
} else {
- // When unchecking the "Need review" checkbox and the new
- // translation is empty, the current translation should be
- // automatically selected.
- var inputfield = Y.one('#' + translation_id);
- if (inputfield !== null && inputfield.
- var current_radio_id = translation_
+ var new_translation
+ if (new_translatio
+ new_translation
+ var current_select_id = translation_
- var current_radio = Y.one('#' + current_radio_id);
- if (current_radio !== null) {
- current_
+ var current_select = Y.one('#' + current_select_id);
+ if (current_select !== null) {
+ current_
}
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -51,7 +51,7 @@
# Check that the associated radio button is selected.
- def _check_
+ def _checkResetTran
self, client, checkbox, singular_
| Henning Eggers (henninge) wrote : | # |
Am 12.04.2010 16:57, schrieb Adi Roiban:
> I have renamed the method.
Thanks.
>
> I have also added a test for pt_BR, since the use of „_” in language code and as a separator for form fields can generated errors.
Good thinking! Very good, indeed.
>
> I have removed „user.ensure_
> Do we really need to call it after each page load?
I don't think so, the browser stays logged in, doesn't it?
>
> I have renamed the variables and remove the comment. Many thanks for this review!
Thanks a lot for your work, it is much appreicated! ;-)
I will land this now.
Henning
| Adi Roiban (adiroiban) wrote : | # |
I forget to update the previous integration test with the new implementation that actually requires selecting the new empty translation.
I have fixed it.
=== modified file 'lib/lp/
--- lib/lp/
+++ lib/lp/
@@ -75,8 +75,9 @@
... 'evolution/
>>> inputradio = admin_browser.
... name='msgset_
- >>> inputradio.value = [ 'msgset_
- >>> inputfield = admin_browser.
+ >>> inputradio.value = ['msgset_
+ >>> inputfield = admin_browser.
+ ... name='msgset_
>>> inputfield.value = 'New test translation'
>>> admin_browser.
>>> print extract_
@@ -88,11 +89,15 @@
Located in ...
'Someone should review this translation' can be used to reset the translation,
-and after clicking 'Save & Continue', all translations entered for this
+when a new emtpy translation is added and marked as needing review.
+After clicking 'Save & Continue', all translations entered for this
message will be listed as suggestions.
>>> admin_browser.
... 'Someone should review this translation'
+ >>> inputradio = admin_browser.
+ ... name='msgset_
+ >>> inputradio.value = ['msgset_
>>> admin_browser.
>>> print extract_
... 'messages_
| Henning Eggers (henninge) wrote : | # |
I tried to land it but it has another merge conflict. Please merge the current
devel again and I will try to land it again.
| Adi Roiban (adiroiban) wrote : | # |
Hi,
I merged and solved the conflict and push the changes.
Cheers,
Adi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 12.03.2010 16:42, Adi Roiban schrieb:
Hi Adi,
thanks for tackling this. There seem to have been some misunderstanding
about how this option worked, judging by the comments in the bug.
I am a little concerned about the behaviour. Shouldn't the radio button
in front of the input box need to be activated (see below)? Also, I am
not sure if really _all_ old suggestions should be brought up again. But
that may be OK.
I also have some other suggestions. Please look at them and we can talk
again tomorrow.
review needs-fixing
Please find my comments below.
Cheers,
Hennning
> === modified file 'lib/lp/ translations/ browser/ tests/translati onmessage- views.txt' translations/ browser/ tests/translati onmessage- views.txt 2009-09-11 22:24:51 +0000 translations/ browser/ tests/translati onmessage- views.txt 2010-03-15 13:43:34 +0000 shared_ translationmess age == translationmessage
> --- lib/lp/
> +++ lib/lp/
> @@ -689,3 +689,108 @@
> False
> >>> subview.
> True
> +
> +
> +Reseting current translation
Resetting ...
> +------ ------- ------- ------- --
> +
> +The current translation can be resetted by submiting an empty translation or
> +a translation similar to the current one, while forcing the suggestions.
The current translation can be reset by submitting an empty translation
or a translation similar to the current one while forcing suggestions.
> +
> + >>> # We need to force timestamp update, since suggestions are submitted
> + >>> # to fast
Please don't put comments in doc tests. Whatever goes into the comment
can go into the normal text. It's "too fast", btw. ;)
> + >>> year_tick = 2100 translation( translation, force_suggestio n=False) : age.get( 1)
> + >>> def submit_
> + ... global year_tick
> + ... translationmessage = TranslationMess
I find this very obscure. I think it would be clearer to pass
translationmessage as a parameter into the function. If you want "any"
TranslationMessage object, use the factory outside and pass the object
into the function.
> + ... pofile = translationmess age.pofile age.potmsgset url(translation message) , '+translate']) now(UTC) .strftime( '-%m-%dT% H:%M:%S+ 00:00') ) 1_es_translatio n_0_radiobutton ': 1_es_translatio n_0_new' , 1_es_translatio n_0_new' : translation, translations' : 'Save & Continue'} 1_es_needsrevie w'] = 'force_suggestion' onsLayer, server_ url=server_ url) request. method = 'POST' initialize( ) trans.. .
> + ... potmsgset = translationmess
> + ... server_url = '/'.join(
> + ... [canonical_
> + ... now = (str(year_tick) +
> + ... datetime.
> + ... year_tick += 1
> + ... form = {
> + ... 'lock_timestamp': now,
> + ... 'alt': None,
> + ... 'msgset_1': None,
> + ... 'msgset_
> + ... 'msgset_
> + ... 'msgset_
> + ... 'submit_
> + ... if force_suggestion:
> + ... form['msgset_
> + ... tm_view = create_view(
> + ... translationmessage, "+translate", form=form,
> + ... layer=Translati
> + ... tm_view.
> + ... tm_view.
> +
> + >>> def print_current_