[IMP] added sync option in base_gengo wizard,do not show option in website_gengo
bzr revid: pga@tinyerp.com-20140321071438-kip2lkzlzvm0et7n
This commit is contained in:
parent
0660bf99af
commit
bc0a7cbc0c
|
@ -53,9 +53,12 @@ class base_gengo_translations(osv.osv_memory):
|
||||||
_name = 'base.gengo.translations'
|
_name = 'base.gengo.translations'
|
||||||
_columns = {
|
_columns = {
|
||||||
'restart_send_job': fields.boolean("Restart Sending Job"),
|
'restart_send_job': fields.boolean("Restart Sending Job"),
|
||||||
|
'sync_type': fields.selection([('send', 'Send New Terms'),
|
||||||
|
('receive', 'Receive Translation'),
|
||||||
|
('both', 'Both')], "Sync Type"),
|
||||||
'lang_id': fields.many2one('res.lang', 'Language', required=True),
|
'lang_id': fields.many2one('res.lang', 'Language', required=True),
|
||||||
}
|
}
|
||||||
|
_defaults = {'sync_type' : 'both'}
|
||||||
def gengo_authentication(self, cr, uid, context=None):
|
def gengo_authentication(self, cr, uid, context=None):
|
||||||
'''
|
'''
|
||||||
This method tries to open a connection with Gengo. For that, it uses the Public and Private
|
This method tries to open a connection with Gengo. For that, it uses the Public and Private
|
||||||
|
@ -117,8 +120,10 @@ class base_gengo_translations(osv.osv_memory):
|
||||||
#send immediately a new request for the selected language (if any)
|
#send immediately a new request for the selected language (if any)
|
||||||
ctx = context.copy()
|
ctx = context.copy()
|
||||||
ctx['gengo_language'] = wizard.lang_id.id
|
ctx['gengo_language'] = wizard.lang_id.id
|
||||||
self._sync_request(cr, uid, limit=GENGO_DEFAULT_LIMIT, context=ctx)
|
if wizard.sync_type in ['send','both']:
|
||||||
self._sync_response( cr, uid, limit=GENGO_DEFAULT_LIMIT, context=ctx)
|
self._sync_request(cr, uid, limit=GENGO_DEFAULT_LIMIT, context=ctx)
|
||||||
|
if wizard.sync_type in ['receive','both']:
|
||||||
|
self._sync_response( cr, uid, limit=GENGO_DEFAULT_LIMIT, context=ctx)
|
||||||
#check the cron jobs and eventually restart/recreate them
|
#check the cron jobs and eventually restart/recreate them
|
||||||
if wizard.restart_send_job:
|
if wizard.restart_send_job:
|
||||||
self.do_check_schedular(cr, uid, 'gengo_sync_send_request_scheduler', _('Gengo Sync Translation (Request)'), '_sync_request', context=context)
|
self.do_check_schedular(cr, uid, 'gengo_sync_send_request_scheduler', _('Gengo Sync Translation (Request)'), '_sync_request', context=context)
|
||||||
|
|
|
@ -8,7 +8,14 @@
|
||||||
<form string="Gengo Request Form" version="7.0">
|
<form string="Gengo Request Form" version="7.0">
|
||||||
<group>
|
<group>
|
||||||
<field name="lang_id"/>
|
<field name="lang_id"/>
|
||||||
<field name="restart_send_job"/>
|
</group>
|
||||||
|
<group>
|
||||||
|
<group>
|
||||||
|
<field name="sync_type" widget="radio"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="restart_send_job"/>
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
<button name="act_update" string="Send" type="object" class="oe_highlight"/>
|
<button name="act_update" string="Send" type="object" class="oe_highlight"/>
|
||||||
|
|
|
@ -25,25 +25,34 @@
|
||||||
},
|
},
|
||||||
translation_gengo: function () {
|
translation_gengo: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var dialog = new website.GengoTranslatorDialog();
|
if(!localStorage['website_gengo_nodialog']){
|
||||||
dialog.appendTo($(document.body));
|
var dialog = new website.GengoTranslatorDialog();
|
||||||
self.gengo_translate = true;
|
dialog.appendTo($(document.body));
|
||||||
dialog.on('activate', this, function () {
|
self.gengo_translate = true;
|
||||||
dialog.$el.modal('hide');
|
dialog.on('activate', this, function () {
|
||||||
self.translate().then(function () {
|
localStorage['website_gengo_nodialog'] = dialog.$('input[name=do_not_show]').prop('checked') || '';
|
||||||
self.gengo_translate = false;
|
dialog.$el.modal('hide');
|
||||||
if($('.oe_translatable_todo').length > 0){
|
self.translation_gengo_display()
|
||||||
self.$el.find('form.navbar-form.navbar-left > *').addClass("hidden");
|
|
||||||
self.$el.find('.gengo_post,.gengo_info,.gengo_discard').removeClass("hidden");
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
self.$el.find('form.navbar-form.navbar-left > *').addClass("hidden");
|
|
||||||
self.$el.find('.gengo_inprogress,.gengo_info,.gengo_discard').removeClass("hidden");
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
self.gengo_translate = true;
|
||||||
|
self.translation_gengo_display()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
translation_gengo_display:function(){
|
||||||
|
var self = this;
|
||||||
|
self.translate().then(function () {
|
||||||
|
self.gengo_translate = false;
|
||||||
|
if($('.oe_translatable_todo').length > 0){
|
||||||
|
self.$el.find('form.navbar-form.navbar-left > *').addClass("hidden");
|
||||||
|
self.$el.find('.gengo_post,.gengo_info,.gengo_discard').removeClass("hidden");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
self.$el.find('form.navbar-form.navbar-left > *').addClass("hidden");
|
||||||
|
self.$el.find('.gengo_inprogress,.gengo_info,.gengo_discard').removeClass("hidden");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
translation_gengo_post: function () {
|
translation_gengo_post: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -72,10 +81,12 @@
|
||||||
openerp.jsonRpc('/website/set_translations', 'call', {
|
openerp.jsonRpc('/website/set_translations', 'call', {
|
||||||
'data': trans,
|
'data': trans,
|
||||||
'lang': website.get_context()['lang'],
|
'lang': website.get_context()['lang'],
|
||||||
}).done(function(){
|
}).then(function () {
|
||||||
$('.oe_translatable_todo').addClass('oe_translatable_inprogress').removeClass('oe_translatable_todo');
|
$('.oe_translatable_todo').addClass('oe_translatable_inprogress').removeClass('oe_translatable_todo');
|
||||||
self.$el.find('.gengo_wait').addClass("hidden");
|
self.$el.find('.gengo_wait').addClass("hidden");
|
||||||
self.$el.find('.gengo_inprogress,.gengo_discard').removeClass("hidden");
|
self.$el.find('.gengo_inprogress,.gengo_discard').removeClass("hidden");
|
||||||
|
}).fail(function () {
|
||||||
|
alert("Could not Post translation");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,10 @@
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
<div class="pull-left">
|
||||||
|
<input type="checkbox" name="do_not_show"/>
|
||||||
|
Do not show this dialog later.
|
||||||
|
</div>
|
||||||
<button type="button" data-action="activate" class="btn btn-primary">Ok</button>
|
<button type="button" data-action="activate" class="btn btn-primary">Ok</button>
|
||||||
or
|
or
|
||||||
<a data-action="discard" data-dismiss="modal" href="#">Cancel</a>
|
<a data-action="discard" data-dismiss="modal" href="#">Cancel</a>
|
||||||
|
@ -57,10 +61,10 @@
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<section>
|
<section>
|
||||||
<select class="form-control" required="required" autofocus="autofocus">
|
<select class="form-control" required="required" autofocus="autofocus">
|
||||||
<option value="machine">Translation By Machine</option>
|
<option value="machine">Translation By Machine (Free)</option>
|
||||||
<option value="standard">Standard</option>
|
<option value="standard">Standard - $0.05 per word</option>
|
||||||
<option value="pro">Pro</option>
|
<option value="pro">Pro - $0.10 per word</option>
|
||||||
<option value="ultra">Ultra</option>
|
<option value="ultra">Ultra - $0.15 per word</option>
|
||||||
</select>
|
</select>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue