~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/factory.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2010-07-28 19:49:46 UTC
  • mfrom: (11091.7.10 bug-600673)
  • Revision ID: launchpad@pqm.canonical.com-20100728194946-y9jpq31yooosc3v6
[r=maris][ui=rs][bug=600673] Translation import approval template
        selector.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
# pylint: disable-msg=F0401
170
170
    RosettaImportStatus)
171
171
from lp.translations.interfaces.translationgroup import (
172
172
    ITranslationGroupSet)
 
173
from lp.translations.interfaces.translationimportqueue import (
 
174
    RosettaImportStatus)
 
175
from lp.translations.interfaces.translationfileformat import (
 
176
    TranslationFileFormat)
173
177
from lp.translations.interfaces.translationsperson import ITranslationsPerson
174
178
from lp.translations.interfaces.translationtemplatesbuildjob import (
175
179
    ITranslationTemplatesBuildJobSource)
2085
2089
        translation.is_imported = is_imported
2086
2090
        translation.is_current = True
2087
2091
 
2088
 
    def makeTranslationImportQueueEntry(self, path=None, status=None,
 
2092
    def makeTranslationImportQueueEntry(self, path=None, productseries=None,
 
2093
                                        distroseries=None,
2089
2094
                                        sourcepackagename=None,
2090
 
                                        distroseries=None,
2091
 
                                        productseries=None, content=None,
2092
 
                                        uploader=None, is_published=False):
 
2095
                                        potemplate=None, content=None,
 
2096
                                        uploader=None, pofile=None,
 
2097
                                        format=None, status=None):
2093
2098
        """Create a `TranslationImportQueueEntry`."""
2094
2099
        if path is None:
2095
2100
            path = self.getUniqueString() + '.pot'
2096
 
        if status is None:
2097
 
            status = RosettaImportStatus.NEEDS_REVIEW
2098
 
 
2099
 
        if (sourcepackagename is None and distroseries is None):
 
2101
 
 
2102
        for_distro = not (distroseries is None and sourcepackagename is None)
 
2103
        for_project = productseries is not None
 
2104
        has_template = (potemplate is not None)
 
2105
        if has_template and not for_distro and not for_project:
 
2106
            # Copy target from template.
 
2107
            distroseries = potemplate.distroseries
 
2108
            sourcepackagename = potemplate.sourcepackagename
 
2109
            productseries = potemplate.productseries
 
2110
 
 
2111
        if sourcepackagename is None and distroseries is None:
2100
2112
            if productseries is None:
2101
2113
                productseries = self.makeProductSeries()
2102
2114
        else:
2110
2122
 
2111
2123
        if content is None:
2112
2124
            content = self.getUniqueString()
2113
 
 
2114
2125
        content_reference = getUtility(ILibraryFileAliasSet).create(
2115
2126
            name=os.path.basename(path), size=len(content),
2116
2127
            file=StringIO(content), contentType='text/plain')
2117
2128
 
 
2129
        if format is None:
 
2130
            format = TranslationFileFormat.PO
 
2131
 
 
2132
        if status is None:
 
2133
            status = RosettaImportStatus.NEEDS_REVIEW
 
2134
 
2118
2135
        return TranslationImportQueueEntry(
2119
 
            path=path, status=status, sourcepackagename=sourcepackagename,
2120
 
            distroseries=distroseries, productseries=productseries,
2121
 
            importer=uploader, content=content_reference,
2122
 
            is_published=is_published)
 
2136
            path=path, productseries=productseries, distroseries=distroseries,
 
2137
            sourcepackagename=sourcepackagename, importer=uploader,
 
2138
            content=content_reference, status=status, format=format,
 
2139
            is_published=False)
2123
2140
 
2124
2141
    def makeMailingList(self, team, owner):
2125
2142
        """Create a mailing list for the team."""