Пример #1
    def disable(cls, session, id_):
        """ Disable the language 'id_'
            if it is not the only enabled one,
            then delete all translations for that language.

        if Language.count(session, cls.enabled == True) < 2:
            raise QuotaError('Cannot disable last enabled language.')

        language = Language.get(session, id_)
        language.enabled = False

        NodeInfo.remove_translations(session, id_)

        return language
Пример #2
    def enable(cls, session, id_, translation_lang_id):
        """ Enable the language 'id_'
            if the number of enabled languages did not reach 'max_languages',
            then create translations for that language:
            create translations for each NodeInfo
            from 'translation_lang_id' to 'lang_id'.
        max_ = Setting.get(session, 'max_languages').value
        enabled = cls.count(session, Language.enabled == True)
        if enabled >= max_:
            msg = 'The maximum number of enabled languages was reached.'
            raise QuotaError(msg)

        language = cls.get(session, id_)
        language.enabled = True
        log.debug('Enabled language: %s', language)


        return language