summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoren Van Onder <jov@odoo.com>2015-11-20 09:58:33 +0100
committerJoren Van Onder <jov@odoo.com>2015-12-29 09:08:43 +0100
commit7cee96fcd47dc6f4087baf2cd068bb4a11a0d58e (patch)
tree9739725991ec917394d5ddcacdecfc3c61337035
parent8d0cb0990e52bd584466c733ce7d4a787f22c38a (diff)
[FIX] mass_mailing: don't assume the request will have a geoip
geoip is set by the website module. If website is not installed, request.session.geoip won't exist. Because all the geoip logic is in the website module this means that if you don't install the website module all of your tracked links will have an undefined country. This isn't that big of an issue, because as far as I can tell the only default view that displays this country is in website_links. Ideally, the geoip should perhaps be moved to base, but for now this will do.
-rw-r--r--addons/mass_mailing/controllers/main.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/addons/mass_mailing/controllers/main.py b/addons/mass_mailing/controllers/main.py
index 035d22ef09d..6ac211fa25f 100644
--- a/addons/mass_mailing/controllers/main.py
+++ b/addons/mass_mailing/controllers/main.py
@@ -22,5 +22,10 @@ class MassMailController(http.Controller):
@http.route('/r/<string:code>/m/<int:stat_id>', type='http', auth="none")
def full_url_redirect(self, code, stat_id, **post):
cr, uid, context = request.cr, request.uid, request.context
- request.registry['link.tracker.click'].add_click(cr, uid, code, request.httprequest.remote_addr, request.session['geoip'].get('country_code'), stat_id=stat_id, context=context)
+
+ # don't assume geoip is set, it is part of the website module
+ # which mass_mailing doesn't depend on
+ country_code = request.session.get('geoip', False) and request.session.geoip.get('country_code', False)
+
+ request.registry['link.tracker.click'].add_click(cr, uid, code, request.httprequest.remote_addr, country_code, stat_id=stat_id, context=context)
return werkzeug.utils.redirect(request.registry['link.tracker'].get_url_from_code(cr, uid, code, context=context), 301)