def move_view(self, request): """ Allows us to move a Chunk from one place to another. Yes, it accepts request.GET, because I can't be bothered to monkey patch the jQuery ajax sending to send a CSRF token. Screw it. Data received in the request should be: * `pk` * `position` * `region` The form then handles moving everything in .save() """ form = MovementForm(data=request.GET, files=None, initial=None) if form.is_valid() and self.has_change_permission(request, form.cleaned_data['pk']): form.save() html = self.render_changelists_for_object( request=request, obj=form.cleaned_data['pk'].content_object) json_data = { 'action': 'move', 'html': html, 'primary_key': form.cleaned_data['pk'].pk, } self.log_change(request, *form.change_message()) self.log_change(request, *form.parent_change_message()) return HttpResponse(json.dumps(json_data), content_type='application/json') return HttpResponseBadRequest(json.dumps(form.errors), content_type='application/json')