[FIX] link_tracker: fix link tracer when no geoip in session

The `geoip` is not always defined in the session,
and therefore one needs to check it's defined before
attempting to use it.

The same is done at different places in the code,
through the different modules.

opw-687783
This commit is contained in:
Denis Ledoux
2016-09-06 12:04:43 +02:00
parent 7970cbe178
commit f19d179bb0
+2 -1
View File
@@ -8,6 +8,7 @@ from openerp.http import request
class link_tracker(http.Controller):
@http.route('/r/<string:code>', type='http', auth='none', website=True)
def full_url_redirect(self, code, **post):
request.env['link.tracker.click'].add_click(code, request.httprequest.remote_addr, request.session['geoip'].get('country_code'), stat_id=False)
country_code = request.session.geoip and request.session.geoip.get('country_code') or False
request.env['link.tracker.click'].add_click(code, request.httprequest.remote_addr, country_code, stat_id=False)
redirect_url = request.env['link.tracker'].get_url_from_code(code)
return werkzeug.utils.redirect(redirect_url or '', 301)