Skip to content

Commit

Permalink
Allow for normal get and post delete, and ajax get delete.
Browse files Browse the repository at this point in the history
Needed for sigurdga#12 and sigurdga#14
  • Loading branch information
sigurdga committed Jun 30, 2012
1 parent ea20c29 commit 8281b33
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions fileupload/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fileupload.models import Picture
from django.views.generic import CreateView, DeleteView

from django.http import HttpResponse
from django.http import HttpResponse, HttpResponseRedirect
from django.utils import simplejson
from django.core.urlresolvers import reverse

Expand Down Expand Up @@ -35,9 +35,12 @@ def delete(self, request, *args, **kwargs):
"""
self.object = self.get_object()
self.object.delete()
response = JSONResponse(True, {}, response_mimetype(self.request))
response['Content-Disposition'] = 'inline; filename=files.json'
return response
if request.is_ajax():
response = JSONResponse(True, {}, response_mimetype(self.request))
response['Content-Disposition'] = 'inline; filename=files.json'
return response
else:
return HttpResponseRedirect('/upload/new')

class JSONResponse(HttpResponse):
"""JSON response class."""
Expand Down

0 comments on commit 8281b33

Please sign in to comment.