Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/issue-6840-slug-uniqueness-on-move
Browse files Browse the repository at this point in the history
  • Loading branch information
goutnet committed May 19, 2021
2 parents eb77ea6 + b39faf0 commit bc4a986
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -10,13 +10,15 @@ Unreleased
* Fixed builds on RTD
* Remove debug print from apphook_reload
* Enforce use of coverage > 4 for python 3.8 support
* Fixed the cache not being invalidated when updating a PlaceholderField in a custom model
* Fixed 66622 bad Title.path in multilingual sites when parent slug is created or modified
* Fixed 6973 bag with unexpected behavior ``get_page_from_request``
* Temporarily pinned django-treebeard to < 4.5, this avoids breaking changes introduced
* Improved performance of ``cms list plugins`` command
* Fix styles issues, caused by switching to the ``display: flex`` on the page tree renderer.
* Added django-treebeard 4.5.1 support, previously pinned django-treebeard<4.5 to avoid breaking changes introduced
* Updated documentation links
* documentation: Added an example of sqlite database configuration in documentation
* Added support for Github Actions based CI.
* Added Support for testing frontend, docs, test and linting in different/parallel CI pipelines.
* Remove travis integration from the project as the project has moved to Github Actions.
Expand Down Expand Up @@ -45,6 +47,7 @@ Unreleased
``force_str``and ``smart_str``.



3.7.4 (2020-07-21)
==================

Expand Down
4 changes: 4 additions & 0 deletions cms/models/placeholdermodel.py
Expand Up @@ -507,6 +507,10 @@ def mark_as_dirty(self, language, clear_cache=True):
elif attached_model is StaticPlaceholder:
StaticPlaceholder.objects.filter(draft=self).update(dirty=True)

# Force to clear cache when attached model is not a Page or a StaticPlaceholder, otherwise cache is never invalidated when using PlaceholderField
elif clear_cache is False:
self.clear_cache(language)

def get_plugin_tree_order(self, language, parent_id=None):
"""
Returns a list of plugin ids matching the given language
Expand Down
53 changes: 53 additions & 0 deletions cms/tests/test_cache.py
Expand Up @@ -653,6 +653,59 @@ def test_render_placeholder_cache(self):
text = content_renderer.render_placeholder(ph1, context)
self.assertEqual(text, "Other text")

def test_render_placeholderfield_cache_in_custom_model(self):
"""
Regression test for #6912
Assert that placeholder of a placeholderfield in custom model has its cache cleared correctly when mark_as_dirty is called in the admin
"""

invalidate_cms_page_cache()

# Create an instance of a custom model containing a placeholderfield
ex = Example1(char_1="one", char_2="two", char_3="tree", char_4="four")
ex.save()
ph1 = ex.placeholder

# Add a first plugin
test_plugin = add_plugin(ph1, "TextPlugin", "en", body="Some text")
test_plugin.save()

# Create a first request using render_placeholder to ensure that the content is equal to the first plugin content
request = self.get_request()
content_renderer = self.get_content_renderer(request)
context = SekizaiContext()
context["request"] = self.get_request()
text = content_renderer.render_placeholder(ph1, context, use_cache=True)
self.assertEqual(text, "Some text")

# Add a second plugin in the placeholder
test_plugin = add_plugin(ph1, "TextPlugin", "en", body="Some other text")
test_plugin.save()

# Clear plugins cache to ensure that cms.utils.plugins.get_plugins() will refetch the plugins
del ph1._plugins_cache

# Create a second request using render_placeholder to ensure that the content is still equal to the first plugin content as cache was not cleared yet
request = self.get_request()
content_renderer = self.get_content_renderer(request)
context = SekizaiContext()
context["request"] = self.get_request()
text = content_renderer.render_placeholder(ph1, context, use_cache=True)
self.assertEqual(text, "Some text")

# Mark placeholder as dirty as it is done in cms.admin.placeholderadmin file
ph1.mark_as_dirty("en", clear_cache=False)

# Create a last request to ensure that rendered content contains the two plugins content
request = self.get_request()
content_renderer = self.get_content_renderer(request)
context = SekizaiContext()
context["request"] = self.get_request()

text = content_renderer.render_placeholder(ph1, context, use_cache=True)
self.assertEqual(text, "Some textSome other text")


class PlaceholderCacheTestCase(CMSTestCase):
def setUp(self):
Expand Down
9 changes: 8 additions & 1 deletion docs/how_to/install.rst
Expand Up @@ -134,7 +134,14 @@ django CMS requires a relational database backend. Each django CMS installation

You can use SQLite, which is included in Python and doesn't need to be installed separately or configured further. You
are unlikely to be using that for a project in production, but it's ideal for development and exploration, especially
as it is configured by default in a new Django project's :setting:`django:DATABASES`.
as it is configured by default in a new Django project's :setting:`django:DATABASES`::

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR , 'db.sqlite3'),
}
}

.. note::

Expand Down

0 comments on commit bc4a986

Please sign in to comment.