'Move the page to the requested target, at the given position.
NOTE: We have to change from one "coordinate system" to another to
adapt JSTree to Django Treebeard.
If the Tree looks like this:
<root>
â¢ Page 4
â¢ Page 5 (position 0)
For example,
target=4, position=1 => target=5, position="right"
target=4, position=0 => target=4, position="first-child"'

@require_POST
@transaction.atomic
def move_page(self, request, page_id, extra_context=None):

    target = request.POST.get('target', None)
    position = request.POST.get('position', 0)
    site_id = request.POST.get('site', None)
    user = request.user
    try:
        position = int(position)
    except (TypeError, ValueError):
        position = 0
    try:
        page = self.model.objects.get(pk=page_id)
    except self.model.DoesNotExist:
        return jsonify_request(HttpResponseBadRequest('error'))
    try:
        site = Site.objects.get(id=int(site_id))
    except (TypeError, ValueError, MultipleObjectsReturned, ObjectDoesNotExist):
        site = get_current_site(request)
    if (target is None):
        try:
            tb_target = Page.get_draft_root_node(position=position, site=site)
            if (page.is_sibling_of(tb_target) and (page.path < tb_target.path)):
                tb_position = 'right'
            else:
                tb_position = 'left'
        except IndexError:
            tb_target = Page.get_draft_root_node(site=site)
            tb_position = 'right'
    else:
        try:
            target = tb_target = self.model.objects.get(pk=int(target), site=site)
        except (TypeError, ValueError, self.model.DoesNotExist):
            return jsonify_request(HttpResponseBadRequest('error'))
        if (position == 0):
            tb_position = 'first-child'
        else:
            try:
                tb_target = target.get_children().filter(publisher_is_draft=True, site=site)[position]
                if (page.is_sibling_of(tb_target) and (page.path < tb_target.path)):
                    tb_position = 'right'
                else:
                    tb_position = 'left'
            except IndexError:
                tb_position = 'last-child'
    if ((not self.has_move_page_permission(request, obj=page)) or (target and (not target.has_add_permission(user)))):
        return jsonify_request(HttpResponseForbidden(force_text(_("Error!    You    don't    have    permissions    to    move    this    page.    Please    reload    the    page"))))
    operation_token = self._send_pre_page_operation(request, operation=operations.MOVE_PAGE, obj=page)
    page.move_page(tb_target, tb_position)
    page.refresh_from_db()
    self._send_post_page_operation(request, operation=operations.MOVE_PAGE, token=operation_token, obj=page)
    return jsonify_request(HttpResponse(status=200))
