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
15 lines
631 B
Python
15 lines
631 B
Python
# -*- coding: utf-8 -*-
|
|
import werkzeug
|
|
|
|
from openerp.addons.web import http
|
|
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):
|
|
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)
|