Skip to content

Commit

Permalink
Merge pull request #3881 from pevar/master
Browse files Browse the repository at this point in the history
Empty All in placeholder remove plugins from all the localized version of the page
  • Loading branch information
mkoistinen committed Feb 25, 2015
2 parents 4d19f46 + 78ad9b9 commit 85aaf28
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
13 changes: 0 additions & 13 deletions .tx/config

This file was deleted.

2 changes: 1 addition & 1 deletion cms/admin/placeholderadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def clear_placeholder(self, request, placeholder_id):
if perms_needed:
return HttpResponseForbidden(force_text(_("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_text(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 @@ -570,6 +570,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 85aaf28

Please sign in to comment.