'Performs a move or a "paste" operation (when Â«move_a_copyÂ» is set)
POST request with following parameters:
- plugin_id
- placeholder_id
- plugin_language (optional)
- plugin_parent (optional)
- plugin_order (array, optional)
- move_a_copy (Boolean, optional) (anything supplied here except a case-
insensitive "false" is True)
NOTE: If move_a_copy is set, the plugin_order should contain an item
\'__COPY__\' with the desired destination of the copied plugin.'

@method_decorator(require_POST)
@xframe_options_sameorigin
@transaction.atomic
def move_plugin(self, request):

    try:
        plugin_id = get_int(request.POST.get('plugin_id'))
    except TypeError:
        raise RuntimeError("'plugin_id'    is    a    required    parameter.")
    plugin = self._get_plugin_from_id(plugin_id)
    try:
        placeholder_id = get_int(request.POST.get('placeholder_id'))
    except TypeError:
        raise RuntimeError("'placeholder_id'    is    a    required    parameter.")
    except ValueError:
        raise RuntimeError("'placeholder_id'    must    be    an    integer    string.")
    placeholder = Placeholder.objects.get(pk=placeholder_id)
    parent_id = get_int(request.POST.get('plugin_parent', ''), None)
    language = (request.POST.get('plugin_language', None) or plugin.language)
    move_a_copy = request.POST.get('move_a_copy')
    move_a_copy = (move_a_copy and (move_a_copy != '0') and (move_a_copy.lower() != 'false'))
    move_to_clipboard = (placeholder == request.toolbar.clipboard)
    source_language = plugin.language
    source_placeholder = plugin.placeholder
    order = request.POST.getlist('plugin_order[]')
    if (placeholder != source_placeholder):
        try:
            template = self.get_placeholder_template(request, placeholder)
            has_reached_plugin_limit(placeholder, plugin.plugin_type, plugin.language, template=template)
        except PluginLimitReached as er:
            return HttpResponseBadRequest(er)
    exclude_from_order_check = ['__COPY__', str(plugin.pk)]
    ordered_plugin_ids = [int(pk) for pk in order if (pk not in exclude_from_order_check)]
    plugins_in_tree_count = placeholder.get_plugins(language).filter(parent=parent_id, pk__in=ordered_plugin_ids).count()
    if (len(ordered_plugin_ids) != plugins_in_tree_count):
        message = _('order    parameter    references    plugins    in    different    trees')
        return HttpResponseBadRequest(force_text(message))
    move_a_plugin = ((not move_a_copy) and (not move_to_clipboard))
    if (parent_id and (plugin.parent_id != parent_id)):
        target_parent = get_object_or_404(CMSPlugin, pk=parent_id)
        if (move_a_plugin and (target_parent.placeholder_id != placeholder.pk)):
            return HttpResponseBadRequest(force_text(_('parent    must    be    in    the    same    placeholder')))
        if (move_a_plugin and (target_parent.language != language)):
            return HttpResponseBadRequest(force_text(_('parent    must    be    in    the    same    language    as    plugin_language')))
    elif parent_id:
        target_parent = plugin.parent
    else:
        target_parent = None
    if (move_a_copy and (plugin.plugin_type == 'PlaceholderPlugin')):
        new_plugin = self._paste_placeholder(request, plugin=plugin, target_language=language, target_placeholder=placeholder, tree_order=order)
    elif move_a_copy:
        new_plugin = self._paste_plugin(request, plugin=plugin, target_parent=target_parent, target_language=language, target_placeholder=placeholder, tree_order=order)
    elif move_to_clipboard:
        new_plugin = self._cut_plugin(request, plugin=plugin, target_language=language, target_placeholder=placeholder)
    else:
        new_plugin = self._move_plugin(request, plugin=plugin, target_parent=target_parent, target_language=language, target_placeholder=placeholder, tree_order=order)
    placeholder.mark_as_dirty(language)
    if (placeholder != source_placeholder):
        source_placeholder.mark_as_dirty(source_language)
    target_placeholder_admin = self._get_attached_admin(placeholder)
    uses_copy_hook = _instance_overrides_method(PlaceholderAdminMixin, self, 'post_copy_plugins')
    if (target_placeholder_admin and (not uses_copy_hook)):
        uses_copy_hook = _instance_overrides_method(PlaceholderAdminMixin, target_placeholder_admin, 'post_copy_plugins')
    uses_move_hook = _instance_overrides_method(PlaceholderAdminMixin, self, 'post_move_plugin')
    if (target_placeholder_admin and (not uses_move_hook)):
        uses_move_hook = _instance_overrides_method(PlaceholderAdminMixin, target_placeholder_admin, 'post_move_plugin')
    if (move_a_copy and uses_copy_hook):
        warnings.warn('The    post_copy_plugins    hook    has    been    deprecated.    Please    use    placeholder    operation    signals    instead.', DeprecationWarning)
        plugins = list(new_plugin.get_tree())
        self.post_copy_plugins(request, source_placeholder, placeholder, plugins)
        if (target_placeholder_admin and (target_placeholder_admin.model != self.model)):
            target_placeholder_admin.post_copy_plugins(request, source_placeholder=source_placeholder, target_placeholder=placeholder, plugins=plugins)
    elif uses_move_hook:
        warnings.warn('The    post_move_plugin    hook    has    been    deprecated.    Please    use    placeholder    operation    signals    instead.', DeprecationWarning)
        self.post_move_plugin(request, source_placeholder, placeholder, new_plugin)
        if (target_placeholder_admin and (target_placeholder_admin.model != self.model)):
            target_placeholder_admin.post_move_plugin(request, source_placeholder=source_placeholder, target_placeholder=placeholder, plugin=new_plugin)
    try:
        language = request.toolbar.toolbar_language
    except AttributeError:
        language = get_language_from_request(request)
    with force_language(language):
        plugin_urls = new_plugin.get_action_urls()
    json_response = {'urls': plugin_urls, 'reload': (move_a_copy or requires_reload(PLUGIN_MOVE_ACTION, [new_plugin]))}
    return HttpResponse(json.dumps(json_response), content_type='application/json')
