# HG changeset patch # User Brian Neal # Date 1450671539 21600 # Node ID e1c03da72818623887decc3519398422937a55b0 # Parent d9610b1e2a3d5efb389b9da1bae321f3e937fc19 Get rid of some warnings in Django 1.8. diff -r d9610b1e2a3d -r e1c03da72818 donations/views.py --- a/donations/views.py Wed Dec 16 21:21:33 2015 -0600 +++ b/donations/views.py Sun Dec 20 22:18:59 2015 -0600 @@ -6,12 +6,10 @@ import datetime import logging -from django.shortcuts import render_to_response -from django.template import RequestContext +from django.shortcuts import render from django.conf import settings from django.contrib.sites.models import Site from django.http import HttpResponse -from django.http import HttpResponseServerError from django.contrib.auth.models import User from django.views.decorators.csrf import csrf_exempt @@ -49,8 +47,8 @@ req.add_header("Content-type", "application/x-www-form-urlencoded") try: response = urllib2.urlopen(req) - except URLError, e: - logging.exception('IPN: exception verifying IPN: %s', e) + except urllib2.URLError as ex: + logging.exception('IPN: exception verifying IPN: %s', ex) return None return response.read() @@ -61,7 +59,7 @@ current_site = Site.objects.get_current() form_action, business = paypal_params() - return render_to_response('donations/index.html', { + return render(request, 'donations/index.html', { 'goal': settings.DONATIONS_GOAL, 'gross': gross, 'net': net, @@ -74,8 +72,7 @@ 'item_number': settings.DONATIONS_ITEM_NUM, 'item_anon_number': settings.DONATIONS_ITEM_ANON_NUM, 'domain': current_site.domain, - }, - context_instance = RequestContext(request)) + }) @csrf_exempt @@ -218,4 +215,3 @@ else: donation.save() logging.info('IPN: donation saved') - diff -r d9610b1e2a3d -r e1c03da72818 downloads/views.py --- a/downloads/views.py Wed Dec 16 21:21:33 2015 -0600 +++ b/downloads/views.py Sun Dec 20 22:18:59 2015 -0600 @@ -3,8 +3,7 @@ """ import json -from django.shortcuts import render_to_response, get_object_or_404 -from django.template import RequestContext +from django.shortcuts import render, get_object_or_404 from django.contrib.auth.decorators import login_required from django.http import Http404 from django.http import HttpResponse @@ -37,11 +36,10 @@ def index(request): categories = Category.objects.all() total_dls = Download.public_objects.all().count() - return render_to_response('downloads/index.html', { + return render(request, 'downloads/index.html', { 'categories': categories, 'total_dls': total_dls, - }, - context_instance = RequestContext(request)) + }) ####################################################################### # Maps URL component to database field name for the Download table: @@ -71,12 +69,11 @@ except InvalidPage: raise Http404 - return render_to_response('downloads/download_list.html', { + return render(request, 'downloads/download_list.html', { 's' : sort, 'category' : cat, 'page' : the_page, - }, - context_instance = RequestContext(request)) + }) ####################################################################### @@ -93,11 +90,10 @@ except InvalidPage: raise Http404 - return render_to_response('downloads/download_summary.html', { + return render(request, 'downloads/download_summary.html', { 'page': the_page, 'title': 'Newest Downloads', - }, - context_instance = RequestContext(request)) + }) ####################################################################### @@ -114,11 +110,10 @@ except InvalidPage: raise Http404 - return render_to_response('downloads/download_summary.html', { + return render(request, 'downloads/download_summary.html', { 'page': the_page, 'title': 'Popular Downloads', - }, - context_instance = RequestContext(request)) + }) ####################################################################### @@ -134,11 +129,10 @@ except InvalidPage: raise Http404 - return render_to_response('downloads/download_summary.html', { + return render(request, 'downloads/download_summary.html', { 'page': the_page, 'title': 'Highest Rated Downloads', - }, - context_instance = RequestContext(request)) + }) ####################################################################### @@ -147,10 +141,9 @@ download = get_object_or_404(Download.public_objects, pk=id) if not download.is_public: raise Http404 - return render_to_response('downloads/download_detail.html', { + return render(request, 'downloads/download_detail.html', { 'download' : download, - }, - context_instance = RequestContext(request)) + }) ####################################################################### @@ -171,18 +164,16 @@ else: form = AddDownloadForm() - return render_to_response('downloads/add.html', { + return render(request, 'downloads/add.html', { 'add_form': form, - }, - context_instance=RequestContext(request)) + }) ####################################################################### @login_required def thanks(request): - return render_to_response('downloads/thanks.html', { - }, - context_instance=RequestContext(request)) + return render(request, 'downloads/thanks.html', { + }) ####################################################################### diff -r d9610b1e2a3d -r e1c03da72818 forums/views/main.py --- a/forums/views/main.py Wed Dec 16 21:21:33 2015 -0600 +++ b/forums/views/main.py Sun Dec 20 22:18:59 2015 -0600 @@ -15,9 +15,8 @@ from django.core.urlresolvers import reverse from django.core.paginator import InvalidPage from django.shortcuts import get_object_or_404 -from django.shortcuts import render_to_response +from django.shortcuts import render from django.template.loader import render_to_string -from django.template import RequestContext from django.views.decorators.http import require_POST from django.db.models import F @@ -108,11 +107,10 @@ cmpdef = lambda a, b: cmp(a['cat'].position, b['cat'].position) cats = sorted(cats.values(), cmpdef) - return render_to_response('forums/index.html', { + return render(request, 'forums/index.html', { 'cats': cats, 'feeds': feeds, - }, - context_instance=RequestContext(request)) + }) def forum_index(request, slug): @@ -147,14 +145,13 @@ can_moderate = perms.can_moderate(forum, request.user) - return render_to_response('forums/forum_index.html', { + return render(request, 'forums/forum_index.html', { 'forum': forum, 'feed': feed, 'page': page, 'page_nav': page_nav, 'can_moderate': can_moderate, - }, - context_instance=RequestContext(request)) + }) def topic_index(request, id): @@ -223,7 +220,7 @@ is_subscribed = request.user.is_authenticated() and ( topic in request.user.subscriptions.all()) - return render_to_response('forums/topic.html', { + return render(request, 'forums/topic.html', { 'forum': topic.forum, 'topic': topic, 'page': page, @@ -234,8 +231,7 @@ 'form': NewPostForm(initial={'topic_id': topic.id}), 'is_favorite': is_favorite, 'is_subscribed': is_subscribed, - }, - context_instance=RequestContext(request)) + }) def topic_unread(request, id): @@ -308,11 +304,10 @@ else: form = NewTopicForm(request.user, forum) - return render_to_response('forums/new_topic.html', { + return render(request, 'forums/new_topic.html', { 'forum': forum, 'form': form, - }, - context_instance=RequestContext(request)) + }) @login_required @@ -321,11 +316,10 @@ This view displays the success page for a newly created topic. """ topic = get_object_or_404(Topic.objects.select_related(), pk=tid) - return render_to_response('forums/new_topic_thanks.html', { + return render(request, 'forums/new_topic_thanks.html', { 'forum': topic.forum, 'topic': topic, - }, - context_instance=RequestContext(request)) + }) @require_POST @@ -352,12 +346,11 @@ _bump_post_count(request.user) _update_last_visit(request.user, form.topic, datetime.datetime.now()) - return render_to_response('forums/display_post.html', { + return render(request, 'forums/display_post.html', { 'post': post, 'can_moderate': perms.can_moderate(form.topic.forum, request.user), 'can_reply': True, - }, - context_instance=RequestContext(request)) + }) # The client side javascript is pretty simplistic right now and we don't # want to change it yet. It is expecting a single error string. Just grab @@ -459,14 +452,13 @@ else: form = PostForm(instance=post, topic_name=topic_name) - return render_to_response('forums/edit_post.html', { + return render(request, 'forums/edit_post.html', { 'forum': post.topic.forum, 'topic': post.topic, 'post': post, 'form': form, 'can_moderate': can_moderate, - }, - context_instance=RequestContext(request)) + }) @require_POST @@ -615,13 +607,12 @@ else: form = None - return render_to_response('forums/new_post.html', { + return render(request, 'forums/new_post.html', { 'forum': topic.forum, 'topic': topic, 'form': form, 'can_post': can_post, - }, - context_instance=RequestContext(request)) + }) @login_required @@ -685,12 +676,11 @@ else: form = MoveTopicForm(request.user) - return render_to_response('forums/move_topic.html', { + return render(request, 'forums/move_topic.html', { 'forum': topic.forum, 'topic': topic, 'form': form, - }, - context_instance=RequestContext(request)) + }) @login_required @@ -740,13 +730,12 @@ if form is None: form = MoveTopicForm(request.user, hide_label=True) - return render_to_response('forums/mod_forum.html', { + return render(request, 'forums/mod_forum.html', { 'forum': forum, 'page': page, 'page_nav': page_nav, 'form': form, - }, - context_instance=RequestContext(request)) + }) @login_required @@ -757,7 +746,8 @@ """ forum_ids = Forum.objects.forum_ids_for_user(request.user) - tlvs = TopicLastVisit.objects.filter(user=request.user, + TopicLastVisit.objects.filter( + user=request.user, topic__forum__id__in=forum_ids).delete() now = datetime.datetime.now() @@ -809,13 +799,12 @@ posts = topic.posts.select_related() - return render_to_response('forums/mod_split_topic.html', { + return render(request, 'forums/mod_split_topic.html', { 'forum': topic.forum, 'topic': topic, 'posts': posts, 'form': form, - }, - context_instance=RequestContext(request)) + }) @login_required @@ -836,13 +825,12 @@ # we do this for the template since it is rendered twice page_nav = render_to_string('forums/pagination.html', {'page': page}) - return render_to_response('forums/topic_list.html', { + return render(request, 'forums/topic_list.html', { 'title': 'Topics With Unread Posts', 'page': page, 'page_nav': page_nav, 'unread': True, - }, - context_instance=RequestContext(request)) + }) def unanswered_topics(request): @@ -865,13 +853,12 @@ # we do this for the template since it is rendered twice page_nav = render_to_string('forums/pagination.html', {'page': page}) - return render_to_response('forums/topic_list.html', { + return render(request, 'forums/topic_list.html', { 'title': 'Unanswered Topics', 'page': page, 'page_nav': page_nav, 'unread': False, - }, - context_instance=RequestContext(request)) + }) def active_topics(request, num): @@ -910,13 +897,12 @@ title = 'Last %d Active Topics' % num - return render_to_response('forums/topic_list.html', { + return render(request, 'forums/topic_list.html', { 'title': title, 'page': page, 'page_nav': page_nav, 'unread': False, - }, - context_instance=RequestContext(request)) + }) @login_required @@ -945,11 +931,10 @@ ip_users = sorted(set(Post.objects.filter( user_ip=post.user_ip).values_list('user__username', flat=True))) - return render_to_response('forums/post_ip.html', { + return render(request, 'forums/post_ip.html', { 'post': post, 'ip_users': ip_users, - }, - context_instance=RequestContext(request)) + }) def _user_posts(request, target_user, req_user, page_title): @@ -972,12 +957,11 @@ # we do this for the template since it is rendered twice page_nav = render_to_string('forums/pagination.html', {'page': page}) - return render_to_response('forums/post_list.html', { + return render(request, 'forums/post_list.html', { 'title': page_title, 'page': page, 'page_nav': page_nav, - }, - context_instance=RequestContext(request)) + }) def _bump_post_count(user): diff -r d9610b1e2a3d -r e1c03da72818 gcalendar/views.py --- a/gcalendar/views.py Wed Dec 16 21:21:33 2015 -0600 +++ b/gcalendar/views.py Sun Dec 20 22:18:59 2015 -0600 @@ -10,9 +10,8 @@ from django.http import HttpResponseForbidden from django.http import HttpResponseRedirect from django.http import Http404 -from django.shortcuts import render_to_response from django.shortcuts import get_object_or_404 -from django.template import RequestContext +from django.shortcuts import render from gcalendar.forms import EventEntryForm from gcalendar.models import Event @@ -25,10 +24,9 @@ else: tz = 'US/Pacific' - return render_to_response('gcalendar/index.html', { + return render(request, 'gcalendar/index.html', { 'tz': tz, - }, - context_instance = RequestContext(request)) + }) @login_required @@ -44,18 +42,16 @@ else: form = EventEntryForm() - return render_to_response('gcalendar/event.html', { + return render(request, 'gcalendar/event.html', { 'title': 'Add Calendar Event', 'form': form, - }, - context_instance = RequestContext(request)) + }) @login_required def add_thanks(request): - return render_to_response('gcalendar/thanks_add.html', { - }, - context_instance = RequestContext(request)) + return render(request, 'gcalendar/thanks_add.html', { + }) @login_required @@ -71,10 +67,9 @@ except EmptyPage: page = paginator.page(paginator.num_pages) - return render_to_response('gcalendar/edit.html', { + return render(request, 'gcalendar/edit.html', { 'page': page, - }, - context_instance = RequestContext(request)) + }) @login_required @@ -95,18 +90,16 @@ else: form = EventEntryForm(instance=event) - return render_to_response('gcalendar/event.html', { + return render(request, 'gcalendar/event.html', { 'title': 'Change Calendar Event', 'form': form, - }, - context_instance = RequestContext(request)) + }) @login_required def edit_thanks(request): - return render_to_response('gcalendar/thanks_edit.html', { - }, - context_instance = RequestContext(request)) + return render(request, 'gcalendar/thanks_edit.html', { + }) def delete_event(request): @@ -127,6 +120,3 @@ return HttpResponse(id) return HttpResponseForbidden() - - -# vim: ts=4 sw=4 diff -r d9610b1e2a3d -r e1c03da72818 membermap/views.py --- a/membermap/views.py Wed Dec 16 21:21:33 2015 -0600 +++ b/membermap/views.py Sun Dec 20 22:18:59 2015 -0600 @@ -4,9 +4,8 @@ """ import json -from django.shortcuts import render_to_response +from django.shortcuts import render from django.template.loader import render_to_string -from django.template import RequestContext from django.http import HttpResponse from django.http import HttpResponseBadRequest from django.http import HttpResponseForbidden @@ -37,10 +36,9 @@ else: form = MapEntryForm() - return render_to_response('membermap/index.html', { + return render(request, 'membermap/index.html', { 'form': form, - }, - context_instance = RequestContext(request)) + }) def query(request): diff -r d9610b1e2a3d -r e1c03da72818 sg101/templates/bio/members.html --- a/sg101/templates/bio/members.html Wed Dec 16 21:21:33 2015 -0600 +++ b/sg101/templates/bio/members.html Sun Dec 20 22:18:59 2015 -0600 @@ -1,5 +1,4 @@ {% extends 'bio/base.html' %} -{% load cycle from future %} {% load static from staticfiles %} {% load bio_tags %} {% load messages_tags %} diff -r d9610b1e2a3d -r e1c03da72818 sg101/templates/contact/contact_form.html --- a/sg101/templates/contact/contact_form.html Wed Dec 16 21:21:33 2015 -0600 +++ b/sg101/templates/contact/contact_form.html Sun Dec 20 22:18:59 2015 -0600 @@ -4,7 +4,7 @@

Contact Us

Please use the following form to contact the site management. Your feedback and comments are very important to us.

-
{% csrf_token %} +{% csrf_token %} diff -r d9610b1e2a3d -r e1c03da72818 sg101/templates/forums/forum_index.html --- a/sg101/templates/forums/forum_index.html Wed Dec 16 21:21:33 2015 -0600 +++ b/sg101/templates/forums/forum_index.html Sun Dec 20 22:18:59 2015 -0600 @@ -1,5 +1,4 @@ {% extends 'base.html' %} -{% load cycle from future %} {% load forum_tags %} {% load bio_tags %} {% block custom_head %} diff -r d9610b1e2a3d -r e1c03da72818 sg101/templates/forums/index.html --- a/sg101/templates/forums/index.html Wed Dec 16 21:21:33 2015 -0600 +++ b/sg101/templates/forums/index.html Sun Dec 20 22:18:59 2015 -0600 @@ -1,5 +1,4 @@ {% extends 'base.html' %} -{% load cycle from future %} {% load static from staticfiles %} {% load accounts_tags %} {% load cache %} diff -r d9610b1e2a3d -r e1c03da72818 sg101/templates/forums/mod_forum.html --- a/sg101/templates/forums/mod_forum.html Wed Dec 16 21:21:33 2015 -0600 +++ b/sg101/templates/forums/mod_forum.html Sun Dec 20 22:18:59 2015 -0600 @@ -1,5 +1,4 @@ {% extends 'base.html' %} -{% load cycle from future %} {% load static from staticfiles %} {% load bio_tags %} {% load forum_tags %} diff -r d9610b1e2a3d -r e1c03da72818 sg101/templates/forums/mod_split_topic.html --- a/sg101/templates/forums/mod_split_topic.html Wed Dec 16 21:21:33 2015 -0600 +++ b/sg101/templates/forums/mod_split_topic.html Sun Dec 20 22:18:59 2015 -0600 @@ -1,6 +1,5 @@ {% extends 'base.html' %} {% load static from staticfiles %} -{% load cycle from future %} {% load forum_tags %} {% block title %}Forums: Split Topic{% endblock %} {% block custom_js %}{{ form.media }}{% endblock %} diff -r d9610b1e2a3d -r e1c03da72818 sg101/templates/forums/post_list.html --- a/sg101/templates/forums/post_list.html Wed Dec 16 21:21:33 2015 -0600 +++ b/sg101/templates/forums/post_list.html Sun Dec 20 22:18:59 2015 -0600 @@ -1,5 +1,4 @@ {% extends 'base.html' %} -{% load cycle from future %} {% load forum_tags %} {% block title %}Forums: {{ title }}{% endblock %} {% block custom_js %} diff -r d9610b1e2a3d -r e1c03da72818 sg101/templates/forums/topic.html --- a/sg101/templates/forums/topic.html Wed Dec 16 21:21:33 2015 -0600 +++ b/sg101/templates/forums/topic.html Sun Dec 20 22:18:59 2015 -0600 @@ -1,5 +1,4 @@ {% extends 'base.html' %} -{% load cycle from future %} {% load forum_tags %} {% load core_tags %} {% load script_tags %} diff -r d9610b1e2a3d -r e1c03da72818 sg101/templates/forums/topic_list.html --- a/sg101/templates/forums/topic_list.html Wed Dec 16 21:21:33 2015 -0600 +++ b/sg101/templates/forums/topic_list.html Sun Dec 20 22:18:59 2015 -0600 @@ -1,5 +1,4 @@ {% extends 'base.html' %} -{% load cycle from future %} {% load bio_tags %} {% load forum_tags %} {% block title %}Forums: {{ title }}{% endblock %} diff -r d9610b1e2a3d -r e1c03da72818 sg101/templates/news/story.html --- a/sg101/templates/news/story.html Wed Dec 16 21:21:33 2015 -0600 +++ b/sg101/templates/news/story.html Sun Dec 20 22:18:59 2015 -0600 @@ -39,7 +39,7 @@ Story Permalink {% if user.is_authenticated %} - Send this story to a friend {% endif %}

diff -r d9610b1e2a3d -r e1c03da72818 sg101/templates/news/story_summary.html --- a/sg101/templates/news/story_summary.html Wed Dec 16 21:21:33 2015 -0600 +++ b/sg101/templates/news/story_summary.html Sun Dec 20 22:18:59 2015 -0600 @@ -42,7 +42,7 @@ {% endif %} Permalink {% if user.is_authenticated %} -Send this story to a friend {% endif %}

{{ form.name.label }}:{{ form.name.errors }}{{ form.name }}
{{ form.email.label }}:{{ form.email.errors }}{{ form.email }}