Skip to content

Commit

Permalink
Download geoip first
Browse files Browse the repository at this point in the history
  • Loading branch information
thoas committed Mar 15, 2016
1 parent d58cc8e commit cb17484
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ geoip:
@(mkdir -p data/{geoip,geoip2})
@(wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz)
@(wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz)
@(gunzip -d GeoLite2-City.mmdb.gz > data/geoip2/)
@(gunzip -d GeoLiteCity.dat.gz > data/geoip/)
@(gunzip -d GeoLite2-City.mmdb.gz > data/geoip2/GeoLite2-City.mmdb)
@(gunzip -d GeoLiteCity.dat.gz > data/geoip/GeoLiteCity.dat)

migrate:
@(ENV=example python manage.py makemigrations safety)
Expand Down
1 change: 1 addition & 0 deletions safety/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from importlib import import_module # noqa

from django.contrib.gis.geoip2 import HAS_GEOIP2

if HAS_GEOIP2:
from django.contrib.gis.geoip2 import GeoIP2 as GeoIP # noqa
else:
Expand Down
6 changes: 4 additions & 2 deletions safety/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _

from . import utils
from . import managers


Expand Down Expand Up @@ -57,7 +56,10 @@ def __str__(self):
return '%s (%s)' % (self.user, self.device)

def delete_store_session(self):
store = utils.get_session_store()
from .utils import get_session_store

store = get_session_store()

if store.exists(session_key=self.session_key):
store.delete(session_key=self.session_key)

Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ whitelist_externals =
make
changedir = {toxinidir}
commands =
make geoip
make test

[testenv:py27-django19nogeoip2]
Expand Down

0 comments on commit cb17484

Please sign in to comment.