def put(self, request):
        """
        Create a new plugin.

        If modifications are correct return confirmation message
        and the new render of the layout section;
        if not, return the plugin form with error messages

        PUT parameters :
          - placeholder_id : Html ID of the placeholder, e.g. 'content-placeholder-1'.
          - plugin_type    : Content type ID of the new plugin.
          - form fields
          - csrf token
        """
        # Get PUT parameters
        request.PUT = self.DATA.copy() 

        placeholder_html_id = request.PUT.get('placeholder_id', None)
        plugin_type    = request.PUT.get('plugin_type', None)

        if placeholder_html_id and plugin_type:
            # Check if placeholder ID is valid
            placeholder_slug_items = check_placeholder_html_id(placeholder_html_id)
            layout_section_slug = placeholder_slug_items[0]
            # Get form of the plugin type
            try:
                content_type = CTA().get_for_pk(plugin_type)
            except ContentType.DoesNotExist:
                raise ErrorResponse(status.HTTP_400_BAD_REQUEST,
                                    {'msg': MESSAGES.get('default_error', "")})

            PluginClass     = content_type.model_class()
            plugin          = PluginClass()
            PluginFormClass = plugin.get_admin_form()
            form            = PluginFormClass(request.PUT, instance=plugin)

            if form.is_valid():
                # Creation of the new plugin
                new_plugin = form.save()
                # Creation of the relation
                display_on_new_pages = (not is_page_placeholder_html_id(placeholder_html_id))
                relation = PluginRelation.objects.create(content_object=new_plugin,
                                                         placeholder_slug= placeholder_html_id,
                                                         display_on_new_pages=display_on_new_pages)
                relation.pages.add(request.page)

                # At the moment, we displayed it on everypage
                if display_on_new_pages:
                    for page in request.website.pages.all():
                        relation.pages.add(page)
                
                # Set right order
                try:
                    last_relation = PluginRelation.objects.filter(
                        pages=request.page,
                        placeholder_slug=placeholder_html_id).order_by('-plugin_order')[0]
                    plugin_order = last_relation.plugin_order + 10
                except __HOLE__:
                    plugin_order = 0
                relation.plugin_order = plugin_order
                # Saving modifications
                relation.save()

                rendering_context = RenderingContext(request)
                plugin_html_medias = rendering_context\
                    .get_html_medias_for_plugin_relation(relation)
                html_rendering = rendering_context.get_html_layout(layout_section_slug)
                
                # Sending response
                response = Response(status.HTTP_200_OK,
                                    {'msg': MESSAGES.get('item_edit_success', ''),
                                     'html': html_rendering,
                                     'layout_section_slug': layout_section_slug,
                                     'medias': plugin_html_medias})
                return self.render(response)
            
            # Invalid Form => 400 BAD REQUEST
            else:
                html = render_to_string('administration/plugin/plugin-create.html',
                                        {'form': form,
                                         'placeholder_id': placeholder_html_id,
                                         'plugin_type': plugin_type},
                                       context_instance=RequestContext(request))
                raise ErrorResponse(status.HTTP_400_BAD_REQUEST,
                                    {'msg': MESSAGES.get('invalid_data', ""),
                                     'html': html})
        # Bad parameters => 400 BAD REQUEST
        else:
            raise ErrorResponse(status.HTTP_400_BAD_REQUEST,
                                {'msg': MESSAGES.get('default_error', "")})
dataset/ETHPy150Open ionyse/ionyweb/ionyweb/administration/views/plugin.py/PluginView.put