Return a cancel parameter in the query string if the user cancels picking a file

This commit is contained in:
Benjamin Dauvergne 2015-03-09 15:45:19 +01:00
parent 1e70b0caaf
commit 54f2509a68
1 changed files with 8 additions and 2 deletions

View File

@ -81,8 +81,14 @@ class Homepage(Documents, SingleTableMixin, CommonUpload):
def post(self, request, *args, **kwargs):
if self.can_pick() and 'cancel' in request.POST:
return HttpResponseRedirect(request.GET['pick'])
return super(Upload, self).post(request, *args, **kwargs)
url = request.GET['pick']
scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
query = urlparse.parse_qs(query)
query['cancel'] = ['']
query = urllib.urlencode(query)
url = urlparse.urlunsplit((scheme, netloc, path, query, fragment))
return HttpResponseRedirect(url)
return super(Homepage, self).post(request, *args, **kwargs)
class Document(TemplateView):
template_name = 'fargo/document.html'