POTemplateSubset.getPOTemplateByTranslationDomain should honor iscurrent flag

Bug #314839 reported by Henning Eggers
6
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Henning Eggers

Bug Description

When searching for templates by translation domain, disabled templates (potemplate.iscurrent == False) must not be taken into account. This causes the auto approval script to fail if relevant disabled templates exist.

Related branches

Changed in rosetta:
status: New → Confirmed
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

There are two attenuating circumstances:

1. AFAICS this situation does not cause the auto-approval script to fail as such. It just means that the file in question does not get approved, and an ambiguity is logged to error-reports. Changing the disabled template's domain resolves the ambiguity and allows the files to be approved.

2. The situation only occurs where the upload's sourcepackagename is not unambiguously known. As things stand now, that means that it only happens with KDE translations—specifically the ones uploaded in language packs.

Revision history for this message
Arne Goetje (arnegoetje) wrote :

The code snipped in question:

---------------------8<----------------------------------

    def getPOTemplateByTranslationDomain(self, translation_domain):
        """See `IPOTemplateSubset`."""
        queries = [self.query]
        clausetables = list(self.clausetables)

        queries.append('POTemplate.translation_domain = %s' % sqlvalues(
            translation_domain))

        # Fetch up to 2 templates, to check for duplicates.
        matches = POTemplate.select(
            ' AND '.join(queries), clauseTables=clausetables, limit=2)

        result = [match for match in matches]
        if len(result) == 0:
            return None
        elif len(result) == 1:
            return result[0]
        else:
            log.warn(
                "Found multiple templates with translation domain '%s'. "
                "There should be only one."
                % translation_domain)
            return None

---------------------8<----------------------------------

Proposal:
1. Add a query to check for potemplate.iscurrent == True (which should honor the "Accept Translations" switch in the Admin UI)
Something like this:
        queries.append('POTemplate.translation_domain = %s' % sqlvalues(
            translation_domain))
        queries.append('POTemplate.iscurrent = True')

2. drop the limit = 2 and use the result to display the affected template names and source packages in the error message.

Revision history for this message
Henning Eggers (henninge) wrote :

We should remember the general nature of POTemplateSubset, it is not solely used for auto-approval. Hard-wiring this into the method could break other uses of it.

I would propose to make "include disabled templates" a parameter for the whole subset which can be set during construction. It could default to "True" to remain backward compatible and be set to "False" when the auto-approval script creates its subset.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

I like this one. The possibility actually came up in a pre-imp when I was solving a similar issue elsewhere a month or two back. The only reason I didn't do it was that at the time it was overweight for the problem I was trying to solve.

Now that we have another instance of the problem, it becomes more viable.

Changed in rosetta:
assignee: nobody → henninge
importance: Undecided → High
milestone: none → 2.2.1
status: Confirmed → Triaged
Revision history for this message
Henning Eggers (henninge) wrote :

FLW: This should be straightforward ...

Changed in rosetta:
status: Triaged → In Progress
Revision history for this message
Henning Eggers (henninge) wrote :

Fixed in RF 7540.

Changed in rosetta:
status: In Progress → Fix Committed
Changed in rosetta:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.