Exemplo n.º 1
0
    def post(self):
        """Create a new language and fill it with empty translations"""
        if not users.is_current_user_admin():
            self.error(403)

        code = self.request.get('code')
        label = self.request.get('label')

        language = Language.all().filter('code =', code).get()
        if language is not None:
            self.error(500)
        else:
            language = Language(code=code,
                                label=label,
                                enabled_in_tool=False,
                                enabled_on_site=False)
            for phrase in Phrase.all():
                translation = Translation(phrase=phrase, text='')
                translation.put()
                language.translations.append(translation.key())
            language.put()

        init_cached_languages()

        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('')
Exemplo n.º 2
0
 def get(self):
     """Get all phrases"""
     json = []
     phrases = Phrase.all().order('-date')
     for phrase in phrases:
         json.append({
             'id': phrase.key().id(),
             'text': phrase.text,
         })
     self.response.headers['Content-Type'] = 'application/json'
     self.response.out.write(simplejson.dumps(json))
Exemplo n.º 3
0
 def get(self):
     """Get all phrases"""
     json = []
     phrases = Phrase.all().order('-date')
     for phrase in phrases:
         json.append({
             'id': phrase.key().id(),
             'text': phrase.text,
         })
     self.response.headers['Content-Type'] = 'application/json'
     self.response.out.write(simplejson.dumps(json))
Exemplo n.º 4
0
    def post(self):
        code = self.request.path.split('/')[-2]
        original = self.request.get('original')
        suggestion = self.request.get('suggestion')

        if not code in translations:
            raise Exception('Unknown language code')

        current_user = get_current_youtify_user()
        translation = Translation(text=suggestion, user=current_user)
        phrase = Phrase.all().filter(original=original)
        if phrase is None and users.is_current_user_admin():
            phrase = Phrase(original=original)

        suggestions = getattr(phrase, code)
        suggestions.append(suggestion)
        phrase.save()
Exemplo n.º 5
0
    def post(self):
        """Create a new language and fill it with empty translations"""
        if not users.is_current_user_admin():
            self.error(403)

        code = self.request.get('code')
        label = self.request.get('label')

        language = Language.all().filter('code =', code).get()
        if language is not None:
            self.error(500)
        else:
            language = Language(code=code, label=label, enabled_in_tool=False, enabled_on_site=False)
            for phrase in Phrase.all():
                translation = Translation(phrase=phrase, text='')
                translation.put()
                language.translations.append(translation.key())
            language.put()

        init_cached_languages()

        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('')