diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/builder/views.py | 4 | ||||
-rw-r--r-- | app/lib/django_comments/abstracts.py | 2 | ||||
-rw-r--r-- | app/lib/django_comments/models.py | 2 | ||||
-rw-r--r-- | app/lib/pagination/templates/pagination/pagination.html | 2 | ||||
-rw-r--r-- | app/lib/pagination/templatetags/pagination_tags.py | 6 | ||||
-rw-r--r-- | app/locations/views.py | 10 | ||||
-rw-r--r-- | app/photos/models.py | 5 | ||||
-rw-r--r-- | app/photos/views.py | 13 | ||||
-rw-r--r-- | app/projects/views.py | 6 | ||||
-rw-r--r-- | app/utils/views.py | 4 |
10 files changed, 31 insertions, 23 deletions
diff --git a/app/builder/views.py b/app/builder/views.py index 7491b32..a32d384 100644 --- a/app/builder/views.py +++ b/app/builder/views.py @@ -1,4 +1,4 @@ -from django.shortcuts import render_to_response +from django.shortcuts import render from django.template import RequestContext from builder.base import BuildWriting, BuildWritingFeed, BuildMap, BuildPhotos, BuildProjects, BuildSitemap from src.build import builder as src_builder @@ -82,4 +82,4 @@ def do_build(request): else: options[section]().build() context = {'message': 'Writing %s to Disk' % section} - return render_to_response('admin/message.html', context) + return render(request, 'admin/message.html', context) diff --git a/app/lib/django_comments/abstracts.py b/app/lib/django_comments/abstracts.py index 4fbb94a..f4ff362 100644 --- a/app/lib/django_comments/abstracts.py +++ b/app/lib/django_comments/abstracts.py @@ -6,7 +6,7 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site from django.db import models from django.utils import timezone -from django.utils.encoding import python_2_unicode_compatible +from six import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ try: from django.urls import reverse diff --git a/app/lib/django_comments/models.py b/app/lib/django_comments/models.py index ebf1bc5..204cf2e 100644 --- a/app/lib/django_comments/models.py +++ b/app/lib/django_comments/models.py @@ -1,7 +1,7 @@ +from six import python_2_unicode_compatible from django.conf import settings from django.db import models from django.utils import timezone -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ from .abstracts import ( diff --git a/app/lib/pagination/templates/pagination/pagination.html b/app/lib/pagination/templates/pagination/pagination.html index e2f8e42..0a7f9a4 100644 --- a/app/lib/pagination/templates/pagination/pagination.html +++ b/app/lib/pagination/templates/pagination/pagination.html @@ -1,6 +1,6 @@ {% load pagination_tags %}{% if is_paginated %} <ul class="pages">{% if page_obj.has_previous %} - <li><a href="{% page_path prev_page %}" class="prev"> Newer</a></li>{% endif %}{% for page in pages %}{% if page %}{% if page == page_obj.number %} + <li><a href="{% if prev_page == 1%}/{{request.base_path}}/{%else%}{% page_path prev_page %}{%endif%}" class="prev"> Newer</a></li>{% endif %}{% for page in pages %}{% if page %}{% if page == page_obj.number %} <li class="current page">{{ page }}</li>{% else %} <li><a href="{% if page == 1%}/{{request.base_path}}/{%else%}{% page_path page %}{%endif%}" class="page">{{ page }}</a></li>{% endif %}{% else %} <li>...</li>{% endif %}{% endfor %}{% if page_obj.has_next %} diff --git a/app/lib/pagination/templatetags/pagination_tags.py b/app/lib/pagination/templatetags/pagination_tags.py index 75c23f6..0356f1f 100644 --- a/app/lib/pagination/templatetags/pagination_tags.py +++ b/app/lib/pagination/templatetags/pagination_tags.py @@ -5,7 +5,7 @@ except NameError: import re from django import template from django.db.models.query import QuerySet -from django.core.paginator import Paginator, QuerySetPaginator, InvalidPage +from django.core.paginator import Paginator, InvalidPage register = template.Library() @@ -21,7 +21,7 @@ def page_path(parser, token): raise template.TemplateSyntaxError( 'page_path requires a page template var' ) - + return PagePathNode(bits[1]) class PagePathNode(template.Node): @@ -99,7 +99,7 @@ class AutoPaginateNode(template.Node): value = self.queryset_var.resolve(context) if issubclass(value.__class__, QuerySet): model = value.model - paginator_class = QuerySetPaginator + paginator_class = Paginator else: value = list(value) try: diff --git a/app/locations/views.py b/app/locations/views.py index a6d9ea1..06f7838 100644 --- a/app/locations/views.py +++ b/app/locations/views.py @@ -1,4 +1,4 @@ -from django.shortcuts import render_to_response +from django.shortcuts import render from django.template import RequestContext from django.views.generic import ListView from django.views.generic.detail import DetailView @@ -18,10 +18,10 @@ def map_list(request): 'route_list': Route.objects.all(), 'region_list': Region.objects.all() } - return render_to_response( + return render( + request, 'archives/map.html', context, - context_instance=RequestContext(request) ) class MapList(ListView): @@ -66,10 +66,10 @@ def map_data(request): 'country_list': Country.objects.filter(visited=True).exclude(name='default'), 'region_list': Region.objects.all() } - return render_to_response( + return render( + request, 'archives/map_data.html', context, - context_instance=RequestContext(request) ) diff --git a/app/photos/models.py b/app/photos/models.py index 4bf3759..075808d 100644 --- a/app/photos/models.py +++ b/app/photos/models.py @@ -153,8 +153,9 @@ class LuxImage(models.Model): return "%soriginal/%s/%s.%s" % (settings.IMAGES_URL, self.pub_date.strftime("%Y"), base, self.get_image_ext()) else: if size != 'tn': - s = LuxImageSize.objects.get(name=size) - if s not in self.sizes.all(): + try: + self.sizes.filter(name=size) + except DoesNotExist: print("new size is "+s.name) self.sizes.add(s) return "%s%s/%s_%s.%s" % (settings.IMAGES_URL, self.pub_date.strftime("%Y"), base, size, self.get_image_ext()) diff --git a/app/photos/views.py b/app/photos/views.py index 915b022..070b40d 100644 --- a/app/photos/views.py +++ b/app/photos/views.py @@ -1,5 +1,5 @@ import json -from django.shortcuts import render_to_response, render +from django.shortcuts import render from django.template import RequestContext from django.http import Http404, HttpResponse from django.core import serializers @@ -64,11 +64,18 @@ class OldGalleryList(PaginatedListView): class DailyPhotoList(PaginatedListView): + model=LuxImage template_name = 'archives/photo_daily_list.html' def get_queryset(self): return LuxImage.objects.filter(is_public=True, title__startswith="daily_") + def get_context_data(self, **kwargs): + # Call the base implementation first to get a context + context = super(DailyPhotoList, self).get_context_data(**kwargs) + context['breadcrumbs'] = ['daily',] + return context + def gallery_list(request, page): request.page_url = '/photos/%d/' @@ -84,7 +91,7 @@ def gallery(request, slug): context = { 'object': PhotoGallery.objects.get(set_slug=slug) } - return render_to_response('details/photo_galleries.html', context, context_instance=RequestContext(request)) + return render(request, 'details/photo_galleries.html', context) def photo_json(request, slug): @@ -127,4 +134,4 @@ def gallery_list_by_area(request, slug, page): 'region': region, 'page': page } - return render_to_response("archives/photos.html", context, context_instance=RequestContext(request)) + return render(request, "archives/photos.html", context) diff --git a/app/projects/views.py b/app/projects/views.py index 23500e0..ad5f167 100644 --- a/app/projects/views.py +++ b/app/projects/views.py @@ -1,4 +1,4 @@ -from django.shortcuts import render_to_response, get_object_or_404 +from django.shortcuts import render, get_object_or_404 from django.template import RequestContext from django.apps import apps @@ -26,12 +26,12 @@ def detail(request, slug): "object_list": qs, } template = 'details/%s.html' % (slug) - return render_to_response(template, context, context_instance=RequestContext(request)) + return render(request, template, context) def gif_detail(request, slug): obj = get_object_or_404(AnimatedGif, slug__exact=slug) - return render_to_response('details/gifs.html', {'object': obj}, context_instance=RequestContext(request)) + return render(request, 'details/gifs.html', {'object': obj}) def data_json(request, id): diff --git a/app/utils/views.py b/app/utils/views.py index d4c9eae..db8cb35 100644 --- a/app/utils/views.py +++ b/app/utils/views.py @@ -4,7 +4,6 @@ from django.urls import reverse from django.http import Http404, HttpResponse from django.views.generic import ListView, DetailView from django.apps import apps -from django.shortcuts import render_to_response from django.shortcuts import render from django.template import RequestContext @@ -16,7 +15,8 @@ BREADCRUMBS = { 'SrcPost':'SRC', 'Book':'Book Notes', 'Entry':'Jrnl', - 'NewsletterMailing':'lttr' + 'NewsletterMailing':'lttr', + 'LuxImage':'lttr' } class PaginatedListView(ListView): |