Skip to content

Commit

Permalink
Merge pull request #4093 from williamdev/support/3.0.x
Browse files Browse the repository at this point in the history
backport fix #3881 from 3.1 branch : Empty All in placeholder remove plu...
  • Loading branch information
mkoistinen committed May 11, 2015
2 parents 8bc5eca + eecbd1d commit cce9c47
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,8 @@ Please see Install/2.4 release notes *before* attempting to upgrade to version 2
- Improves frontend performance relating to resizing the sideframe
- Corrects an issue where items might not be visible in structue mode menus
- Limits version of django-mptt used in CMS for 3.0.x
- Prevent accidental upgrades to Django 1.8, which is not yet supported
- Prevent accidental upgrades to Django 1.8, which is not yet supported

=== 3.0.14 (XXXX-XX-XX) ===

- Fixed an issue related to "Empty all" Placeholder feature
2 changes: 1 addition & 1 deletion cms/admin/placeholderadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def clear_placeholder(self, request, placeholder_id):
if perms_needed:
return HttpResponseForbidden(force_unicode(_("You do not have permission to clear this placeholder")))
self.log_deletion(request, placeholder, obj_display)
placeholder.clear()
placeholder.clear(language)
self.message_user(request, _('The placeholder "%(obj)s" was cleared successfully.') % {
'obj': force_unicode(obj_display)})
self.post_clear_placeholder(request, placeholder)
Expand Down
33 changes: 33 additions & 0 deletions cms/tests/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,39 @@ def test_tree_displays_in_correct_language(self):
response = self.client.get(url, {'language': 'es-mx'})
self.assertRegexpMatches(str(response.content), url_pat.format(page.pk, 'es-mx', es_title, ))

def test_empty_placeholder_in_correct_language(self):
"""
Test that Cleaning a placeholder only affect current language contents
"""
# create some objects
page_en = create_page("EmptyPlaceholderTestPage (EN)", "nav_playground.html", "en")
ph = page_en.placeholders.get(slot="body")

# add the text plugin to the en version of the page
add_plugin(ph, "TextPlugin", "en", body="Hello World EN 1")
add_plugin(ph, "TextPlugin", "en", body="Hello World EN 2")

# creating a de title of the page and adding plugins to it
create_title("de", page_en.get_title(), page_en, slug=page_en.get_slug())
add_plugin(ph, "TextPlugin", "de", body="Hello World DE")
add_plugin(ph, "TextPlugin", "de", body="Hello World DE 2")
add_plugin(ph, "TextPlugin", "de", body="Hello World DE 3")

# before cleaning the de placeholder
self.assertEqual(ph.get_plugins('en').count(), 2)
self.assertEqual(ph.get_plugins('de').count(), 3)

admin_user, staff = self._get_guys()
with self.login_user_context(admin_user):
url = '%s?language=de' % admin_reverse('cms_page_clear_placeholder', args=[ph.pk])
response = self.client.post(url, {'test': 0})

self.assertEqual(response.status_code, 302)

# After cleaning the de placeholder, en placeholder must still have all the plugins
self.assertEqual(ph.get_plugins('en').count(), 2)
self.assertEqual(ph.get_plugins('de').count(), 0)


class AdminTests(AdminTestsBase):
# TODO: needs tests for actual permissions, not only superuser/normaluser
Expand Down

0 comments on commit cce9c47

Please sign in to comment.