diff options
| author | David Beguin <dbe@odoo.com> | 2019-09-06 13:38:29 +0000 |
|---|---|---|
| committer | Aurélien Warnon <awa@odoo.com> | 2019-09-20 14:44:56 +0000 |
| commit | 17e84025239ed78716ed5d5d92c0ee0e10fbfb29 (patch) | |
| tree | 8b73e1c9dc05ea950a92f9f8621e6a4220687576 /addons/website/controllers | |
| parent | 08108486d5af4125324190eb61a6be0dedcba7a7 (diff) | |
[IMP] website : store visitor timezone
In order to be able to send push notifications using recipients timezone,
the visitor timezone is now stored in DB.
The visitor timezone is only updated once, when found_visitor_timezone
cannot be found in localstorage. Once the timezone is updated,
found_visitor_timezone is added to localstorage.
Task ID : 1936643
PR #34973
Diffstat (limited to 'addons/website/controllers')
| -rw-r--r-- | addons/website/controllers/main.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index f91870adfaf..6ac7ef197f8 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -6,6 +6,7 @@ import json import os import re import logging +import pytz import requests import werkzeug.utils import werkzeug.wrappers @@ -397,6 +398,15 @@ class Website(Home): res[id_or_xml_id] = View.render_template(id_or_xml_id, values) return res + @http.route(['/website/update_visitor_timezone'], type='json', auth="public", website=True) + def update_visitor_timezone(self, timezone): + visitor_sudo = request.env['website.visitor']._get_visitor_from_request() + if visitor_sudo: + if timezone in pytz.all_timezones: + visitor_sudo.write({'timezone': timezone}) + return True + return False + # ------------------------------------------------------ # Server actions # ------------------------------------------------------ |
