Mercurial > public > sg101
comparison forums/views/favorites.py @ 1032:e932f2ecd4a7
Django 1.8 warnings / tech debt cleanup.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 26 Dec 2015 15:10:55 -0600 |
parents | b347a31d12dd |
children |
comparison
equal
deleted
inserted
replaced
1031:e1c03da72818 | 1032:e932f2ecd4a7 |
---|---|
3 """ | 3 """ |
4 from django.contrib.auth.decorators import login_required | 4 from django.contrib.auth.decorators import login_required |
5 from django.core.urlresolvers import reverse | 5 from django.core.urlresolvers import reverse |
6 from django.views.decorators.http import require_POST | 6 from django.views.decorators.http import require_POST |
7 from django.shortcuts import get_object_or_404 | 7 from django.shortcuts import get_object_or_404 |
8 from django.shortcuts import render_to_response | 8 from django.shortcuts import render |
9 from django.template import RequestContext | |
10 from django.http import HttpResponseRedirect | 9 from django.http import HttpResponseRedirect |
11 from django.http import HttpResponseForbidden | 10 from django.http import HttpResponseForbidden |
12 from django.http import Http404 | 11 from django.http import Http404 |
13 | 12 |
14 from django.core.paginator import InvalidPage | 13 from django.core.paginator import InvalidPage |
61 try: | 60 try: |
62 page = paginator.page(page_num) | 61 page = paginator.page(page_num) |
63 except InvalidPage: | 62 except InvalidPage: |
64 raise Http404 | 63 raise Http404 |
65 | 64 |
66 return render_to_response('forums/manage_topics.html', { | 65 return render(request, 'forums/manage_topics.html', { |
67 'page_title': 'Favorite Topics', | 66 'page_title': 'Favorite Topics', |
68 'description': 'Your favorite topics are listed below.', | 67 'description': 'Your favorite topics are listed below.', |
69 'page': page, | 68 'page': page, |
70 }, | 69 }) |
71 context_instance=RequestContext(request)) | 70 |
72 | 71 |
73 @login_required | 72 @login_required |
74 def favorites_status(request, topic_id): | 73 def favorites_status(request, topic_id): |
75 """Display the favorite status for the given topic.""" | 74 """Display the favorite status for the given topic.""" |
76 topic = get_object_or_404(Topic.objects.select_related(), id=topic_id) | 75 topic = get_object_or_404(Topic.objects.select_related(), id=topic_id) |
77 is_favorite = request.user in topic.bookmarkers.all() | 76 is_favorite = request.user in topic.bookmarkers.all() |
78 return render_to_response('forums/favorite_status.html', { | 77 return render(request, 'forums/favorite_status.html', { |
79 'topic': topic, | 78 'topic': topic, |
80 'is_favorite': is_favorite, | 79 'is_favorite': is_favorite, |
81 }, | 80 }) |
82 context_instance=RequestContext(request)) | 81 |
83 | 82 |
84 @login_required | 83 @login_required |
85 @require_POST | 84 @require_POST |
86 def unfavorite_topic(request, topic_id): | 85 def unfavorite_topic(request, topic_id): |
87 """ | 86 """ |