Mercurial > public > sg101
changeset 1031:e1c03da72818
Get rid of some warnings in Django 1.8.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 20 Dec 2015 22:18:59 -0600 |
parents | d9610b1e2a3d |
children | e932f2ecd4a7 |
files | donations/views.py downloads/views.py forums/views/main.py gcalendar/views.py membermap/views.py sg101/templates/bio/members.html sg101/templates/contact/contact_form.html sg101/templates/forums/forum_index.html sg101/templates/forums/index.html sg101/templates/forums/mod_forum.html sg101/templates/forums/mod_split_topic.html sg101/templates/forums/post_list.html sg101/templates/forums/topic.html sg101/templates/forums/topic_list.html sg101/templates/news/story.html sg101/templates/news/story_summary.html |
diffstat | 16 files changed, 76 insertions(+), 125 deletions(-) [+] |
line wrap: on
line diff
--- 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') -
--- 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', { + }) #######################################################################
--- 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):
--- 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
--- 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):
--- 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 %}
--- 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 @@ <h2>Contact Us</h2> <p>Please use the following form to contact the site management. Your feedback and comments are very important to us.</p> -<form action="{% url 'contact.views.contact_form' %}" method="post">{% csrf_token %} +<form action="{% url 'contact-form' %}" method="post">{% csrf_token %} <table> <tr><th>{{ form.name.label }}:</th><td>{{ form.name.errors }}{{ form.name }}</td></tr> <tr><th>{{ form.email.label }}:</th><td>{{ form.email.errors }}{{ form.email }}</td></tr>
--- 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 %}
--- 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 %}
--- 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 %}
--- 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 %}
--- 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 %}
--- 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 %}
--- 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 %}
--- 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 @@ <a href="{{ story.get_absolute_url }}"><img src="{% static "icons/link.png" %}" alt="Story Permalink" title="Story Permalink" /></a> {% if user.is_authenticated %} - <a href="{% url 'news.views.email_story' story.id %}"><img src="{% static "icons/email_go.png" %}" + <a href="{% url 'news-email_story' story.id %}"><img src="{% static "icons/email_go.png" %}" alt="Send this story to a friend" title="Send this story to a friend" /></a> {% endif %} </p>
--- 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 %} <a href="{{ story.get_absolute_url }}"><img src="{% static "icons/link.png" %}" alt="Permalink" title="Permalink" /></a> {% if user.is_authenticated %} -<a href="{% url 'news.views.email_story' story.id %}"><img src="{% static "icons/email_go.png" %}" +<a href="{% url 'news-email_story' story.id %}"><img src="{% static "icons/email_go.png" %}" alt="Send this story to a friend" title="Send this story to a friend" /></a> {% endif %} </p>