diff options
author | luxagraf <sng@luxagraf.net> | 2013-04-23 22:18:04 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2013-04-23 22:18:04 -0400 |
commit | 33cf5ef19cd578fcbc5962764d72bbd7310bfb89 (patch) | |
tree | a84907902337b626be85e644633681c538c74e05 /app/blog | |
parent | 4b963b007e47feedce22938c0831d0f3bcf54f84 (diff) |
swtiched from google maps api to OSM with leaflet
Diffstat (limited to 'app/blog')
-rw-r--r-- | app/blog/urls.py | 14 | ||||
-rw-r--r-- | app/blog/views.py | 64 |
2 files changed, 27 insertions, 51 deletions
diff --git a/app/blog/urls.py b/app/blog/urls.py index 57a3e7a..6bd6538 100644 --- a/app/blog/urls.py +++ b/app/blog/urls.py @@ -1,15 +1,13 @@ -from django.conf.urls.defaults import * -from django.views.generic.list_detail import object_list -from django.views.generic.simple import redirect_to - +from django.conf.urls import * +from django.views.generic.base import RedirectView from blog.models import Entry - +from blog.views import BlogEntryListView urlpatterns = patterns('', (r'(?P<slug>[-\w]+)/(?P<page>\d+)/$', 'blog.views.entry_list_by_area'), - (r'(?P<page>\d+)/$', 'blog.views.entry_list'), - (r'(?P<slug>[-\w]+)/$', redirect_to, {'url': '/writing/%(slug)s/1/'}), - (r'', redirect_to, {'url': '/writing/1/'}), + (r'(?P<page>\d+)/$', BlogEntryListView.as_view()), + (r'(?P<slug>[-\w]+)/$', RedirectView.as_view(url="/writing/%(slug)s/1/")), + (r'', RedirectView.as_view(url="/writing/1/")), ) diff --git a/app/blog/views.py b/app/blog/views.py index e23acff..67b6f41 100644 --- a/app/blog/views.py +++ b/app/blog/views.py @@ -1,22 +1,16 @@ from django.shortcuts import render_to_response,get_object_or_404 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 django.views.generic import ListView - -from blog.models import Entry, Topic +from blog.models import Entry from locations.models import Region, Country from photos.models import Photo, PhotoGallery -#from chunks.models import Chunk def home(request): - qs = Entry.objects.filter(status__exact=1).select_related()[:4] - #gallery = PhotoGallery.objects.latest() context = { - 'object_list': qs, - #'gallery': gallery + 'object_list': Entry.objects.filter(status__exact=1).select_related()[:4] } return render_to_response('archives/homepage.html', context, context_instance = RequestContext(request)) @@ -33,56 +27,40 @@ def entry_detail(request, year, month, day, slug): """ List of all writing """ -def entry_list(request,page): - request.page_url = '/writing/%d/' - request.page = int(page) - try: - is_build = request.POST['builder'] - extra_context={ - 'page':page, - 'MEDIA_URL': settings.BAKED_MEDIA_URL - } - except KeyError: - extra_context={'page':page} - qs = Entry.objects.filter(status__exact=1).order_by('-pub_date').select_related() - return object_list(request, queryset=qs, template_name='archives/writing.html',extra_context=extra_context) +class BlogEntryListView(ListView): + template_name="archives/writing.html" + model = Entry + def get_context_data(self, **kwargs): + context = super(BlogEntryListView, self).get_context_data(**kwargs) + context.update({ + 'page': self.kwargs['page'] + }) + self.request.page_url = '/writing/%d/' + self.request.page = self.kwargs['page'] + return context """ -List of all writing +Grabs entries by region or country """ -def topic_list(request,slug,page): - request.page_url = '/topics/'+slug+'/%d/' - request.page = int(page) - topic = Topic.objects.get(slug=slug) - qs = Entry.objects.filter(status__exact=1,topics=topic).order_by('-pub_date').select_related() - return object_list(request, queryset=qs, template_name='archives/topics.html',extra_context={'page':page}) -""" -Grabs entries by region or country -""" def entry_list_by_area(request,slug,page): request.page_url = '/writing/'+slug+'/%d/' request.page = int(page) try: region = Region.objects.get(slug__exact=slug) qs = Entry.objects.filter(status__exact=1,region = region).order_by('-pub_date') - except KeyError: + except: region = Country.objects.get(slug__exact=slug) qs = Entry.objects.filter(status__exact=1,location__state__country = region).order_by('-pub_date') if not region: raise Http404 - try: - is_build = request.POST['builder'] - extra_context={ - 'region': region, - 'MEDIA_URL': settings.BAKED_MEDIA_URL - } - except: - extra_context={'region': region,} - return object_list(request, queryset=qs, template_name='archives/writing.html', - extra_context=extra_context) + context = { + 'region': region, + 'object_list': qs, + } + return render_to_response("archives/writing.html", context, context_instance=RequestContext(request)) """ def about(request): |