Commits

Anonymous committed d2bf037

Import django.http for all the http response types

Comments (0)

Files changed (1)

gnocchi_forum/views.py

 from django.views.generic.list_detail import object_list
 from django.shortcuts import get_object_or_404
 from django.db.models import Max, Count
-
+from django import http
 from django.contrib.auth.decorators import permission_required
 
 from gnocchi_forum import models, forms, settings
 def forum_detail(request, forum_slug, forum_id):
     forum = get_object_or_404(models.Forum, pk=forum_id)
     if not forum_slug == forum.slug:
-        return HttpResponsePermanentRedirect(forum.get_absolute_url())
+        return http.HttpResponsePermanentRedirect(forum.get_absolute_url())
     # permssion check?
     return object_list(request,
         queryset = forum.thread_set.annotate(
 def thread_create(request, forum_id):
     forum = get_object_or_404(models.Forum, pk=forum_id)
     if not request.user.has_perm('create_thread', forum):
-        return HttpResponseForbidden()
+        return http.HttpResponseForbidden()
 
     if request.method == 'POST':
         form = forms.NewThreadForm(request.POST)
         if form.is_valid():
             obj = form.save()
-            return HttpResponseRedirect(obj.get_absolute_url())
+            return http.HttpResponseRedirect(obj.get_absolute_url())
     else:
         form = forms.NewThreadForm()
     return direct_to_template(request,
 def thread_detail(request, thread_slug, thread_id):
     thread = get_object_or_404(models.Thread, pk=thread_id)
     if not thread_slug == thread.slug:
-        return HttpResponsePermanentRedirect(thread.get_absolute_url())
+        return http.HttpResponsePermanentRedirect(thread.get_absolute_url())
     page_size = int(request.GET.get('page_size', settings.PAGINATION_SIZE))
     return object_list(request,
         queryset = thread.post_set.all(),
 def post_create(request, thread_slug, thread_id):
     thread = get_object_or_404(models.Thread, pk=thread_id)
     if not thread_slug == thread.slug:
-        return HttpResponsePermanentRedirect(thread.get_absolute_url())
+        return http.HttpResponsePermanentRedirect(thread.get_absolute_url())
     if request.method == 'POST':
         form = forms.NewPostForm(request.POST)
         if form.is_valid():
             obj = form.save(commit=False)
             obj.thread = thread
             obj.save()
-            return HttpResponseRedirect(obj.get_absolute_url())
+            return http.HttpResponseRedirect(obj.get_absolute_url())
     else:
         form = forms.NewPostForm()
     return direct_to_template(request,