Skip to content

Commit 3cd8767

Browse files
authored
fix: AttributeError CMSPlugin (EditorNotePlugin) object has no attribute config (#280)
1 parent 1ef2bc7 commit 3cd8767

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

djangocms_frontend/ui_plugin_base.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from django.utils.encoding import force_str
44

55
from djangocms_frontend.helpers import get_related
6+
from djangocms_frontend.models import AbstractFrontendUIItem
67

78
try:
89
from cms.admin.placeholderadmin import PlaceholderAdmin
@@ -30,12 +31,13 @@ def __str__(self):
3031
return force_str(super().__str__())
3132

3233
def render(self, context, instance, placeholder):
33-
for key, value in instance.config.items():
34-
if isinstance(value, dict) and set(value.keys()) == {"pk", "model"}:
35-
if key not in instance.__dir__(): # hasattr would return the value in the config dict
36-
setattr(instance.__class__, key, get_related(key))
37-
if "instance" not in instance.config and isinstance(instance.config, dict):
38-
context.update(instance.config)
34+
if isinstance(instance, AbstractFrontendUIItem):
35+
for key, value in instance.config.items():
36+
if isinstance(value, dict) and set(value.keys()) == {"pk", "model"}:
37+
if key not in instance.__dir__(): # hasattr would return the value in the config dict
38+
setattr(instance.__class__, key, get_related(key))
39+
if "instance" not in instance.config and isinstance(instance.config, dict):
40+
context.update(instance.config)
3941
return super().render(context, instance, placeholder)
4042

4143
if not hasattr(PlaceholderAdmin, "edit_field"):

tests/test_settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@
119119

120120
SITE_ID = 1
121121

122+
STATIC_URL = "/static/"
123+
122124
ROOT_URLCONF = "tests.urls"
123125

124126
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

tests/utilities/test_plugins.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,5 @@ def test_editor_note_with_cms4(self):
164164

165165
with self.login_user_context(self.superuser):
166166
response = self.client.get(endpoint)
167-
print(response.content)
168167
self.assertEqual(response.status_code, 200)
169168
self.assertContains(response, 'My private note')

0 commit comments

Comments
 (0)