2014-03-19 13:31:21 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2014-03-31 12:19:32 +00:00
|
|
|
import openerp
|
2014-09-03 09:55:00 +00:00
|
|
|
from openerp import http, SUPERUSER_ID
|
2014-07-06 14:44:26 +00:00
|
|
|
from openerp.http import request
|
2014-03-31 12:19:32 +00:00
|
|
|
import time
|
2014-03-28 11:37:15 +00:00
|
|
|
|
|
|
|
GENGO_DEFAULT_LIMIT = 20
|
|
|
|
|
2014-03-19 13:31:21 +00:00
|
|
|
class website_gengo(http.Controller):
|
|
|
|
|
2014-03-24 10:36:31 +00:00
|
|
|
@http.route('/website/get_translated_length', type='json', auth='user', website=True)
|
|
|
|
def get_translated_length(self, translated_ids, lang):
|
2014-03-19 13:31:21 +00:00
|
|
|
ir_translation_obj = request.registry['ir.translation']
|
2014-03-24 10:36:31 +00:00
|
|
|
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'] += len(trans.source.split())
|
2014-03-19 13:31:21 +00:00
|
|
|
return result
|
2014-03-28 06:36:23 +00:00
|
|
|
|
2014-03-25 14:13:08 +00:00
|
|
|
@http.route('/website/check_gengo_set', type='json', auth='user', website=True)
|
|
|
|
def check_gengo_set(self):
|
2014-09-03 09:55:00 +00:00
|
|
|
user = request.registry['res.users'].browse(request.cr, SUPERUSER_ID, request.uid)
|
2014-03-26 07:10:57 +00:00
|
|
|
company_flag = 0
|
2014-03-25 14:13:08 +00:00
|
|
|
if not user.company_id.gengo_public_key or not user.company_id.gengo_private_key:
|
2014-03-26 07:10:57 +00:00
|
|
|
company_flag = user.company_id.id
|
|
|
|
return company_flag
|
2014-03-28 06:36:23 +00:00
|
|
|
|
|
|
|
@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:
|
2014-09-03 09:55:00 +00:00
|
|
|
request.registry['res.company'].write(request.cr, request.uid, user.company_id.id, config)
|
2014-03-28 06:36:23 +00:00
|
|
|
return True
|
2014-03-28 11:37:15 +00:00
|
|
|
|
|
|
|
@http.route('/website/post_gengo_jobs', type='json', auth='user', website=True)
|
2014-03-31 07:06:25 +00:00
|
|
|
def post_gengo_jobs(self):
|
2014-03-28 11:37:15 +00:00
|
|
|
request.registry['base.gengo.translations']._sync_request(request.cr, request.uid, limit=GENGO_DEFAULT_LIMIT, context=request.context)
|
|
|
|
return True
|