Merge lp:~danilo/launchpad/bug-479385 into lp:launchpad

Proposed by Данило Шеган
Status: Merged
Approved by: Данило Шеган
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~danilo/launchpad/bug-479385
Merge into: lp:launchpad
Diff against target: 74 lines (+43/-2)
2 files modified
lib/lp/translations/model/potmsgset.py (+6/-2)
lib/lp/translations/tests/test_potmsgset.py (+37/-0)
To merge this branch: bzr merge lp:~danilo/launchpad/bug-479385
Reviewer Review Type Date Requested Status
Francis J. Lacoste (community) release-critical Approve
Gavin Panella (community) code Approve
Review via email: mp+14742@code.launchpad.net

Commit message

Do not check for permissions when setting translator credits as translated.

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

= Bug 479385 =

Fix failure in setTranslationCreditsToTranslated when pofile.owner has not agreed to licensing terms. Also use pofile.lasttranslator if it's defined, prior to using pofile.owner.

The only code change in model/potmsgset.py is in setTranslationCreditsToTranslated to pass pofile.lasttranslator if it's defined and to pass force_edition_rights=True to updateTranslation call.

This is a CP candidate.

= Tests =

bin/test -vvt setTranslationCreditsToTranslated

= Demo & QA =

Run scripts/rosetta/fix_translation_credits.py over entire DB (that's how we detected the problem in the first place).

= 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/translations/model/potmsgset.py
  lib/lp/translations/tests/test_potmsgset.py

Revision history for this message
Gavin Panella (allenap) wrote :

Looks good.

review: Approve (code)
Revision history for this message
Francis J. Lacoste (flacoste) :
review: Approve (release-critical)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/model/potmsgset.py'
2--- lib/lp/translations/model/potmsgset.py 2009-10-30 10:29:25 +0000
3+++ lib/lp/translations/model/potmsgset.py 2009-11-11 12:20:29 +0000
4@@ -1056,9 +1056,13 @@
5 if self.is_translation_credit:
6 translation = self.getSharedTranslationMessage(pofile.language)
7 if translation is None:
8+ translator = pofile.lasttranslator
9+ if translator is None:
10+ translator = pofile.owner
11 message = self.updateTranslation(
12- pofile, pofile.owner, [credits_message_str],
13- is_imported=False, allow_credits=True, force_shared=True,
14+ pofile, translator, [credits_message_str],
15+ is_imported=False, allow_credits=True,
16+ force_shared=True, force_edition_rights=True,
17 lock_timestamp=datetime.datetime.now(pytz.UTC))
18
19 def setSequence(self, potemplate, sequence):
20
21=== modified file 'lib/lp/translations/tests/test_potmsgset.py'
22--- lib/lp/translations/tests/test_potmsgset.py 2009-11-10 02:08:57 +0000
23+++ lib/lp/translations/tests/test_potmsgset.py 2009-11-11 12:20:29 +0000
24@@ -23,6 +23,7 @@
25 from lp.translations.interfaces.translationfileformat import (
26 TranslationFileFormat)
27 from lp.translations.interfaces.translationmessage import TranslationConflict
28+from lp.translations.interfaces.translationsperson import ITranslationsPerson
29 from lp.translations.model.translationmessage import (
30 DummyTranslationMessage)
31
32@@ -674,6 +675,42 @@
33 self.assertNotEqual(None, current_shared)
34 self.assertEqual(None, current_shared.potemplate)
35
36+ def test_setTranslationCreditsToTranslated_permissions(self):
37+ # Even if POFile.owner has not agreed to the Launchpad
38+ # translations licensing policy, automated credit
39+ # messages are still created.
40+ sr_pofile = self.factory.makePOFile('sr', self.devel_potemplate)
41+ owner = sr_pofile.owner
42+ ITranslationsPerson(owner).translations_relicensing_agreement = False
43+ credits_potmsgset = self.factory.makePOTMsgSet(
44+ self.devel_potemplate, singular=u'translator-credits')
45+ current = credits_potmsgset.getCurrentTranslationMessage(
46+ self.devel_potemplate, sr_pofile.language)
47+ self.assertEqual(owner, current.submitter)
48+
49+ def test_setTranslationCreditsToTranslated_submitter_lasttranslator(self):
50+ # Submitter on the automated translation message is set to
51+ # POFile.lasttranslator if it's defined.
52+ sr_pofile = self.factory.makePOFile('sr', self.devel_potemplate)
53+ last_translator = self.factory.makePerson()
54+ sr_pofile.lasttranslator = last_translator
55+ credits_potmsgset = self.factory.makePOTMsgSet(
56+ self.devel_potemplate, singular=u'translator-credits')
57+ current = credits_potmsgset.getCurrentTranslationMessage(
58+ self.devel_potemplate, sr_pofile.language)
59+ self.assertEqual(last_translator, current.submitter)
60+
61+ def test_setTranslationCreditsToTranslated_submitter_owner(self):
62+ # Submitter on the automated translation message is set to
63+ # POFile.owner if POFile.lasttranslator is not defined.
64+ sr_pofile = self.factory.makePOFile('sr', self.devel_potemplate)
65+ self.assertEqual(None, sr_pofile.lasttranslator)
66+ credits_potmsgset = self.factory.makePOTMsgSet(
67+ self.devel_potemplate, singular=u'translator-credits')
68+ current = credits_potmsgset.getCurrentTranslationMessage(
69+ self.devel_potemplate, sr_pofile.language)
70+ self.assertEqual(sr_pofile.owner, current.submitter)
71+
72
73 class TestPOTMsgSetSuggestions(TestCaseWithFactory):
74 """Test retrieval and dismissal of translation suggestions."""