Changeset - 66dbfac066b0
[Not reviewed]
Brett Smith (brett) - 4 years ago 2017-11-07 14:00:48
brett@sfconservancy.org
Migrate RequestContext users to render() calls.

This was necessary because render_to_response no longer takes a
context_instance. We were always using this to pass in a RequestContext,
which the render shortcut can already do, so switch to that.
8 files changed with 21 insertions and 36 deletions:
0 comments (0 inline, 0 general)
www/conservancy/__init__.py
Show inline comments
 
import hashlib
 

	
 
from django.conf import settings
 
from django.shortcuts import render_to_response
 
from django.template import RequestContext
 

	
 
# This is backwards compatibilty support for a custom function we wrote
 
# ourselves that is no longer necessary in modern Django.
 
from django.shortcuts import render as render_template_with_context
 

	
 
class ParameterValidator(object):
 
    def __init__(self, given_hash_or_params, params_hash_key=None):
 
        if params_hash_key is None:
...
 
@@ -41,8 +44,3 @@ class ParameterValidator(object):
 

	
 
    def fail(self):
 
        self.valid = False
 

	
 

	
 
def render_template_with_context(request, template_path, context_dict):
 
    return render_to_response(template_path, context_dict,
 
                              context_instance=RequestContext(request))
www/conservancy/apps/blog/views.py
Show inline comments
...
 
@@ -4,8 +4,7 @@ from django.views.generic import ListView
 
from django.views.generic.dates import YearArchiveView, MonthArchiveView, DayArchiveView, DateDetailView
 
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
 
from conservancy.apps.staff.models import Person
 
from django.shortcuts import get_object_or_404, render_to_response
 
from django.template import RequestContext
 
from django.shortcuts import get_object_or_404, render
 
from datetime import datetime
 

	
 
def OR_filter(field_name, objs):
...
 
@@ -65,7 +64,7 @@ def custom_index(request, queryset, *args, **kwargs):
 

	
 
    extra_context['blog_entries'] = blog_entries
 

	
 
    return render_to_response('blog/entry_list.html', extra_context, context_instance=RequestContext(request))
 
    return render(request, 'blog/entry_list.html', extra_context)
 

	
 
def techblog_redirect(request):
 
    """Redirect from the old 'techblog' to the new blog
...
 
@@ -103,8 +102,7 @@ def query(request):
 
                                               entry__isnull=False).distinct(),
 
                         key=last_name)
 
        tags = EntryTag.objects.all().order_by('label')
 
        return render_to_response('blog/query.html',
 
                                  {'authors': authors, 'tags': tags}, context_instance=RequestContext(request))
 
        return render(request, 'blog/query.html', {'authors': authors, 'tags': tags})
 

	
 
def relative_redirect(request, path):
 
    from django import http
www/conservancy/apps/contacts/views.py
Show inline comments
 
from django.shortcuts import render_to_response
 
from django.template import RequestContext
 
from django.shortcuts import render
 
from django import forms
 
from conservancy.apps.contacts.models import ContactEntry
 
from django.forms import ModelForm
...
 
@@ -18,10 +17,8 @@ def subscribe(request):
 
        form = ContactEntryForm(request.POST)
 
        if form.is_valid():
 
            form.save()
 
            return render_to_response('contacts/subscribe_success.html',
 
                                      {'form': form.cleaned_data}, context_instance=RequestContext(request))
 
            return render(request, 'contacts/subscribe_success.html', {'form': form.cleaned_data})
 
    else:
 
        form = ContactEntryForm()
 

	
 
    return render_to_response('contacts/subscribe.html',
 
                              {'form': form}, context_instance=RequestContext(request))
 
    return render(request, 'contacts/subscribe.html', {'form': form})
www/conservancy/apps/events/views.py
Show inline comments
 
# from django.views.generic.list_detail import object_list
 
from django.shortcuts import render_to_response
 
from django.template import RequestContext
 
from django.shortcuts import render
 
from django.http import Http404, HttpResponse
 
from django.template import loader
 
from django.core.exceptions import ObjectDoesNotExist
...
 
@@ -21,7 +20,7 @@ def event_detail(request, year, slug, queryset, **kwargs):
 
        event = queryset.get(date__year=year, slug__exact=slug)
 
    except ObjectDoesNotExist:
 
        raise Http404, "Event does not exist"
 
    return render_to_response('events/event_detail.html', {'event': event}, context_instance=RequestContext(request))
 
    return render(request, 'events/event_detail.html', {'event': event})
 

	
 
def custom_index(request, queryset, *args, **kwargs):
 
    """Scrollable index of future and past events, with date index.
www/conservancy/apps/news/views.py
Show inline comments
 
# from django.views.generic.list_detail import object_list
 
from django.views.generic import ListView
 
from django.template import RequestContext
 
from django.shortcuts import render_to_response
 
from django.shortcuts import render
 
from django.views.generic.dates import YearArchiveView, MonthArchiveView, DayArchiveView, DateDetailView
 
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
 
from conservancy.apps.news.models import ExternalArticle
...
 
@@ -42,7 +41,7 @@ def listing(request, *args, **kwargs):
 
        # If page is out of range (e.g. 9999), deliver last page of results.
 
        news = paginator.page(paginator.num_pages)
 

	
 
    return render_to_response('news/pressrelease_list.html', {"news": news, "date_list" : date_list}, context_instance=RequestContext(request))
 
    return render(request, 'news/pressrelease_list.html', {"news": news, "date_list" : date_list})
 

	
 
class NewsYearArchiveView(YearArchiveView):
 
    # queryset = Article.objects.all()
www/conservancy/apps/summit_registration/views.py
Show inline comments
 
from django.shortcuts import render_to_response
 
from django.template import RequestContext
 
from django.shortcuts import render
 
from django import forms
 
from django.template import RequestContext
 
from conervancy.apps.summit_registration.models import SummitRegistration
 

	
 
def register(request):
...
 
@@ -21,10 +19,8 @@ def register(request):
 
        form = SummitForm(request.POST)
 
        if form.is_valid():
 
            form.save()
 
            return render_to_response('summit_registration/register_success.html',
 
                                      {'form': form.cleaned_data}, context_instance=RequestContext(request))
 
            return render(reqeust, 'summit_registration/register_success.html', {'form': form.cleaned_data})
 
    else:
 
        form = SummitForm()
 

	
 
    return render_to_response('summit_registration/register.html',
 
                              {'form': form}, context_instance=RequestContext(request))
 
    return render(request, 'summit_registration/register.html', {'form': form})
www/conservancy/feeds.py
Show inline comments
...
 
@@ -2,8 +2,7 @@ from django.contrib.syndication.views import Feed
 
from django.utils.feedgenerator import Rss201rev2Feed 
 
from conservancy.apps.news.models import PressRelease
 
from conservancy.apps.blog.models import Entry as BlogEntry
 
from django.template import RequestContext
 
from django.shortcuts import render_to_response
 
from django.shortcuts import render
 
from django.conf import settings
 
from datetime import datetime
 

	
...
 
@@ -255,4 +254,4 @@ def view(request):
 
    """
 

	
 
    feeds = (PressReleaseFeed, BlogFeed, OmnibusFeed)
 
    return render_to_response("feeds.html", {'feeds': feeds}, context_instance=RequestContext(request))
 
    return render(request, "feeds.html", {'feeds': feeds})
www/conservancy/sponsors.py
Show inline comments
 
from django.shortcuts import render_to_response
 
from django.template import RequestContext
 
from django.shortcuts import render
 
from conservancy.apps.supporters.models import Supporter as Supporter
 
from datetime import datetime, timedelta
 

	
...
 
@@ -19,4 +18,4 @@ def view(request):
 
        'supporters_count' : supporters_count,
 
        'anonymous_count' : anonymous_count
 
    }
 
    return render_to_response("sponsors.html", c, context_instance=RequestContext(request))
 
    return render(request, "sponsors.html", c)
0 comments (0 inline, 0 general)