Skip to content

Commit 1e6d2c2

Browse files
authored
fix: inline editing crashed for plugin template tags (#260)
1 parent 6d8dc1c commit 1e6d2c2

File tree

17 files changed

+87
-44
lines changed

17 files changed

+87
-44
lines changed

djangocms_frontend/common/attributes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ class Meta:
3636
"attributes",
3737
]
3838
}
39+
3940
attributes = AttributesFormField()

djangocms_frontend/component_base.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ class CMSFrontendComponent(forms.Form):
5050
_admin_form = None
5151
_model = None
5252
_plugin = None
53-
META_FIELDS = ["is_local", "disable_edit", "disable_child_plugins", "show_add_form",
54-
"frontend_editable_fields", "link_fieldset_position", "require_parent",
55-
"parent_classes"]
53+
META_FIELDS = [
54+
"is_local",
55+
"disable_edit",
56+
"disable_child_plugins",
57+
"show_add_form",
58+
"frontend_editable_fields",
59+
"link_fieldset_position",
60+
"require_parent",
61+
"parent_classes",
62+
]
5663

5764
@classmethod
5865
def admin_form_factory(cls, **kwargs) -> type:
@@ -149,7 +156,8 @@ def plugin_factory(cls) -> type:
149156
"slots": slots,
150157
"save_model": cls.save_model,
151158
**{
152-
field: getattr(cls._component_meta, field) for field in cls.META_FIELDS
159+
field: getattr(cls._component_meta, field)
160+
for field in cls.META_FIELDS
153161
if hasattr(cls._component_meta, field)
154162
},
155163
**(

djangocms_frontend/contrib/carousel/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ class Meta:
106106
label=_("Wrap"),
107107
initial=True,
108108
required=False,
109-
help_text=_("Whether the carousel should cycle continuously or have " "hard stops."),
109+
help_text=_("Whether the carousel should cycle continuously or have hard stops."),
110110
)
111111
carousel_aspect_ratio = forms.ChoiceField(
112112
label=_("Aspect ratio"),
113113
choices=settings.EMPTY_CHOICE + CAROUSEL_ASPECT_RATIO_CHOICES,
114114
required=False,
115115
initial=settings.EMPTY_CHOICE[0][0],
116-
help_text=_("Determines width and height of the image " "according to the selected ratio."),
116+
help_text=_("Determines width and height of the image according to the selected ratio."),
117117
)
118118
carousel_transition = forms.ChoiceField(
119119
label=_("Transition"),

djangocms_frontend/contrib/content/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Meta:
1515
verbose_name = _("Code block")
1616

1717
def get_short_description(self):
18-
return f'<{self.config.get("code_type", CODE_TYPE_CHOICES[0][0])}>'
18+
return f"<{self.config.get('code_type', CODE_TYPE_CHOICES[0][0])}>"
1919

2020

2121
class Blockquote(FrontendUIItem):

djangocms_frontend/contrib/grid/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def clean(self):
179179
self.cleaned_data[f"{size}_col"] = int(self.cleaned_data[f"{size}_col"])
180180
else:
181181
raise ValidationError(
182-
_('Column size needs to be empty, "auto", or a ' "number between 1 and %(cols)d"),
182+
_('Column size needs to be empty, "auto", or a number between 1 and %(cols)d'),
183183
params=dict(cols=GRID_SIZE),
184184
code="invalid_column",
185185
)

djangocms_frontend/contrib/grid/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class Meta:
6868
def get_short_description(self):
6969
text = self.config.get("plugin_title", {}).get("title", "") or self.config.get("attributes", {}).get("id", "")
7070

71-
if self.config.get('xs_col'):
71+
if self.config.get("xs_col"):
7272
text += f" (col-{self.xs_col}) "
7373
else:
7474
text += " (auto) "

djangocms_frontend/contrib/image/forms.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ class Meta:
120120
label=_("Width"),
121121
required=False,
122122
min_value=1,
123-
help_text=_("The image width as number in pixels. " 'Example: "720" and not "720px".'),
123+
help_text=_('The image width as number in pixels. Example: "720" and not "720px".'),
124124
)
125125
height = forms.IntegerField(
126126
label=_("Height"),
127127
required=False,
128128
min_value=1,
129-
help_text=_("The image height as number in pixels. " 'Example: "720" and not "720px".'),
129+
help_text=_('The image height as number in pixels. Example: "720" and not "720px".'),
130130
)
131131
alignment = forms.ChoiceField(
132132
label=_("Alignment"),
@@ -210,9 +210,7 @@ def clean(self):
210210
data = self.cleaned_data
211211
# you shall only set one image kind
212212
if not data.get("picture", False) and not data.get("external_picture", False):
213-
raise forms.ValidationError(
214-
_("You need to add either an image, " "or a URL linking to an external image.")
215-
)
213+
raise forms.ValidationError(_("You need to add either an image, or a URL linking to an external image."))
216214

217215
# certain cropping options do not work together, the following
218216
# list defines the disallowed options used in the ``clean`` method
@@ -234,7 +232,7 @@ def clean(self):
234232
break
235233

236234
if invalid_option_pair:
237-
message = _("Invalid cropping settings. " 'You cannot combine "{field_a}" with "{field_b}".')
235+
message = _('Invalid cropping settings. You cannot combine "{field_a}" with "{field_b}".')
238236
message = message.format(
239237
field_a=self.fields[invalid_option_pair[0]].label,
240238
field_b=self.fields[invalid_option_pair[0]].label,

djangocms_frontend/contrib/link/cms_plugins.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@
3737

3838
class LinkPluginMixin:
3939
link_fieldset_position = None
40-
link_fields = (
41-
(("site", "url_grouper"),)
42-
if apps.is_installed("djangocms_url_manager")
43-
else ("link", "target")
44-
)
40+
link_fields = (("site", "url_grouper"),) if apps.is_installed("djangocms_url_manager") else ("link", "target")
4541

4642
def render(self, context, instance, placeholder):
4743
if "request" in context:

djangocms_frontend/contrib/link/helpers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ def get_link(self) -> str:
2727
if not url_grouper:
2828
return ""
2929
from djangocms_url_manager.models import Url
30+
3031
url = Url.objects.filter(url_grouper=url_grouper).order_by("pk").last()
3132
if not url: # pragma: no cover
3233
return ""
3334
return url.get_absolute_url() or ""
3435

3536
from djangocms_link.helpers import get_link as djangocms_link_get_link
37+
3638
return djangocms_link_get_link(self.config.get("link", {}), Site.objects.get_current().pk) or ""

djangocms_frontend/contrib/navigation/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Meta:
1515
verbose_name = _("Navigation")
1616

1717
def get_short_description(self):
18-
return f'({self.config.get("navbar_design", "-")})'
18+
return f"({self.config.get('navbar_design', '-')})"
1919

2020

2121
class NavContainer(FrontendUIItem):

0 commit comments

Comments
 (0)