Skip to content

Commit

Permalink
Merge branch 'develop-4' into feat/data-bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Mar 28, 2024
2 parents 798829e + 1344853 commit 29b7e74
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions cms/cms_toolbars.py
Expand Up @@ -429,8 +429,9 @@ def get_on_delete_redirect_url(self):

# if the current page has a parent in the request's current language redirect to it
if parent_page and language in parent_page.get_languages():
with force_language(language):
return parent_page.get_absolute_url(language=language)
return get_object_preview_url(
parent_page.pagecontent_set(manager="admin_manager").latest_content(language=language).first()
)

# else redirect to root, do not redirect to Page.objects.get_home() because user could have deleted the last
# page, if DEBUG == False this could cause a 404
Expand Down
2 changes: 1 addition & 1 deletion cms/models/pagemodel.py
Expand Up @@ -607,7 +607,7 @@ def delete_translations(self, language=None):
else:
languages = [language]

self.pagecontent_set.filter(language__in=languages).delete()
self.pagecontent_set(manager="admin_manager").filter(language__in=languages).delete()

def save(self, **kwargs):
if self.reverse_id == "":
Expand Down
2 changes: 1 addition & 1 deletion cms/models/pluginmodel.py
Expand Up @@ -213,7 +213,7 @@ def get_plugin_class_instance(self, admin=None):
def get_plugin_instance(self, admin=None):
"""
For a plugin instance (usually as a CMSPluginBase), this method
returns the downcasted (i.e., correctly typed subclass of CMSPluginBase) instacnce and the plugin class
returns the downcasted (i.e., correctly typed subclass of CMSPluginBase) instance and the plugin class
:return: Tuple (instance, plugin)
Expand Down
2 changes: 1 addition & 1 deletion cms/tests/test_static_analysis.py
Expand Up @@ -10,4 +10,4 @@ class AboveStaticAnalysisCodeTest(TestCase):
"""
def test_ruff(self):
ruff = find_ruff_bin()
self.assertEqual(os.spawnv(os.P_WAIT, ruff, ["ruff", "cms", "menus"]), 0)
self.assertEqual(os.spawnv(os.P_WAIT, ruff, ["ruff", "check", "cms", "menus"]), 0)
3 changes: 1 addition & 2 deletions cms/utils/page.py
Expand Up @@ -96,8 +96,7 @@ def get_page_from_request(request, use_path=None, clean_path=None):
.filter(path=path)
.select_related('page__node')
)
page_urls = list(page_urls)

page_urls = list(page_urls) # force queryset evaluation to save 1 query
try:
page = page_urls[0].page
except IndexError:
Expand Down
9 changes: 5 additions & 4 deletions cms/views.py
Expand Up @@ -140,12 +140,13 @@ def details(request, slug):
# this means we need to correctly redirect that request.
return _handle_no_page(request)

# get_published_languages will return all languages in draft mode
# and published only in live mode.
# These languages are then filtered out by the user allowed languages
# we use the _get_page_content_cache method to populate the cache with all public languages
# The languages are then filtered out by the user allowed languages
page._get_page_content_cache(None, fallback=True, force_reload=True)
pagecontent_languages = list(page.page_content_cache.keys())
available_languages = [
language for language in user_languages
if language in list(page.get_languages())
if language in pagecontent_languages
]

own_urls = [
Expand Down

0 comments on commit 29b7e74

Please sign in to comment.