diff options
-rw-r--r-- | app/blog/admin.py | 11 | ||||
-rw-r--r-- | app/blog/models.py | 16 | ||||
-rw-r--r-- | config/settings/settings.py | 3 | ||||
-rw-r--r-- | config/settings/settings_dev.py | 1 | ||||
-rw-r--r-- | design/templates/details/entry.html | 4 |
5 files changed, 20 insertions, 15 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 bf319ce..0f73f86 100644 --- a/app/blog/models.py +++ b/app/blog/models.py @@ -39,7 +39,7 @@ TEMPLATES = ( ) class PostImage(models.Model): title = models.CharField(max_length=100) - image = models.ImageField(upload_to="%s%s" %(settings.IMAGES_ROOT, datetime.datetime.today().strftime("%Y"))) + image = models.ImageField(upload_to="%s/%s" %(settings.IMAGES_ROOT, datetime.datetime.today().strftime("%Y"))) def __unicode__(self): return self.title @@ -90,6 +90,14 @@ class Entry(models.Model): return '%spost-images/%s/%s' %(settings.IMAGES_URL, image_dir, img) @property + def state(self): + return self.location.state + + @property + def country(self): + return self.location.state.country + + @property def region(self): return self.location.state.country.lux_region @@ -114,8 +122,12 @@ class Entry(models.Model): def save(self): md = image_url_replace(self.body_markdown) - self.body_html = markdown.markdown(self.body_markdown, extensions=['extra',], safe_mode = False) + 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/config/settings/settings.py b/config/settings/settings.py index a2c37d3..608edf8 100644 --- a/config/settings/settings.py +++ b/config/settings/settings.py @@ -37,7 +37,8 @@ GOOGLE_MAPS_API_KEY = MAP_API_KEY = 'ABQIAAAAEZ0Oz7LFDmdS1OBHm6HLgRQT5Lr-mnFT_29 # API key for Flickr imports FLICKR_API_KEY = '7b9d978a440c6ab65a545adc0aa0d693' FLICKR_USER_ID = '85322932@N00' - +#root url +BASE_URL = "http://luxagraf.net/" #path to the folder that holds the generated html files FLATFILES_ROOT = os.path.join(PROJ_ROOT, 'site/') #media and image URLs for the generated html files diff --git a/config/settings/settings_dev.py b/config/settings/settings_dev.py index 1f2e4e9..3cf51d7 100644 --- a/config/settings/settings_dev.py +++ b/config/settings/settings_dev.py @@ -40,6 +40,7 @@ GOOGLE_MAPS_API_KEY = MAP_API_KEY = 'ABQIAAAAEZ0Oz7LFDmdS1OBHm6HLgRQT5Lr-mnFT_29 FLICKR_API_KEY = '7b9d978a440c6ab65a545adc0aa0d693' FLICKR_USER_ID = '85322932@N00' +BASE_URL = "http://127.0.0.1:8000/" #path to the folder that holds the generated html files FLATFILES_ROOT = os.path.join(PROJ_ROOT, 'site/') #media and image URLs for the generated html files diff --git a/design/templates/details/entry.html b/design/templates/details/entry.html index 5209d09..bc23646 100644 --- a/design/templates/details/entry.html +++ b/design/templates/details/entry.html @@ -19,13 +19,13 @@ class="{%if t == 0 or t == 2 %}single{%endif%}{%if t == 1 or t == 3 %}double{%en <article role="main"> <header> <h1>{%if object.template_name == 1 or object.template_name == 3 %}{{object.title|smartypants|safe}}{%else%}{{object.title|smartypants|widont|safe}}{%endif%}</h1> + <time datetime="{{object.pub_date|date:'c'}}" pubdate>{{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"j, Y"}}</span></time> <aside class="geo bl"> - <span class="location" itemprop="geo" itemscope itemtype="http://data-vocabulary.org/Geo">{% if object.country_name == "United States" %}{{object.location_name|smartypants|safe}}, <a href="/writing/united-states/1/" title="travel writing from the United States">{{object.state_name}}</a>{%else%}{{object.location_name|smartypants|safe}}, <a href="/writing/{{object.location.state.country.slug}}/" title="travel writing from {{object.country_name}}">{{object.country_name}}</a>{%endif%} + <span class="location" itemprop="geo" itemscope itemtype="http://data-vocabulary.org/Geo">{% if object.country.name == "United States" %}{{object.location.name|smartypants|safe}}, <a href="/writing/united-states/1/" title="travel writing from the United States">{{object.state}}</a>, U.S.{%else%}{{object.location.name|smartypants|safe}}, <a href="/writing/{{object.country.slug}}/" title="travel writing from {{object.country.name}}">{{object.country.name}}</a>{%endif%} <meta itemprop="latitude" content="{{object.latitude}}" /> <meta itemprop="longitude" content="{{object.longitude}}" /></span> {%comment%} (<a href="" title="">Map</a>, <a href="" title="">Photos</a>){%endcomment%} </aside> - <time datetime="{{object.pub_date|date:'c'}}" pubdate>{{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"j, Y"}}</span></time> </header> <div class="post-body{% with object.template_name as t %}{%if t == 0 or t == 2 %}-single{%endif%}{%if t == 1 or t == 3 %}-double{%endif%}{%endwith%}"> {{object.body_html|smartypants|widont|safe}} |