summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/blog/admin.py11
-rw-r--r--app/blog/models.py4
-rw-r--r--app/locations/models.py16
3 files changed, 21 insertions, 10 deletions
diff --git a/app/blog/admin.py b/app/blog/admin.py
index c4b7e77..c0d72d9 100644
--- a/app/blog/admin.py
+++ b/app/blog/admin.py
@@ -3,12 +3,10 @@ from django import forms
from blog.models import Entry, PostImage, EntryAside
from blog.widgets import AdminImageWidget
from django.contrib.gis.admin import OSMGeoAdmin
-from django.contrib.gis.maps.google import GoogleMap
from django.conf import settings
from models import *
-GMAP = GoogleMap(key=settings.GOOGLE_MAPS_API_KEY)
class EntryAsideInline(admin.TabularInline):
model = EntryAside
@@ -24,15 +22,8 @@ class BlogEntryForm(forms.ModelForm):
widgets = {
'body_markdown': forms.Textarea(attrs={'rows':50, 'cols':100}),
}
- def clean_point(self):
- try:
- location = Location.objects.filter(geometry__contains=self.cleaned_data['point']).get()
- self.location = location
- except Location.DoesNotExist:
- raise forms.ValidationError("There is no location associated with that point")
- return self.cleaned_data['point']
-
+
class EntryAdmin(OSMGeoAdmin):
form = BlogEntryForm
inlines = [EntryAsideInline,]
diff --git a/app/blog/models.py b/app/blog/models.py
index b7c7d87..80ec303 100644
--- a/app/blog/models.py
+++ b/app/blog/models.py
@@ -116,6 +116,10 @@ class Entry(models.Model):
md = image_url_replace(self.body_markdown)
self.body_html = markdown.markdown(md, extensions=['extra',], safe_mode = False)
self.dek == markdown.markdown(self.dek, safe_mode = False)
+ try:
+ self.location = Location.objects.filter(geometry__contains=self.point).get()
+ except Location.DoesNotExist:
+ raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" %(settings.BASE_URL))
super(Entry, self).save()
class EntryAside(models.Model):
diff --git a/app/locations/models.py b/app/locations/models.py
index e088697..6fc85cf 100644
--- a/app/locations/models.py
+++ b/app/locations/models.py
@@ -159,6 +159,22 @@ class Location(models.Model):
def __unicode__(self): return self.name
+class BirdingLocation(models.Model):
+ location = models.ForeignKey(Location)
+ name = models.CharField(max_length=50)
+ slug = models.SlugField()
+ date_visited = models.DateTimeField('Date visited',null=True)
+ point = models.PointField()
+ # GeoManager, a subclass that adds a rich set of geospatial queryset methods
+ objects = models.GeoManager()
+
+ def get_absolute_url(self):
+ return "/birdinglocations/%s/%s/%s/" % (self.state.country.slug, self.state.slug, self.slug)
+
+
+ def __unicode__(self): return self.name
+
+
class Route(models.Model):
name = models.CharField(max_length=200)
slug = models.SlugField()