Merge lp:~jtv/launchpad/recife-getpofileswithtranslationcredits into lp:launchpad/db-devel

Proposed by Jeroen T. Vermeulen on 2010-11-29
Status: Merged
Approved by: Jeroen T. Vermeulen on 2010-11-29
Approved revision: no longer in the source branch.
Merged at revision: 10015
Proposed branch: lp:~jtv/launchpad/recife-getpofileswithtranslationcredits
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~jtv/launchpad/recife-pre-stats
Diff against target: 48 lines (+12/-5)
2 files modified
lib/lp/translations/model/pofile.py (+11/-1)
lib/lp/translations/tests/test_pofile.py (+1/-4)
To merge this branch: bzr merge lp:~jtv/launchpad/recife-getpofileswithtranslationcredits
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) code 2010-11-29 Approve on 2010-11-29
Review via email: mp+42083@code.launchpad.net

Commit Message

[r=jelmer][ui=none][no-qa] Recife-fix getPOFilesWithTranslationCredits.

Description of the Change

= Recife: fix getPOFilesWithTranslationCredits =

This fixes up POFileSet.getPOFilesWithTranslationCredits for Rosetta's new "Recife" data model. In a nutshell, if the caller passes untranslated=True, the method should look not for translation credits with is_current_ubuntu==False but for ones with is_current_ubuntu==False or is_current_upstream==False depending on what kind of template the POFile is for—Ubuntu or upstream respectively.

To test:
{{{
./bin/test -vvc lp.translations.tests.test_pofile
}}}

No lint,

Jeroen

To post a comment you must log in.
Jelmer Vernooij (jelmer) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/model/pofile.py'
2--- lib/lp/translations/model/pofile.py 2010-11-29 10:14:38 +0000
3+++ lib/lp/translations/model/pofile.py 2010-11-29 10:14:39 +0000
4@@ -1417,6 +1417,9 @@
5
6 def getPOFilesWithTranslationCredits(self, untranslated=False):
7 """See `IPOFileSet`."""
8+ # Avoid circular imports.
9+ from lp.translations.model.potemplate import POTemplate
10+
11 store = getUtility(IStoreSelector).get(MAIN_STORE, MASTER_FLAVOR)
12 clauses = [
13 TranslationTemplateItem.potemplateID == POFile.potemplateID,
14@@ -1431,8 +1434,15 @@
15 TranslationMessage.potmsgsetID == POTMsgSet.id,
16 TranslationMessage.potemplate == None,
17 POFile.languageID == TranslationMessage.languageID,
18- TranslationMessage.is_current_ubuntu == True),
19+ Or(
20+ And(
21+ POTemplate.productseries == None,
22+ TranslationMessage.is_current_ubuntu == True),
23+ And(
24+ POTemplate.productseries != None,
25+ TranslationMessage.is_current_upstream == True))),
26 (TranslationMessage))
27+ clauses.append(POTemplate.id == POFile.potemplateID)
28 clauses.append(Not(Exists(message_select)))
29 result = store.find((POFile, POTMsgSet), clauses)
30 return result.order_by('POFile.id')
31
32=== modified file 'lib/lp/translations/tests/test_pofile.py'
33--- lib/lp/translations/tests/test_pofile.py 2010-11-29 10:14:38 +0000
34+++ lib/lp/translations/tests/test_pofile.py 2010-11-29 10:14:39 +0000
35@@ -1657,12 +1657,9 @@
36
37 credits_translation = credits_potmsgset.getCurrentTranslation(
38 potemplate, pofile.language, potemplate.translation_side)
39+
40 # Clearing is_current_upstream will make this an "untranslated"
41 # credits message.
42- # XXX JeroenVermeulen 2010-11-29: Also clearing
43- # is_current_ubuntu to make this pass until
44- # getPOFilesWithTranslationCredits is updated.
45- credits_translation.is_current_ubuntu = False
46 credits_translation.is_current_upstream = False
47
48 self.assertEqual(

Subscribers

People subscribed via source and target branches

to status/vote changes: