divio/django-cms — pull request #2487 by Chive (2014-01-18 01:28:52+00:00)
Title: Emptying a static placeholder will not be published

Steps:

- Create a page with a static placeholder and add a plugin to it
- Publish the page
- Edit the page again, remove the plugin from the static placeholder so that the placeholder is now empty
- The publish button doesn't appear. If you 'force' publish through the admin link, it won't update the live page either.

Check the live page - the plugin will still be there. This happens because of the way the publishing of static placeholders is handled. The call is (`cms/cms_toolbar.py:176`):

```
http://localhost/de/admin/cms/page/1/publish/?statics=2
```

where 2 is the static placeholder's primary key. But if it empty, it won't be published.

As far as I could find out, this method below at `cms.admin.static_placeholder.StaticPlaceholderAdmin.post_delete_plugin` is never called.

```
def post_delete_plugin(self, request, plugin):
self.mark_dirty(plugin.placeholder)
```
It uses the method from `cms.admin.pageadmin.PageAdmin.post_delete_plugin` instead.
```
def post_delete_plugin(self, request, plugin):
plugin_name = force_unicode(plugin_pool.get_plugin(plugin.plugin_type).name)
page = plugin.placeholder.page
if page:
page.save()
comment = _("%(plugin_name)s plugin at position %(position)s in %(placeholder)s was deleted.") % {
'plugin_name': plugin_name,
'position': plugin.position,
'placeholder': plugin.placeholder,
}
moderator.page_changed(page, force_moderation_action=PageModeratorState.ACTION_CHANGED)
if 'reversion' in settings.INSTALLED_APPS:
helpers.make_revision_with_plugins(page, request.user, comment)
```

The call:
```
[18/Jan/2014 01:59:36] "GET /de/admin/cms/page/delete-plugin/32717/ HTTP/1.1" 200 2362
```

Instead of, like editing:
```
[18/Jan/2014 01:57:07] "GET /de/admin/cms/staticplaceholder/edit-plugin/32717/ HTTP/1.1" 200 6448
```