8000 Remove placeholder content fallbacks by Aiky30 · Pull Request #6456 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

Remove placeholder content fallbacks #6456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Aiky30
Copy link
Contributor
@Aiky30 Aiky30 commented Jul 24, 2018

Documentation checklist

  • I have updated CHANGELOG.txt if appropriate
  • I have updated the release notes document if appropriate, with:
    • general notes
    • bug-fixes
    • improvements/new features
    • backwards-incompatible changes
    • required upgrade steps
    • names of contributors
  • I have updated other documentation
  • I have added my name to the AUTHORS file
  • This PR's documentation has been approved by Daniele Procida

@coveralls
Copy link
coveralls commented Jul 24, 2018

Coverage Status

Coverage remained the same at 78.189% when pulling 8b33973 on Aiky30:remove-placeholder-content-fallbacks into cb19c60 on divio:release/4.0.x.

@@ -499,11 +499,7 @@ def _preload_placeholders_for_page(self, page, slots=None, inherit=False):
# Creates any placeholders missing on the page
placeholders = title.rescan_placeholders().values()

if inherit:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave this for now, inheritance is different from fallbacks

@@ -482,7 +482,7 @@ def _get_cached_placeholder_content(self, placeholder, language):
language_cache[placeholder.pk] = cached_value
return language_cache.get(placeholder.pk)

def _preload_placeholders_for_page(self, page, slots=None, inherit=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave parameter

@@ -529,7 +525,6 @@ def _preload_placeholders_for_page(self, page, slots=None, inherit=False):
placeholders=placeholders_to_fetch,
template=page.get_template(),
lang=self.request_language,
is_fallback=inherit,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is ok

@@ -125,7 +125,7 @@ def test_preload_placeholders_for_page_with_inherit_off(self):
external_link='https://www.django-cms.org',
)
renderer = self.get_renderer(page=cms_page)
renderer._preload_placeholders_for_page(cms_page, inherit=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave inherit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inherit is False as default so I have left out adding this one unless you feel that it adds value.
_preload_placeholders_for_page(self, page, slots=None, inherit=False):

# These placeholders have no fallback
non_fallback_phs = [ph for ph in placeholders if ph.pk not in fallbacks]
# If no plugin is present in non fallback placeholders, create default plugins if enabled)
# Create default plugins if enabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove parentheses

Copy link
Contributor Author
@Aiky30 Aiky30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All done

@@ -125,7 +125,7 @@ def test_preload_placeholders_for_page_with_inherit_off(self):
external_link='https://www.django-cms.org',
)
renderer = self.get_renderer(page=cms_page)
renderer._preload_placeholders_for_page(cms_page, inherit=False)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inherit is False as default so I have left out adding this one unless you feel that it adds value.
_preload_placeholders_for_page(self, page, slots=None, inherit=False):

@Aiky30
Copy link
Contributor Author
Aiky30 commented Jul 25, 2018

See the output from my modified test using 3.5.2:

======================================================================
FAIL: test_no_cache_plugin (cms.tests.test_cache.CacheTestCase)

Traceback (most recent call last):
File "/src/cms/cms/tests/test_cache.py", line 139, in test_no_cache_plugin
content1 = response1.content
File "/python3.4/site-packages/django/test/testcases.py", line 88, in exit
query['sql'] for query in self.captured_queries
AssertionError: 20 != [1..2] : 20 queries executed, 2 expected
Captured queries were:
SELECT "cms_title"."id", "cms_title"."language", "cms_title"."title", "cms_title"."page_title", "cms_title"."menu_title", "cms_title"."meta_description", "cms_title"."slug", "cms_title"."path", "cms_title"."has_url_overwrite", "cms_title"."redirect", "cms_title"."page_id", "cms_title"."creation_date", "cms_title"."published", "cms_title"."publisher_is_draft", "cms_title"."publisher_public_id", "cms_title"."publisher_state", "cms_page"."id", "cms_page"."created_by", "cms_page"."changed_by", "cms_page"."creation_date", "cms_page"."changed_date", "cms_page"."publication_date", "cms_page"."publication_end_date", "cms_page"."in_navigation", "cms_page"."soft_root", "cms_page"."reverse_id", "cms_page"."navigation_extenders", "cms_page"."template", "cms_page"."login_required", "cms_page"."limit_visibility_in_menu", "cms_page"."is_home", "cms_page"."application_urls", "cms_page"."application_namespace", "cms_page"."publisher_is_draft", "cms_page"."publisher_public_id", "cms_page"."languages", "cms_page"."xframe_options", "cms_page"."is_page_type", "cms_page"."node_id", "cms_treenode"."id", "cms_treenode"."path", "cms_treenode"."depth", "cms_treenode"."numchild", "cms_treenode"."parent_id", "cms_treenode"."site_id" FROM "cms_title" INNER JOIN "cms_page" ON ("cms_title"."page_id" = "cms_page"."id") INNER JOIN "cms_treenode" ON ("cms_page"."node_id" = "cms_treenode"."id") WHERE ("cms_title"."publisher_is_draft" = 0 AND "cms_title"."published" = 1 AND "cms_title"."path" = 'test-page-1')
SELECT "cms_page"."id", "cms_page"."created_by", "cms_page"."changed_by", "cms_page"."creation_date", "cms_page"."changed_date", "cms_page"."publication_date", "cms_page"."publication_end_date", "cms_page"."in_navigation", "cms_page"."soft_root", "cms_page"."reverse_id", "cms_page"."navigation_extenders", "cms_page"."template", "cms_page"."login_required", "cms_page"."limit_visibility_in_menu", "cms_page"."is_home", "cms_page"."application_urls", "cms_page"."application_namespace", "cms_page"."publisher_is_draft", "cms_page"."publisher_public_id", "cms_page"."languages", "cms_page"."xframe_options", "cms_page"."is_page_type", "cms_page"."node_id" FROM "cms_page" WHERE "cms_page"."id" = 1
SELECT "cms_treenode"."id", "cms_treenode"."path", "cms_treenode"."depth", "cms_treenode"."numchild", "cms_treenode"."parent_id", "cms_treenode"."site_id" FROM "cms_treenode" WHERE "cms_treenode"."id" = 1
SELECT (1) AS "a" FROM "cms_pagepermission" INNER JOIN "cms_page" ON ("cms_pagepermission"."page_id" = "cms_page"."id") INNER JOIN "cms_treenode" ON ("cms_page"."node_id" = "cms_treenode"."id") WHERE (("cms_pagepermission"."page_id" = 1 AND ("cms_pagepermission"."grant_on" = 5 OR "cms_pagepermission"."grant_on" = 3 OR "cms_pagepermission"."grant_on" = 1)) AND "cms_pagepermission"."can_view" = 1) LIMIT 1
SELECT "cms_page"."id", "cms_page"."created_by", "cms_page"."changed_by", "cms_page"."creation_date", "cms_page"."changed_date", "cms_page"."publication_date", "cms_page"."publication_end_date", "cms_page"."in_navigation", "cms_page"."soft_root", "cms_page"."reverse_id", "cms_page"."navigation_extenders", "cms_page"."template", "cms_page"."login_required", "cms_page"."limit_visibility_in_menu", "cms_page"."is_home", "cms_page"."application_urls", "cms_page"."application_namespace", "cms_page"."publisher_is_draft", "cms_page"."publisher_public_id", "cms_page"."languages", "cms_page"."xframe_options", "cms_page"."is_page_type", "cms_page"."node_id" FROM "cms_page" WHERE ("cms_page"."application_urls" IN ('NamespacedApp', 'SampleApp2') OR "cms_page"."navigation_extenders" = 'StaticMenu3')
SELECT "cms_page"."id", "cms_page"."created_by", "cms_page"."changed_by", "cms_page"."creation_date", "cms_page"."changed_date", "cms_page"."publication_date", "cms_page"."publication_end_date", "cms_page"."in_navigation", "cms_page"."soft_root", "cms_page"."reverse_id", "cms_page"."navigation_extenders", "cms_page"."template", "cms_page"."login_required", "cms_page"."limit_visibility_in_menu", "cms_page"."is_home", "cms_page"."application_urls", "cms_page"."application_namespace", "cms_page"."publisher_is_draft", "cms_page"."publisher_public_id", "cms_page"."languages", "cms_page"."xframe_options", "cms_page"."is_page_type", "cms_page"."node_id" FROM "cms_page" WHERE "cms_page"."navigation_extenders" = 'StaticMenu'
SELECT "cms_page"."id", "cms_page"."created_by", "cms_page"."changed_by", "cms_page"."creation_date", "cms_page"."changed_date", "cms_page"."publication_date", "cms_page"."publication_end_date", "cms_page"."in_navigation", "cms_page"."soft_root", "cms_page"."reverse_id", "cms_page"."navigation_extenders", "cms_page"."template", "cms_page"."login_required", "cms_page"."limit_visibility_in_menu", "cms_page"."is_home", "cms_page"."application_urls", "cms_page"."application_namespace", "cms_page"."publisher_is_draft", "cms_page"."publisher_public_id", "cms_page"."languages", "cms_page"."xframe_options", "cms_page"."is_page_type", "cms_page"."node_id" FROM "cms_page" WHERE "cms_page"."navigation_extenders" = 'StaticMenu2'
SELECT "cms_page"."id", "cms_page"."created_by", "cms_page"."changed_by", "cms_page"."creation_date", "cms_page"."changed_date", "cms_page"."publication_date", "cms_page"."publication_end_date", "cms_page"."in_navigation", "cms_page"."soft_root", "cms_page"."reverse_id", "cms_page"."navigation_extenders", "cms_page"."template", "cms_page"."login_required", "cms_page"."limit_visibility_in_menu", "cms_page"."is_home", "cms_page"."application_urls", "cms_page"."application_namespace", "cms_page"."publisher_is_draft", "cms_page"."publisher_public_id", "cms_page"."languages", "cms_page"."xframe_options", "cms_page"."is_page_type", "cms_page"."node_id" FROM "cms_page" WHERE ("cms_page"."application_urls" IN ('VariableUrlsApp') OR "cms_page"."navigation_extenders" = 'StaticMenu4')
SELECT DISTINCT "cms_page"."id", "cms_page"."created_by", "cms_page"."changed_by", "cms_page"."creation_date", "cms_page"."changed_date", "cms_page"."publication_date", "cms_page"."publication_end_date", "cms_page"."in_navigation", "cms_page"."soft_root", "cms_page"."reverse_id", "cms_page"."navigation_extenders", "cms_page"."template", "cms_page"."login_required", "cms_page"."limit_visibility_in_menu", "cms_page"."is_home", "cms_page"."application_urls", "cms_page"."application_namespace", "cms_page"."publisher_is_draft", "cms_page"."publisher_public_id", "cms_page"."languages", "cms_page"."xframe_options", "cms_page"."is_page_type", "cms_page"."node_id", T6."id", T6."created_by", T6."changed_by", T6."creation_date", T6."changed_date", T6."publication_date", T6."publication_end_date", T6."in_navigation", T6."soft_root", T6."reverse_id", T6."navigation_extenders", T6."template", T6."login_required", T6."limit_visibility_in_menu", T6."is_home", T6."application_urls", T6."application_namespace", T6."publisher_is_draft", T6."publisher_public_id", T6."languages", T6."xframe_options", T6."is_page_type", T6."node_id", T7."id", T7."path", T7."depth", T7."numchild", T7."parent_id", T7."site_id", "cms_treenode"."id", "cms_treenode"."path", "cms_treenode"."depth", "cms_treenode"."numchild", "cms_treenode"."parent_id", "cms_treenode"."site_id" FROM "cms_page" INNER JOIN "cms_treenode" ON ("cms_page"."node_id" = "cms_treenode"."id") INNER JOIN "cms_title" ON ("cms_page"."id" = "cms_title"."page_id") INNER JOIN "cms_title" T5 ON ("cms_page"."id" = T5."page_id") LEFT OUTER JOIN "cms_page" T6 ON ("cms_page"."publisher_public_id" = T6."id") LEFT OUTER JOIN "cms_treenode" T7 ON (T6."node_id" = T7."id") WHERE ("cms_page"."publisher_is_draft" = 0 AND "cms_treenode"."site_id" = 1 AND ("cms_page"."publication_date" <= '2018-07-25 14:27:50.243714' OR "cms_page"."publication_date" IS NULL) AND ("cms_page"."publication_end_date" > '2018-07-25 14:27:50.243714' OR "cms_page"."publication_end_date" IS NULL) AND "cms_title"."published" = 1 AND NOT ("cms_page"."id" IN (SELECT U1."page_id" AS Col1 FROM "cms_title" U1 WHERE U1."publisher_state" = 4)) AND T5."language" IN ('de', 'en', 'fr')) ORDER BY "cms_treenode"."path" ASC
SELECT "cms_pagepermission"."id", "cms_pagepermission"."user_id", "cms_pagepermission"."group_id", "cms_pagepermission"."can_change", "cms_pagepermission"."can_add", "cms_pagepermission"."can_delete", "cms_pagepermission"."can_change_advanced_settings", "cms_pagepermission"."can_publish", "cms_pagepermission"."can_change_permissions", "cms_pagepermission"."can_move_page", "cms_pagepermission"."can_view", "cms_pagepermission"."grant_on", "cms_pagepermission"."page_id" FROM "cms_pagepermission" WHERE ("cms_pagepermission"."page_id" IN (1) AND "cms_pagepermission"."can_view" = 1)
SELECT "cms_title"."id", "cms_title"."language", "cms_title"."title", "cms_title"."page_title", "cms_title"."menu_title", "cms_title"."meta_description", "cms_title"."slug", "cms_title"."path", "cms_title"."has_url_overwrite", "cms_title"."redirect", "cms_title"."page_id", "cms_title"."creation_date", "cms_title"."published", "cms_title"."publisher_is_draft", "cms_title"."publisher_public_id", "cms_title"."publisher_state" FROM "cms_title" WHERE ("cms_title"."publisher_is_draft" = 0 AND "cms_title"."language" IN ('de', 'en', 'fr') AND "cms_title"."page_id" IN (2))
SELECT "sampleapp_category"."id", "sampleapp_category"."path", "sampleapp_category"."depth", "sampleapp_category"."numchild", "sampleapp_category"."parent_id", "sampleapp_category"."name", "sampleapp_category"."description_id" FROM "sampleapp_category" ORDER BY "sampleapp_category"."path" ASC
SELECT (1) AS "a" FROM "menus_cachekey" WHERE ("menus_cachekey"."language" = 'en' AND "menus_cachekey"."key" = 'cms_3.5.2_menu_nodes_en_1:public' AND "menus_cachekey"."site" = 1) LIMIT 1
INSERT INTO "menus_cachekey" ("language", "site", "key") VALUES ('en', 1, 'cms_3.5.2_menu_nodes_en_1:public')
SELECT "cms_placeholder"."id", "cms_placeholder"."slot", "cms_placeholder"."default_width" FROM "cms_placeholder" INNER JOIN "cms_page_placeholders" ON ("cms_placeholder"."id" = "cms_page_placeholders"."placeholder_id") WHERE "cms_page_placeholders"."page_id" = 2
SELECT "cms_cmsplugin"."id", "cms_cmsplugin"."path", "cms_cmsplugin"."depth", "cms_cmsplugin"."numchild", "cms_cmsplugin"."placeholder_id", "cms_cmsplugin"."parent_id", "cms_cmsplugin"."position", "cms_cmsplugin"."language", "cms_cmsplugin"."plugin_type", "cms_cmsplugin"."creation_date", "cms_cmsplugin"."changed_date" FROM "cms_cmsplugin" WHERE ("cms_cmsplugin"."language" = 'en' AND "cms_cmsplugin"."placeholder_id" IN (3, 4)) ORDER BY "cms_cmsplugin"."placeholder_id" ASC, "cms_cmsplugin"."path" ASC
SELECT "cms_cmsplugin"."id", "cms_cmsplugin"."path", "cms_cmsplugin"."depth", "cms_cmsplugin"."numchild", "cms_cmsplugin"."placeholder_id", "cms_cmsplugin"."parent_id", "cms_cmsplugin"."position", "cms_cmsplugin"."language", "cms_cmsplugin"."plugin_type", "cms_cmsplugin"."creation_date", "cms_cmsplugin"."changed_date" FROM "cms_cmsplugin" WHERE ("cms_cmsplugin"."language" = 'fr' AND "cms_cmsplugin"."placeholder_id" IN (3)) ORDER BY "cms_cmsplugin"."placeholder_id" ASC, "cms_cmsplugin"."path" ASC
SELECT "cms_cmsplugin"."id", "cms_cmsplugin"."path", "cms_cmsplugin"."depth", "cms_cmsplugin"."numchild", "cms_cmsplugin"."placeholder_id", "cms_cmsplugin"."parent_id", "cms_cmsplugin"."position", "cms_cmsplugin"."language", "cms_cmsplugin"."plugin_type", "cms_cmsplugin"."creation_date", "cms_cmsplugin"."changed_date" FROM "cms_cmsplugin" WHERE ("cms_cmsplugin"."language" = 'de' AND "cms_cmsplugin"."placeholder_id" IN (3)) ORDER BY "cms_cmsplugin"."placeholder_id" ASC, "cms_cmsplugin"."path" ASC
SELECT "cms_cmsplugin"."id", "cms_cmsplugin"."path", "cms_cmsplugin"."depth", "cms_cmsplugin"."numchild", "cms_cmsplugin"."placeholder_id", "cms_cmsplugin"."parent_id", "cms_cmsplugin"."position", "cms_cmsplugin"."language", "cms_cmsplugin"."plugin_type", "cms_cmsplugin"."creation_date", "cms_cmsplugin"."changed_date" FROM "cms_cmsplugin" WHERE ("cms_cmsplugin"."language" = 'fr' AND "cms_cmsplugin"."placeholder_id" IN (4)) ORDER BY "cms_cmsplugin"."placeholder_id" ASC, "cms_cmsplugin"."path" ASC
SELECT "cms_cmsplugin"."id", "cms_cmsplugin"."path", "cms_cmsplugin"."depth", "cms_cmsplugin"."numchild", "cms_cmsplugin"."placeholder_id", "cms_cmsplugin"."parent_id", "cms_cmsplugin"."position", "cms_cmsplugin"."language", "cms_cmsplugin"."plugin_type", "cms_cmsplugin"."creation_date", "cms_cmsplugin"."changed_date" FROM "cms_cmsplugin" WHERE ("cms_cmsplugin"."language" = 'de' AND "cms_cmsplugin"."placeholder_id" IN (4)) ORDER BY "cms_cmsplugin"."placeholder_id" ASC, "cms_cmsplugin"."path" ASC

@czpython czpython merged commit a9947fe into django-cms:release/4.0.x Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0