Browse Source

Don't raise error 500 on accessing /pins/upload-pin uri

Fixes #81
tags/v1.0.0
Krzysztof Klimonda 11 years ago
parent
commit
435c41e450
1 changed files with 7 additions and 7 deletions
  1. +7
    -7
      pinry/pins/views.py

+ 7
- 7
pinry/pins/views.py View File

@@ -1,10 +1,5 @@
import json

from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.http import HttpResponse
from django.utils.decorators import method_decorator
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.views.generic import CreateView

from braces.views import LoginRequiredMixin, JSONResponseMixin
@@ -18,6 +13,11 @@ class CreateImage(JSONResponseMixin, LoginRequiredMixin, CreateView):
model = Image
form_class = ImageForm

def get(self, request, *args, **kwargs):
if not request.is_ajax():
return HttpResponseRedirect(reverse('pins:recent-pins'))
super(CreateImage, self).get(request, *args, **kwargs)

def form_valid(self, form):
image = form.save()
return self.render_json_response({


Loading…
Cancel
Save