Ejemplo n.º 1
0
 def getTermByToken(self, token):
     """See `IVocabulary`."""
     try:
         found_language = Language.byCode(token)
     except SQLObjectNotFound:
         raise LookupError(token)
     return self.getTerm(found_language)
Ejemplo n.º 2
0
 def getTermByToken(self, token):
     """See `IVocabulary`."""
     try:
         found_language = Language.byCode(token)
     except SQLObjectNotFound:
         raise LookupError(token)
     return self.getTerm(found_language)
Ejemplo n.º 3
0
 def getQuestionLanguages(self):
     """See `IQuestionCollection`."""
     return set(Language.select("""
         Language.id = Question.language AND
         Question.product = Product.id AND
         Product.project = %s""" % sqlvalues(self.id),
         clauseTables=['Question', 'Product'], distinct=True))
 def translatable_languages(self):
     """See `ITranslationsPerson`."""
     return Language.select("""
         Language.id = PersonLanguage.language AND
         PersonLanguage.person = %s AND
         Language.code <> 'en' AND
         Language.visible""" % sqlvalues(self.person),
         clauseTables=['PersonLanguage'], orderBy='englishname')
Ejemplo n.º 5
0
 def getQuestionLanguages(self):
     """See `IQuestionCollection`."""
     return set(
         Language.select("""
         Language.id = Question.language AND
         Question.product = Product.id AND
         Product.project = %s""" % sqlvalues(self.id),
                         clauseTables=['Question', 'Product'],
                         distinct=True))
 def getQuestionLanguages(self):
     """See `IQuestionCollection`."""
     return set(Language.select(
         """Language.id = language AND Question.id IN (
         SELECT id FROM Question
                   WHERE owner = %(personID)s OR answerer = %(personID)s OR
                        assignee = %(personID)s
         UNION SELECT question FROM QuestionSubscription
               WHERE person = %(personID)s
         UNION SELECT question
               FROM QuestionMessage
               WHERE owner = %(personID)s
         )""" % sqlvalues(personID=self.id),
         clauseTables=['Question'], distinct=True))
Ejemplo n.º 7
0
 def getQuestionLanguages(self):
     """See `IQuestionCollection`."""
     return set(
         Language.select("""Language.id = language AND Question.id IN (
         SELECT id FROM Question
                   WHERE owner = %(personID)s OR answerer = %(personID)s OR
                        assignee = %(personID)s
         UNION SELECT question FROM QuestionSubscription
               WHERE person = %(personID)s
         UNION SELECT question
               FROM QuestionMessage
               WHERE owner = %(personID)s
         )""" % sqlvalues(personID=self.id),
                         clauseTables=['Question'],
                         distinct=True))
Ejemplo n.º 8
0
    def _updateRosettaStatistics(self, ztm):
        self.update(
                'products_using_rosetta',
                Product.selectBy(
                    translations_usage=ServiceUsage.LAUNCHPAD).count())
        self.update('potemplate_count', POTemplate.select().count())
        ztm.commit()
        self.update('pofile_count', POFile.select().count())
        ztm.commit()
        self.update('pomsgid_count', POMsgID.select().count())
        ztm.commit()
        self.update('language_count', Language.select(
            "POFile.language=Language.id",
            clauseTables=['POFile'],
            distinct=True).count())
        ztm.commit()

        cur = cursor()
        cur.execute(
            "SELECT COUNT(DISTINCT submitter) FROM TranslationMessage")
        self.update('translator_count', cur.fetchone()[0] or 0)
        ztm.commit()

        cur = cursor()
        cur.execute("""
            SELECT COUNT(DISTINCT submitter)
            FROM TranslationMessage
            WHERE origin=2
            """)
        self.update('rosetta_translator_count', cur.fetchone()[0] or 0)
        ztm.commit()

        cur = cursor()
        cur.execute("""
            SELECT COUNT(DISTINCT product) FROM ProductSeries,POTemplate
            WHERE ProductSeries.id = POTemplate.productseries
            """)
        self.update('products_with_potemplates', cur.fetchone()[0] or 0)
        ztm.commit()
Ejemplo n.º 9
0
    def _updateRosettaStatistics(self, ztm):
        self.update(
                'products_using_rosetta',
                Product.selectBy(
                    translations_usage=ServiceUsage.LAUNCHPAD).count())
        self.update('potemplate_count', POTemplate.select().count())
        ztm.commit()
        self.update('pofile_count', POFile.select().count())
        ztm.commit()
        self.update('pomsgid_count', POMsgID.select().count())
        ztm.commit()
        self.update('language_count', Language.select(
            "POFile.language=Language.id",
            clauseTables=['POFile'],
            distinct=True).count())
        ztm.commit()

        cur = cursor()
        cur.execute(
            "SELECT COUNT(DISTINCT submitter) FROM TranslationMessage")
        self.update('translator_count', cur.fetchone()[0] or 0)
        ztm.commit()

        cur = cursor()
        cur.execute("""
            SELECT COUNT(DISTINCT submitter)
            FROM TranslationMessage
            WHERE origin=2
            """)
        self.update('rosetta_translator_count', cur.fetchone()[0] or 0)
        ztm.commit()

        cur = cursor()
        cur.execute("""
            SELECT COUNT(DISTINCT product) FROM ProductSeries,POTemplate
            WHERE ProductSeries.id = POTemplate.productseries
            """)
        self.update('products_with_potemplates', cur.fetchone()[0] or 0)
        ztm.commit()