[MIG] website_gengo: Migrate into new api

This commit is contained in:
Jigar Patel
2016-07-14 11:01:09 +02:00
committed by Yannick Tivisse
parent c9dcc6fa76
commit 5f146ac42d
6 changed files with 34 additions and 35 deletions
+1 -4
View File
@@ -4,7 +4,6 @@
{
'name': 'Website Gengo Translator',
'category': 'Website',
'version': '1.0',
'description': """
Website Gengo Translator
========================
@@ -17,7 +16,5 @@ Translate you website in one click
],
'data': [
'views/website_gengo_templates.xml',
],
'qweb': [],
'installable': True,
]
}
@@ -1 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import main
+16 -19
View File
@@ -1,41 +1,38 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import openerp
from openerp import http, SUPERUSER_ID
from openerp.http import request
import time
from odoo import http
from odoo.http import request
GENGO_DEFAULT_LIMIT = 20
class website_gengo(http.Controller):
class WebsiteGengo(http.Controller):
@http.route('/website/get_translated_length', type='json', auth='user', website=True)
def get_translated_length(self, translated_ids, lang):
ir_translation_obj = request.registry['ir.translation']
result={"done":0}
gengo_translation_ids = ir_translation_obj.search(request.cr, request.uid, [('id','in',translated_ids),('gengo_translation','!=', False)])
for trans in ir_translation_obj.browse(request.cr, request.uid, gengo_translation_ids):
result = {"done": 0}
gengo_translation_ids = request.env['ir.translation'].search([('id', 'in', translated_ids), ('gengo_translation', '!=', False)])
for trans in gengo_translation_ids:
result['done'] += len(trans.source.split())
return result
@http.route('/website/check_gengo_set', type='json', auth='user', website=True)
def check_gengo_set(self):
user = request.registry['res.users'].browse(request.cr, SUPERUSER_ID, request.uid)
company = request.env.user.sudo().company_id
company_flag = 0
if not user.company_id.gengo_public_key or not user.company_id.gengo_private_key:
company_flag = user.company_id.id
if not company.gengo_public_key or not company.gengo_private_key:
company_flag = company.id
return company_flag
@http.route('/website/set_gengo_config', type='json', auth='user', website=True)
def set_gengo_config(self,config):
user = request.registry['res.users'].browse(request.cr, request.uid, request.uid)
if user.company_id:
request.registry['res.company'].write(request.cr, request.uid, user.company_id.id, config)
def set_gengo_config(self, config):
request.env.user.company_id.write(config)
return True
@http.route('/website/post_gengo_jobs', type='json', auth='user', website=True)
def post_gengo_jobs(self):
request.registry['base.gengo.translations']._sync_request(request.cr, request.uid, limit=GENGO_DEFAULT_LIMIT, context=request.context)
request.env['base.gengo.translations']._sync_request(limit=GENGO_DEFAULT_LIMIT)
return True
@http.route('/website_gengo/set_translations', type='json', auth='user', website=True)
+3
View File
@@ -1 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import base_gengo_translations
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp.osv import osv
from odoo import models
class base_gengo_translations(osv.TransientModel):
class BaseGengoTranslations(models.TransientModel):
_inherit = 'base.gengo.translations'
# update GROUPS, that are the groups allowing to access the gengo key.
# this is done here because in the base_gengo module, the various website
@@ -1,13 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<template id="gengo_assets_editor" inherit_id="website.assets_editor" name="Editor Head">
<xpath expr='.' position="inside">
<link rel="stylesheet" href="/website_gengo/static/src/css/website_gengo.css"></link>
<script type="text/javascript" src="/website_gengo/static/src/js/website_gengo.js"></script>
</xpath>
</template>
<template id="gengo_assets_editor" inherit_id="website.assets_editor" name="Editor Head">
<xpath expr='.' position="inside">
<link rel="stylesheet" href="/website_gengo/static/src/css/website_gengo.css" />
<script type="text/javascript" src="/website_gengo/static/src/js/website_gengo.js" />
</xpath>
</template>
</data>
</openerp>
</odoo>