-----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/translationmessage-views.txt' > --- lib/lp/translations/browser/tests/translationmessage-views.txt 2009-09-11 22:24:51 +0000 > +++ lib/lp/translations/browser/tests/translationmessage-views.txt 2010-03-15 13:43:34 +0000 > @@ -689,3 +689,108 @@ > False > >>> subview.shared_translationmessage == translationmessage > 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 > + >>> def submit_translation(translation, force_suggestion=False): > + ... global year_tick > + ... translationmessage = TranslationMessage.get(1) 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 = translationmessage.pofile > + ... potmsgset = translationmessage.potmsgset > + ... server_url = '/'.join( > + ... [canonical_url(translationmessage), '+translate']) > + ... now = (str(year_tick) + > + ... datetime.now(UTC).strftime('-%m-%dT%H:%M:%S+00:00')) > + ... year_tick += 1 > + ... form = { > + ... 'lock_timestamp': now, > + ... 'alt': None, > + ... 'msgset_1': None, > + ... 'msgset_1_es_translation_0_radiobutton': > + ... 'msgset_1_es_translation_0_new', > + ... 'msgset_1_es_translation_0_new': translation, > + ... 'submit_translations': 'Save & Continue'} > + ... if force_suggestion: > + ... form['msgset_1_es_needsreview'] = 'force_suggestion' > + ... tm_view = create_view( > + ... translationmessage, "+translate", form=form, > + ... layer=TranslationsLayer, server_url=server_url) > + ... tm_view.request.method = 'POST' > + ... tm_view.initialize() > + > + >>> def print_current_translation(): > + ... translationmessage = TranslationMessage.get(1) > + ... pofile = translationmessage.pofile > + ... potmsgset = translationmessage.potmsgset > + ... current_translation = potmsgset.getCurrentTranslationMessage( > + ... pofile.potemplate, pofile.language) > + ... if current_translation is not None: > + ... print current_translation.translations > + > + >>> def print_local_suggestions(): > + ... import operator > + ... translationmessage = TranslationMessage.get(1) > + ... pofile = translationmessage.pofile > + ... potmsgset = translationmessage.potmsgset > + ... local = sorted( > + ... potmsgset.getLocalTranslationMessages( > + ... pofile.potemplate, pofile.language), > + ... key=operator.attrgetter("date_created"), > + ... reverse=True) > + ... for suggestion in local: > + ... print suggestion.translations > + > +Then we will add a new translation, forcing it as a suggestion. > + > + >>> submit_translation(u'A new suggestion', force_suggestion=True) > + >>> print_local_suggestions() > + [u'A new suggestion'] > + [u'Foos'] > + >>> print_current_translation() > + [u'Foo'] > + > +Forcing suggestions while submitting an empty translation will reset the > +translation for this message and all previously entered translations will be > +listed as suggestions. > + > + >>> submit_translation(u'', force_suggestion=True) > + >>> print_local_suggestions() > + [u'A new suggestion'] > + [u'Foos'] > + [u'Foo'] > + >>> print_current_translation() > + > +Same happens if we force the submission of a suggestion similar with the ... similar to the ... > +current translation. > + > + >>> submit_translation(u'New current translation') > + >>> print_current_translation() > + [u'New current translation'] > + >>> submit_translation(u'New current translation', force_suggestion=True) > + >>> print_local_suggestions() > + [u'New current translation'] > + [u'A new suggestion'] > + [u'Foos'] > + [u'Foo'] > + >>> print_current_translation() > + > +Only users with edit rights are allowed to reset a translation. > + > + >>> submit_translation(u'New current translation') > + >>> print_current_translation() > + [u'New current translation'] > + >>> print_local_suggestions() > + >>> login('