summaryrefslogtreecommitdiff
path: root/apps/blog
diff options
context:
space:
mode:
authorluxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f>2010-03-28 18:00:17 +0000
committerluxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f>2010-03-28 18:00:17 +0000
commit0282141a50433312df9f9be2188ccf8ae198b666 (patch)
tree9f135d466a6bd3ebe05a07eacb061009d0ba71d9 /apps/blog
parent393bfd7ad1f49f473708c7bef336a529aee6a0d8 (diff)
visual redesign
Diffstat (limited to 'apps/blog')
-rw-r--r--apps/blog/admin.py2
-rw-r--r--apps/blog/models.py33
-rw-r--r--apps/blog/signals.py2
-rw-r--r--apps/blog/views.py17
4 files changed, 44 insertions, 10 deletions
diff --git a/apps/blog/admin.py b/apps/blog/admin.py
index af94079..6ea9ea5 100644
--- a/apps/blog/admin.py
+++ b/apps/blog/admin.py
@@ -23,7 +23,7 @@ class EntryAdmin(OSMGeoAdmin):
list_filter = ('pub_date', 'enable_comments', 'status','region','location')
fieldsets = (
('Entry', {'fields': ('title','body_markdown', ('location','region'), 'pub_date', ('status','enable_comments'), 'tags', 'slug','photo_gallery'), 'classes': ('show','extrapretty','wide')}),
- ('Pub Location', {'fields': ('point',('thumbnail',),'dek', 'topics', 'meta_description'), 'classes': ('collapse', 'wide')}),
+ ('Pub Location', {'fields': ('point',('image','thumbnail',),'dek', 'topics', 'meta_description','template_name'), 'classes': ('collapse', 'wide')}),
)
class Media:
diff --git a/apps/blog/models.py b/apps/blog/models.py
index fb0dac6..c3b5a3a 100644
--- a/apps/blog/models.py
+++ b/apps/blog/models.py
@@ -16,14 +16,29 @@ from locations.models import Location,Region
from blog.signals import update_recent
def get_upload_path(self, filename):
- return "images/post-thumbs/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename)
+ return "images/post-images/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename)
+
+def get_tn_path(self, filename):
+ return "images/post-thumbnail/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename)
+
def markdown_processor(md):
- processed = markdown.markdown(md, safe_mode = False).split('<break>')
+ processed = markdown.markdown(md, ['footnotes'],safe_mode = False).split('<break>')
html = processed[0]+processed[1]
lede = processed[0]
return html, lede
+PUB_STATUS = (
+ (0, 'Draft'),
+ (1, 'Published'),
+ )
+
+TEMPLATES = (
+ (0, 'single'),
+ (1, 'double'),
+ (2, 'single-dark'),
+ (3, 'double-dark'),
+ )
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")))
@@ -59,15 +74,13 @@ class Entry(models.Model):
point = models.PointField(null=True)
location = models.ForeignKey(Location, null=True)
region = models.ForeignKey(Region, null=True)
- PUB_STATUS = (
- (0, 'Draft'),
- (1, 'Published'),
- )
status = models.IntegerField(choices=PUB_STATUS, default=0)
photo_gallery = models.ForeignKey(PhotoGallery, blank=True, null=True, verbose_name='photo set')
- thumbnail = models.FileField(upload_to=get_upload_path, null=True,blank=True)
+ image = models.FileField(upload_to=get_upload_path, null=True,blank=True)
+ thumbnail = models.FileField(upload_to=get_tn_path, null=True,blank=True)
meta_description = models.CharField(max_length=256, null=True, blank=True)
topics = models.ManyToManyField(Topic, blank=True)
+ template_name = models.IntegerField(choices=TEMPLATES, default=0)
@property
def longitude(self):
@@ -108,6 +121,12 @@ class Entry(models.Model):
else:
return '%s%s' %(settings.IMAGES_URL, self.thumbnail.url[33:])
+ def get_image_url(self):
+ if settings.DEVELOPMENT == True:
+ return '%s%s' %(settings.IMAGES_URL, self.image.url[35:])
+ else:
+ return '%s%s' %(settings.IMAGES_URL, self.image.url[33:])
+
def save(self):
html,lede = markdown_processor(self.body_markdown)
self.body_html = html
diff --git a/apps/blog/signals.py b/apps/blog/signals.py
index 41025f1..9809f6f 100644
--- a/apps/blog/signals.py
+++ b/apps/blog/signals.py
@@ -8,7 +8,7 @@ from locations.models import Region,Country
def update_recent(sender, instance, signal, *args, **kwargs):
# Update recent entries static file
model = get_model('blog', 'entry')
- qs = {'object_list': model.objects.filter(status__exact=1).order_by('-pub_date')[1:5]}
+ qs = {'object_list': model.objects.filter(status__exact=1).order_by('-pub_date')[1:4]}
c = Context(qs)
t = render_to_string('includes/recent_entries_template.html',c)
fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/recent_entries.html')
diff --git a/apps/blog/views.py b/apps/blog/views.py
index bd583df..20044b0 100644
--- a/apps/blog/views.py
+++ b/apps/blog/views.py
@@ -3,16 +3,20 @@ from django.template import RequestContext
from django.views.generic.date_based import object_detail
from django.views.generic.list_detail import object_list
from django.http import Http404
+from django.conf import settings
from blog.models import Entry, Topic
from locations.models import Region, Country
-from photos.models import Photo
+from photos.models import Photo, PhotoGallery
+from chunks.models import Chunk
def home(request):
featured = Entry.objects.filter(status__exact=1).latest()
+ gallery = PhotoGallery.objects.latest()
context = {
'featured': featured,
+ 'gallery': gallery
}
return render_to_response('archives/homepage.html', context, context_instance = RequestContext(request))
@@ -67,3 +71,14 @@ def entry_list_by_area(request,slug,page):
return object_list(request, queryset=qs, template_name='archives/writing.html',
extra_context=context)
+def about(request):
+ top = Chunk.objects.get(key='about_top')
+ middle = Chunk.objects.get(key='about_middle')
+ bottom = Chunk.objects.get(key='about_bottom')
+ context = {
+ 'top': top,
+ 'middle': middle,
+ 'bottom': bottom,
+ 'IMAGES_URL' : settings.IMAGES_URL
+ }
+ return render_to_response('details/about.html', context, context_instance=RequestContext(request)) \ No newline at end of file