[IMP] Redirect admin to configurations page for Google Calendar API when trying synchro but not still configured
bzr revid: jke@openerp.com-20131219165011-xgy18qcr1n1q4jz1
This commit is contained in:
parent
e70d4e88ae
commit
59c932477e
|
@ -28,9 +28,14 @@ class google_calendar_controller(http.Controller):
|
||||||
client_id = gs_obj.get_client_id(request.cr, request.uid,'calendar',context=kw.get('LocalContext'))
|
client_id = gs_obj.get_client_id(request.cr, request.uid,'calendar',context=kw.get('LocalContext'))
|
||||||
|
|
||||||
if not client_id or client_id == '':
|
if not client_id or client_id == '':
|
||||||
|
action = ''
|
||||||
|
if gc_obj.can_authorize_google(request.cr,request.uid):
|
||||||
|
dummy, action = request.registry.get('ir.model.data').get_object_reference(request.cr, request.uid, 'google_calendar', 'action_config_settings_google_calendar')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"status" : "NeedConfigFromAdmin",
|
"status" : "NeedConfigFromAdmin",
|
||||||
"url" : ''
|
"url" : '',
|
||||||
|
"action" : action
|
||||||
}
|
}
|
||||||
|
|
||||||
# Checking that user have already accepted OpenERP to access his calendar !
|
# Checking that user have already accepted OpenERP to access his calendar !
|
||||||
|
|
|
@ -663,7 +663,7 @@ class google_calendar(osv.osv):
|
||||||
def need_authorize(self,cr,uid,context=None):
|
def need_authorize(self,cr,uid,context=None):
|
||||||
current_user = self.pool.get('res.users').browse(cr,uid,uid,context=context)
|
current_user = self.pool.get('res.users').browse(cr,uid,uid,context=context)
|
||||||
return current_user.google_calendar_rtoken == False
|
return current_user.google_calendar_rtoken == False
|
||||||
|
|
||||||
def get_calendar_scope(self,RO=False):
|
def get_calendar_scope(self,RO=False):
|
||||||
readonly = RO and '.readonly' or ''
|
readonly = RO and '.readonly' or ''
|
||||||
return 'https://www.googleapis.com/auth/calendar%s' % (readonly)
|
return 'https://www.googleapis.com/auth/calendar%s' % (readonly)
|
||||||
|
@ -671,6 +671,9 @@ class google_calendar(osv.osv):
|
||||||
def authorize_google_uri(self,cr,uid,from_url='http://www.openerp.com',context=None):
|
def authorize_google_uri(self,cr,uid,from_url='http://www.openerp.com',context=None):
|
||||||
url = self.pool.get('google.service')._get_authorize_uri(cr,uid,from_url,self.STR_SERVICE,scope=self.get_calendar_scope(),context=context)
|
url = self.pool.get('google.service')._get_authorize_uri(cr,uid,from_url,self.STR_SERVICE,scope=self.get_calendar_scope(),context=context)
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
def can_authorize_google(self,cr,uid,context=None):
|
||||||
|
return self.pool['res.users'].has_group(cr, uid, 'base.group_erp_manager')
|
||||||
|
|
||||||
def set_all_tokens(self,cr,uid,authorization_code,context=None):
|
def set_all_tokens(self,cr,uid,authorization_code,context=None):
|
||||||
gs_pool = self.pool.get('google.service')
|
gs_pool = self.pool.get('google.service')
|
||||||
|
|
|
@ -32,8 +32,16 @@ openerp.google_calendar = function(instance) {
|
||||||
window.location = o.url;
|
window.location = o.url;
|
||||||
}
|
}
|
||||||
else if (o.status == "NeedConfigFromAdmin") {
|
else if (o.status == "NeedConfigFromAdmin") {
|
||||||
alert(_t("Admin need to configure Google Synchronization before to use it !"));
|
|
||||||
window.location = o.url;
|
if (typeof o.action !== 'undefined' && parseInt(o.action)) {
|
||||||
|
if (confirm(_t("An admin need to configure Google Synchronization before to use it, do you want to configure it now ? !"))) {
|
||||||
|
self.do_action(o.action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
alert(_t("An admin need to configure Google Synchronization before to use it !"));
|
||||||
|
}
|
||||||
|
//window.location = o.url;
|
||||||
}
|
}
|
||||||
else if (o.status == "NeedRefresh"){
|
else if (o.status == "NeedRefresh"){
|
||||||
self.$calendar.fullCalendar('refetchEvents');
|
self.$calendar.fullCalendar('refetchEvents');
|
||||||
|
|
Loading…
Reference in New Issue