Skip to content

Commit

Permalink
[IMP] website_hr_recruitment: use session geoip for country default v…
Browse files Browse the repository at this point in the history
…alue
  • Loading branch information
Gorash committed Jun 23, 2014
1 parent 176a6aa commit be4dddc
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions addons/website_hr_recruitment/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
from openerp.addons.web import http
from openerp.tools.translate import _
from openerp.addons.web.http import request
import logging
_logger = logging.getLogger(__name__)

try:
import GeoIP
except ImportError:
GeoIP = None
_logger.warn("Please install GeoIP python module to use events localisation.")

class website_hr_recruitment(http.Controller):
@http.route([
Expand Down Expand Up @@ -43,9 +35,8 @@ def jobs(self, country=None, department=None, office_id=None):
countries = set(o.country_id for o in offices if o.country_id)

# Default search by user country
if not country and not department and not office_id and GeoIP:
GI = GeoIP.open('/usr/share/GeoIP/GeoIP.dat', 0)
country_code = GI.country_code_by_addr(request.httprequest.remote_addr)
if not country and not department and not office_id:
country_code = request.session['geoip'].get('country_code')
if country_code:
country_ids = request.registry.get('res.country').search(cr, uid, [('code', '=', country_code)], context=context)
if country_ids:
Expand Down

0 comments on commit be4dddc

Please sign in to comment.