~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/translations/model/potemplate.py

[r=gmb][bug=504062,
        816366] Hide external suggestions to disabled translation templates
        by removing it from the suggestive potemplate cache.

Show diffs side-by-side

added added

removed removed

Lines of Context:
244
244
        """See `IPOTemplate`."""
245
245
        self._cached_pofiles_by_language = None
246
246
 
 
247
    def _removeFromSuggestivePOTemplatesCache(self):
 
248
        """One level of indirection to make testing easier."""
 
249
        getUtility(
 
250
            IPOTemplateSet).removeFromSuggestivePOTemplatesCache(self)
 
251
 
 
252
    def setActive(self, active):
 
253
        """See `IPOTemplate`."""
 
254
        if not active and active != self.iscurrent:
 
255
            self._removeFromSuggestivePOTemplatesCache()
 
256
        self.iscurrent = active
 
257
 
247
258
    @property
248
259
    def uses_english_msgids(self):
249
260
        """See `IPOTemplate`."""
1375
1386
        return IMasterStore(POTemplate).execute(
1376
1387
            "DELETE FROM SuggestivePOTemplate").rowcount
1377
1388
 
 
1389
    def removeFromSuggestivePOTemplatesCache(self, potemplate):
 
1390
        """See `IPOTemplateSet`."""
 
1391
        rowcount = IMasterStore(POTemplate).execute(
 
1392
            "DELETE FROM SuggestivePOTemplate "
 
1393
            "WHERE potemplate = %s" % sqlvalues(potemplate)).rowcount
 
1394
        return rowcount == 1
 
1395
 
1378
1396
    def populateSuggestivePOTemplatesCache(self):
1379
1397
        """See `IPOTemplateSet`."""
1380
1398
        # XXX j.c.sackett 2010-08-30 bug=627631 Once data migration has