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
=== modified file 'lib/lp/translations/model/potmsgset.py'
--- lib/lp/translations/model/potmsgset.py 2009-10-30 10:29:25 +0000
+++ lib/lp/translations/model/potmsgset.py 2009-11-11 12:20:29 +0000
@@ -1056,9 +1056,13 @@
1056 if self.is_translation_credit:1056 if self.is_translation_credit:
1057 translation = self.getSharedTranslationMessage(pofile.language)1057 translation = self.getSharedTranslationMessage(pofile.language)
1058 if translation is None:1058 if translation is None:
1059 translator = pofile.lasttranslator
1060 if translator is None:
1061 translator = pofile.owner
1059 message = self.updateTranslation(1062 message = self.updateTranslation(
1060 pofile, pofile.owner, [credits_message_str],1063 pofile, translator, [credits_message_str],
1061 is_imported=False, allow_credits=True, force_shared=True,1064 is_imported=False, allow_credits=True,
1065 force_shared=True, force_edition_rights=True,
1062 lock_timestamp=datetime.datetime.now(pytz.UTC))1066 lock_timestamp=datetime.datetime.now(pytz.UTC))
10631067
1064 def setSequence(self, potemplate, sequence):1068 def setSequence(self, potemplate, sequence):
10651069
=== modified file 'lib/lp/translations/tests/test_potmsgset.py'
--- lib/lp/translations/tests/test_potmsgset.py 2009-11-10 02:08:57 +0000
+++ lib/lp/translations/tests/test_potmsgset.py 2009-11-11 12:20:29 +0000
@@ -23,6 +23,7 @@
23from lp.translations.interfaces.translationfileformat import (23from lp.translations.interfaces.translationfileformat import (
24 TranslationFileFormat)24 TranslationFileFormat)
25from lp.translations.interfaces.translationmessage import TranslationConflict25from lp.translations.interfaces.translationmessage import TranslationConflict
26from lp.translations.interfaces.translationsperson import ITranslationsPerson
26from lp.translations.model.translationmessage import (27from lp.translations.model.translationmessage import (
27 DummyTranslationMessage)28 DummyTranslationMessage)
2829
@@ -674,6 +675,42 @@
674 self.assertNotEqual(None, current_shared)675 self.assertNotEqual(None, current_shared)
675 self.assertEqual(None, current_shared.potemplate)676 self.assertEqual(None, current_shared.potemplate)
676677
678 def test_setTranslationCreditsToTranslated_permissions(self):
679 # Even if POFile.owner has not agreed to the Launchpad
680 # translations licensing policy, automated credit
681 # messages are still created.
682 sr_pofile = self.factory.makePOFile('sr', self.devel_potemplate)
683 owner = sr_pofile.owner
684 ITranslationsPerson(owner).translations_relicensing_agreement = False
685 credits_potmsgset = self.factory.makePOTMsgSet(
686 self.devel_potemplate, singular=u'translator-credits')
687 current = credits_potmsgset.getCurrentTranslationMessage(
688 self.devel_potemplate, sr_pofile.language)
689 self.assertEqual(owner, current.submitter)
690
691 def test_setTranslationCreditsToTranslated_submitter_lasttranslator(self):
692 # Submitter on the automated translation message is set to
693 # POFile.lasttranslator if it's defined.
694 sr_pofile = self.factory.makePOFile('sr', self.devel_potemplate)
695 last_translator = self.factory.makePerson()
696 sr_pofile.lasttranslator = last_translator
697 credits_potmsgset = self.factory.makePOTMsgSet(
698 self.devel_potemplate, singular=u'translator-credits')
699 current = credits_potmsgset.getCurrentTranslationMessage(
700 self.devel_potemplate, sr_pofile.language)
701 self.assertEqual(last_translator, current.submitter)
702
703 def test_setTranslationCreditsToTranslated_submitter_owner(self):
704 # Submitter on the automated translation message is set to
705 # POFile.owner if POFile.lasttranslator is not defined.
706 sr_pofile = self.factory.makePOFile('sr', self.devel_potemplate)
707 self.assertEqual(None, sr_pofile.lasttranslator)
708 credits_potmsgset = self.factory.makePOTMsgSet(
709 self.devel_potemplate, singular=u'translator-credits')
710 current = credits_potmsgset.getCurrentTranslationMessage(
711 self.devel_potemplate, sr_pofile.language)
712 self.assertEqual(sr_pofile.owner, current.submitter)
713
677714
678class TestPOTMsgSetSuggestions(TestCaseWithFactory):715class TestPOTMsgSetSuggestions(TestCaseWithFactory):
679 """Test retrieval and dismissal of translation suggestions."""716 """Test retrieval and dismissal of translation suggestions."""