summaryrefslogtreecommitdiff
path: root/addons/website/controllers/backend.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2017-04-05 11:50:43 +0200
committerYannick Tivisse <yti@odoo.com>2017-06-19 17:37:38 +0200
commite331c0bd19c4738b5646bb6fe9ccb959e14b3d9d (patch)
treea480ce7e3622b1c52d52807a7817b24fffc3e529 /addons/website/controllers/backend.py
parentac23ca499ed34337a692fd01ee1d207b40d30926 (diff)
[IMP] website: improve setting ga_client_id from dashboard
It now update the website settings parameter use_google_analytics_dashboard so that the settings are correctly updated with the user choice. Implementation is changed so that the dashboard uses a jsonRpc call instead of directly calling ir_config_parameter set_param.
Diffstat (limited to 'addons/website/controllers/backend.py')
-rw-r--r--addons/website/controllers/backend.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/addons/website/controllers/backend.py b/addons/website/controllers/backend.py
index 0aeb2540133..8a59d730714 100644
--- a/addons/website/controllers/backend.py
+++ b/addons/website/controllers/backend.py
@@ -35,3 +35,25 @@ class WebsiteBackend(http.Controller):
ga_client_id = request.env['ir.config_parameter'].sudo().get_param('google_management_client_id', default='')
dashboard_data['dashboards']['visits']['ga_client_id'] = ga_client_id
return dashboard_data
+
+ @http.route('/website/dashboard/set_ga_client_id', type='json', auth='user')
+ def website_set_ga_client_id(self, ga_client_id):
+ if not request.env.user.has_group('base.group_system'):
+ return {
+ 'error': {
+ 'title': 'Access Error',
+ 'message': 'You do not have sufficient rights to perform that action.',
+ }
+ }
+ if not ga_client_id.endswith('.apps.googleusercontent.com') or ga_client_id.startswith(" "):
+ return {
+ 'error': {
+ 'title': 'Incorrect Client ID',
+ 'message': 'The Google Analytics Client ID you have entered seems incorrect.',
+ }
+ }
+ request.env['website.config.setting'].create({
+ 'use_google_analytics_dashboard': True,
+ 'google_management_client_id': ga_client_id,
+ })
+ return True