summaryrefslogtreecommitdiff
path: root/apps/blog
diff options
context:
space:
mode:
Diffstat (limited to 'apps/blog')
-rw-r--r--apps/blog/admin.py11
-rw-r--r--apps/blog/models.py9
-rw-r--r--apps/blog/signals.py34
-rw-r--r--apps/blog/views.py14
4 files changed, 51 insertions, 17 deletions
diff --git a/apps/blog/admin.py b/apps/blog/admin.py
index d641b5b..78ad458 100644
--- a/apps/blog/admin.py
+++ b/apps/blog/admin.py
@@ -17,16 +17,19 @@ class EntryAdmin(OSMGeoAdmin):
else:
field = super(EntryAdmin,self).formfield_for_dbfield(db_field,**kwargs)
return field
- list_display = ('title', 'pub_date','enable_comments', 'status','region','location')
+ list_display = ('title', 'pub_date','enable_comments', 'status','region','location','photo_gallery')
search_fields = ['title', 'body_markdown']
prepopulated_fields = {"slug" : ('title',)}
list_filter = ('pub_date', 'enable_comments', 'status','region','location')
fieldsets = (
- ('Entry', {'fields': ('title','body_markdown', ('location','region'), 'pub_date', ('status','enable_comments'), 'tags', 'slug'), 'classes': ('show','extrapretty','wide')}),
+ ('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', 'title_keywords'), 'classes': ('collapse', 'wide')}),
)
- extra_js = [GMAP.api_url + GMAP.key]
- map_template = 'gis/admin/google.html'
+
+ class Media:
+ js = ['/media/admin/custom/model.js']
+ #extra_js = [GMAP.api_url + GMAP.key]
+ #map_template = 'gis/admin/google.html'
# Default GeoDjango OpenLayers map options
# Uncomment and modify as desired
# To learn more about this jargon visit:
diff --git a/apps/blog/models.py b/apps/blog/models.py
index 5093f5b..7ad415c 100644
--- a/apps/blog/models.py
+++ b/apps/blog/models.py
@@ -13,9 +13,10 @@ from tagging.models import Tag
from photos.models import PhotoGallery
from locations.models import Location,Region
#from locations.signals import create_location_item
+from blog.signals import update_recent
def get_upload_path(self, filename):
- return "images/post-thumbs/heloo/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename)
+ return "images/post-thumbs/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename)
def markdown_processor(md):
processed = markdown.markdown(md, safe_mode = False).split('<break>')
@@ -109,4 +110,8 @@ class LatestFull(Feed):
return Entry.objects.filter(status__exact=1).order_by('-pub_date')[:10]
-#signals.post_save.connect(create_location_item, sender=Entry) \ No newline at end of file
+from django.dispatch import dispatcher
+from django.db.models import signals
+
+signals.post_save.connect(update_recent, sender=Entry)
+
diff --git a/apps/blog/signals.py b/apps/blog/signals.py
new file mode 100644
index 0000000..0f3c9c4
--- /dev/null
+++ b/apps/blog/signals.py
@@ -0,0 +1,34 @@
+from django.template.loader import render_to_string
+from django.conf import settings
+from django.template import Context
+from django.db.models import get_model
+
+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:6]}
+ c = Context(qs)
+ t = render_to_string('includes/recent_entries_template.html',c)
+ fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/recent_entries.html')
+ file = open(fpath, 'w')
+ file.write(t)
+ file.close()
+ # Update map template
+ import codecs
+ qs = model.objects.filter(status__exact=1)
+ cl = Country.objects.filter(visited=True).exclude(name='default')
+ rl = Region.objects.all()
+ c = Context({'object_list':qs, 'country_list':cl,'region_list':rl})
+ t = render_to_string('includes/map_entry_list_template.html',c)
+ fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/map_entry_list.html')
+ file = codecs.open(fpath, 'w','utf8')
+ file.write(t)
+ file.close()
+ c = Context({'country_list':cl,'region_list':rl})
+ t = render_to_string('includes/map_sidebar_template.html',c)
+ fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/map_sidebar.html')
+ file = codecs.open(fpath, 'w','utf8')
+ file.write(t)
+ file.close() \ No newline at end of file
diff --git a/apps/blog/views.py b/apps/blog/views.py
index 9641813..6ccdc28 100644
--- a/apps/blog/views.py
+++ b/apps/blog/views.py
@@ -9,10 +9,9 @@ from blog.models import Entry
from locations.models import Region, Country
def home(request):
- featured = Entry.objects.filter(status__exact=1).order_by('-pub_date')[:1].get()
+ featured = Entry.objects.filter(status__exact=1).latest()
context = {
'featured': featured,
- 'object_list': Entry.objects.all().exclude(id=featured.id).order_by('-pub_date')[:5],
}
return render_to_response('archives/homepage.html', context, context_instance = RequestContext(request))
@@ -32,13 +31,8 @@ List of all writing
def entry_list(request,page):
request.page_url = '/writing/%d/'
request.page = int(page)
- qs = Entry.objects.filter(status__exact=1).order_by('-pub_date')
- context = {
- 'country_list': Country.objects.filter(visited=True),
- 'region_list': Region.objects.all()
- }
- return object_list(request, queryset=qs, template_name='archives/writing.html',
- extra_context=context)
+ qs = Entry.objects.filter(status__exact=1).order_by('-pub_date').select_related()
+ return object_list(request, queryset=qs, template_name='archives/writing.html')
"""
@@ -57,8 +51,6 @@ def entry_list_by_area(request,slug,page):
raise Http404
context = {
'region': region,
- 'country_list': Country.objects.filter(visited=True),
- 'region_list': Region.objects.all()
}
return object_list(request, queryset=qs, template_name='archives/writing.html',
extra_context=context)