kopia lustrzana https://github.com/wagtail/wagtail
Use request.method == 'POST' to check if the request is a post request
rodzic
7f21efd55d
commit
062f027bc3
|
@ -16,7 +16,7 @@ def add(request):
|
||||||
Image = get_image_model()
|
Image = get_image_model()
|
||||||
ImageForm = get_image_form_for_multi()
|
ImageForm = get_image_form_for_multi()
|
||||||
|
|
||||||
if request.POST:
|
if request.method == 'POST':
|
||||||
if not request.is_ajax():
|
if not request.is_ajax():
|
||||||
return HttpResponseBadRequest("Cannot POST to this view without AJAX")
|
return HttpResponseBadRequest("Cannot POST to this view without AJAX")
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ def edit(request, image_id, callback=None):
|
||||||
if not image.is_editable_by_user(request.user):
|
if not image.is_editable_by_user(request.user):
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
|
|
||||||
if request.POST:
|
if request.method == 'POST':
|
||||||
form = ImageForm(request.POST, request.FILES, instance=image, prefix='image-'+image_id)
|
form = ImageForm(request.POST, request.FILES, instance=image, prefix='image-'+image_id)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
form.save()
|
form.save()
|
||||||
|
@ -67,7 +67,7 @@ def delete(request, image_id):
|
||||||
if not image.is_editable_by_user(request.user):
|
if not image.is_editable_by_user(request.user):
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
|
|
||||||
if request.POST:
|
if request.method == 'POST':
|
||||||
image.delete()
|
image.delete()
|
||||||
return render(request, 'wagtailimages/multiple/confirmation.json', {
|
return render(request, 'wagtailimages/multiple/confirmation.json', {
|
||||||
'success': True,
|
'success': True,
|
||||||
|
|
Ładowanie…
Reference in New Issue