-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MERGE] forward port of branch saas-4 up to f68c835
- Loading branch information
Showing
34 changed files
with
287 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,53 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import openerp | ||
from openerp import SUPERUSER_ID | ||
from openerp.addons.web import http | ||
from openerp.addons.web.http import request | ||
|
||
from werkzeug.wrappers import BaseResponse as Response | ||
|
||
import json | ||
|
||
|
||
class website_gengo(http.Controller): | ||
|
||
def get_gengo_key(self, cr): | ||
icp = request.registry['ir.config_parameter'] | ||
return icp.get_param(cr, SUPERUSER_ID, request.registry['base.gengo.translations'].GENGO_KEY, default="") | ||
|
||
@http.route('/website/gengo_callback', type='http', auth='none') | ||
def gengo_callback(self,**post): | ||
def gengo_callback(self, **post): | ||
cr, uid, context = request.cr, openerp.SUPERUSER_ID, request.context | ||
translation_pool = request.registry['ir.translation'] | ||
if post and post.get('job'): | ||
job = json.loads(post['job']) | ||
if post and post.get('job') and post.get('pgk'): | ||
if post.get('pgk') != self.get_gengo_key(cr): | ||
return Response("Bad authentication - 403/412", status=412) | ||
job = json.loads(post['job'], 'utf-8') | ||
tid = job.get('custom_data', False) | ||
if (job.get('status') == 'approved') and tid: | ||
term = translation_pool.browse(cr, uid, int(tid), context=context) | ||
if term.job_id <> job.get('job_id'): | ||
raise 'Error' | ||
vals = {'state': 'translated', 'value': job.get('body_tgt')} | ||
translation_pool.write(cr, uid, [int(tid)], vals, context=context) | ||
if term.src != job.get('body_src'): | ||
return Response("Text Altered - Not saved", status=100) | ||
domain = [ | ||
'|', | ||
('id', "=", int(tid)), | ||
'&', '&', '&', '&', '&', | ||
('state', '=', term.state), | ||
('gengo_translation', '=', term.gengo_translation), | ||
('src', "=", term.src), | ||
('type', "=", term.type), | ||
('name', "=", term.name), | ||
('lang', "=", term.lang), | ||
#('order_id', "=", term.order_id), | ||
] | ||
|
||
all_ir_tanslations = translation_pool.search(cr, uid, domain, context=context or {}) | ||
|
||
if all_ir_tanslations: | ||
vals = {'state': 'translated', 'value': job.get('body_tgt')} | ||
translation_pool.write(cr, uid, all_ir_tanslations, vals, context=context) | ||
return Response("OK", status=200) | ||
else: | ||
return Response("No terms found", status=104) | ||
return Response("Not saved", status=100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.