Skip to content

Commit

Permalink
Make DEFAULT_CENTER importable
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanboniface committed Feb 2, 2013
1 parent a4f4191 commit 9fefcaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion leaflet_storage/forms.py
Expand Up @@ -4,11 +4,16 @@
from django.contrib.gis.geos import Point
from django.utils.translation import ugettext as _
from django.template.defaultfilters import slugify
from django.conf import settings

from vectorformats.formats import geojson, kml, gpx

from .models import Map, Category, Polyline, Polygon, Marker

DEFAULT_lATITUDE = settings.LEAFLET_LATITUDE if hasattr(settings, "LEAFLET_LATITUDE") else 51
DEFAULT_LONGITUDE = settings.LEAFLET_LONGITUDE if hasattr(settings, "LEAFLET_LONGITUDE") else 2
DEFAULT_CENTER = Point(DEFAULT_LONGITUDE, DEFAULT_lATITUDE)


class PlaceholderForm(forms.ModelForm):

Expand Down Expand Up @@ -84,7 +89,7 @@ def clean_slug(self):

def clean_center(self):
if not self.cleaned_data['center']:
point = Point(2, 51)
point = DEFAULT_CENTER
self.cleaned_data['center'] = point
return self.cleaned_data['center']

Expand Down
4 changes: 2 additions & 2 deletions leaflet_storage/tests/base.py
@@ -1,12 +1,12 @@
from django.test import TestCase
from django.contrib.gis.geos import Point
from django.contrib.auth.models import User
from django.utils import simplejson
from django.core.urlresolvers import reverse

import factory

from leaflet_storage.models import Map, TileLayer, Licence, Category, Marker
from leaflet_storage.forms import DEFAULT_CENTER


class LicenceFactory(factory.Factory):
Expand Down Expand Up @@ -41,7 +41,7 @@ class MapFactory(factory.Factory):
FACTORY_FOR = Map
name = "test map"
slug = "test-map"
center = Point(2, 51)
center = DEFAULT_CENTER
licence = factory.SubFactory(LicenceFactory)
owner = factory.SubFactory(UserFactory)

Expand Down

0 comments on commit 9fefcaa

Please sign in to comment.