Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Jun 18, 2014
2 parents 67dc412 + 6ab9fb4 commit 45fc877
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CHANGELOG
0.13.6 (unreleased)
-------------------

- Nothing changed yet.
* Django Leaflet forms fiels without libgeos installed (thanks Florent Lebreton)


0.13.5 (2014-06-18)
Expand Down
4 changes: 2 additions & 2 deletions leaflet/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
GeoJSONField = type(object)
try:
from django.contrib.gis.db.models import GeometryField
from .forms.widgets import LeafletWidget
except ImportError:
GeometryField = type(object)
from django.forms.widgets import Textarea as LeafletWidget

from .forms.widgets import LeafletWidget


class LeafletGeoAdmin(ModelAdmin):
Expand Down
11 changes: 10 additions & 1 deletion leaflet/forms/backport.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

from django.conf import settings
from django.contrib.gis import gdal
from django.contrib.gis.geos import GEOSGeometry, GEOSException
from django.forms.widgets import Widget
from django.template import loader
from django.utils import six
Expand All @@ -43,6 +42,16 @@
from django.utils.translation import ugettext_lazy as _
from django.core import validators

try:
from django.contrib.gis.geos import GEOSGeometry
except ImportError:
from .nogeos import GEOSGeometry

try:
from django.contrib.gis.geos import GEOSException
except ImportError:
from .nogeos import GEOSException

logger = logging.getLogger('django.contrib.gis')


Expand Down
16 changes: 16 additions & 0 deletions leaflet/forms/nogeos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-


class GEOSGeometry(object):
"""
A simple mock of django.contrib.gis.geos.GEOSGeometry to make
django-leaflet work with only django-geojson (without libgeos)
"""
def __init__(self, geo_input, srid=None):
self.srid = srid
self.geojson = geo_input
return


class GEOSException(Exception):
pass

0 comments on commit 45fc877

Please sign in to comment.