Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe26114

Browse filesBrowse files
fsbraunvinitkumar
andauthored
fix: Allow frontend-editable models to omit get_template method (#8406)
* fix: Allow frontend-editable models to omit get_template method * fix: remove unnecessary padding in modal * fix: adjust test * fix: remove testing assertions --------- Co-authored-by: Vinit Kumar <vinit@django-cms.org>
1 parent 58593a9 commit fe26114
Copy full SHA for fe26114

File tree

Expand file treeCollapse file tree

7 files changed

+7
-13
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

7 files changed

+7
-13
lines changed
Open diff view settings
Collapse file

‎cms/plugin_base.py‎

Copy file name to clipboardExpand all lines: cms/plugin_base.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def requires_parent_plugin(cls, slot, page):
346346
def _get_template_for_conf(cls, page: Page | None, instance: CMSPlugin | None = None):
347347
"""Cache page template because page.get_template() might have to fetch the page content object from the db
348348
since django CMS 4"""
349-
if page:
349+
if page and hasattr(page, "get_template"):
350350
# Make the database access lazy, so that it only happens if needed.
351351
return lazy(page.get_template, str)()
352352
if (
Collapse file

‎cms/plugin_pool.py‎

Copy file name to clipboardExpand all lines: cms/plugin_pool.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def get_all_plugins(
141141

142142
plugins = self.plugins.values()
143143
template = (
144-
lazy(page.get_template, str)() if page else None
144+
lazy(page.get_template, str)() if page and hasattr(page, "get_template") else None
145145
) # Make template lazy to avoid unnecessary db access
146146

147147
allowed_plugins = (
Collapse file

‎cms/plugin_rendering.py‎

Copy file name to clipboardExpand all lines: cms/plugin_rendering.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def render_placeholder(
274274
context.push()
275275

276276
width = width or placeholder.default_width
277-
template = page.get_template() if page else None
277+
template = page.get_template() if page and hasattr(page, "get_template") else None
278278

279279
if width:
280280
context["width"] = width
@@ -776,7 +776,7 @@ def render_plugin(self, instance, page=None):
776776
return self.get_plugin_toolbar_js(instance, page=page)
777777

778778
def render_plugins(self, placeholder, language, page=None):
779-
template = page.get_template() if page else None
779+
template = page.get_template() if page and hasattr(page, "get_template") else None
780780
plugins = self.get_plugins_to_render(placeholder, language, template)
781781

782782
for plugin in plugins:
Collapse file

‎cms/static/cms/js/modules/cms.modal.js‎

Copy file name to clipboardExpand all lines: cms/static/cms/js/modules/cms.modal.js
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,11 +1072,6 @@ class Modal {
10721072
}
10731073
});
10741074

1075-
// figure out if .object-tools is available
1076-
if (contents.find('.object-tools').length) {
1077-
contents.find('#content').css('padding-top', 38); // eslint-disable-line
1078-
}
1079-
10801075
// this is required for IE11. we assume that when the modal is opened the user is going to interact
10811076
// with it. if we don't focus the body directly the next time the user clicks on a field inside
10821077
// the iframe the focus will be stolen by body thus requiring two clicks. this immediately focuses the
Collapse file

‎cms/tests/frontend/unit/cms.modal.test.js‎

Copy file name to clipboardExpand all lines: cms/tests/frontend/unit/cms.modal.test.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,13 +2333,13 @@ describe('CMS.Modal', function() {
23332333
});
23342334
});
23352335

2336-
it('adjusts content if object-tools available', function(done) {
2336+
it('does not adjust content if object-tools are available', function(done) {
23372337
modal._loadIframe({
23382338
url: '/base/cms/tests/frontend/unit/html/modal_iframe_title.html'
23392339
});
23402340
spyOn($.fn, 'css');
23412341
modal.ui.modal.find('iframe').on('load', function() {
2342-
expect($.fn.css).toHaveBeenCalledWith('padding-top', 38);
2342+
expect($.fn.css).not.toHaveBeenCalledWith('padding-top', 38);
23432343
done();
23442344
});
23452345
});
Collapse file

‎cms/utils/i18n.py‎

Copy file name to clipboardExpand all lines: cms/utils/i18n.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def _ensure_site_id(site_id, name):
1414
"""
1515
Ensure that the site_id is an integer.
1616
"""
17-
assert site_id is not None, f"{name} called without specifying 'site_id'. This may lead to unexpected behavior. Call {name} with 'site_id=<some_id>' instead."
1817
if site_id is None:
1918
import warnings
2019

Collapse file

‎cms/utils/placeholder.py‎

Copy file name to clipboardExpand all lines: cms/utils/placeholder.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def get_toolbar_plugin_struct(plugins, slot=None, page=None):
139139
"""
140140
template = None
141141

142-
if page:
142+
if page and hasattr(page, "get_template"):
143143
template = page.get_template()
144144

145145
modules = get_placeholder_conf("plugin_modules", slot, template, default={})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.