Skip to content

Commit fbed89f

Browse files
authored
fix: Move autocomplete view for links to admin (#211)
1 parent 74dd2de commit fbed89f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+217
-570
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
Changelog
33
=========
44

5+
1.3.2 (2024-04-25)
6+
==================
7+
8+
* fix: make grid layout (rows/columns) compatible with flex box-based Django admin by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/208
9+
* fix: Improved handling of optional smart link field by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/210
10+
11+
512
1.3.1 (2024-04-12)
613
==================
714

djangocms_frontend/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
13. Github actions will publish the new package to pypi
2020
"""
2121

22-
__version__ = "1.3.1"
22+
__version__ = "1.3.2"

djangocms_frontend/common/attributes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ class AttributesMixin:
1616

1717
def get_fieldsets(self, request, obj=None):
1818
meta = self.form._meta
19-
fields = (
20-
["tag_type"] if "tag_type" in getattr(meta, "untangled_fields", ()) else []
21-
)
19+
fields = ["tag_type"] if "tag_type" in getattr(meta, "untangled_fields", ()) else []
2220
fields.append("attributes")
2321
return insert_fields(
2422
super().get_fieldsets(request, obj),

djangocms_frontend/common/bootstrap5/background.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ class Meta:
4747
background_context = forms.ChoiceField(
4848
label=_("Background context"),
4949
required=False,
50-
choices=settings.EMPTY_CHOICE
51-
+ settings.COLOR_STYLE_CHOICES
52-
+ (("transparent", _("Transparent")),),
50+
choices=settings.EMPTY_CHOICE + settings.COLOR_STYLE_CHOICES + (("transparent", _("Transparent")),),
5351
initial=settings.EMPTY_CHOICE[0][0],
5452
widget=ColoredButtonGroup(),
5553
)

djangocms_frontend/common/bootstrap5/sizing.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,13 @@ class Meta:
4646
initial=settings.EMPTY_CHOICE[0][0],
4747
choices=settings.EMPTY_CHOICE + settings.SIZE_X_CHOICES,
4848
# widget=ButtonGroup(attrs=dict(property="text")),
49-
help_text=_(
50-
"Sets the horizontal size relative to the surrounding container or the viewport."
51-
),
49+
help_text=_("Sets the horizontal size relative to the surrounding container or the viewport."),
5250
)
5351
size_y = forms.ChoiceField(
5452
label=_("Vertical size"),
5553
required=False,
5654
initial=settings.EMPTY_CHOICE[0][0],
5755
choices=settings.EMPTY_CHOICE + settings.SIZE_Y_CHOICES,
5856
# widget=ButtonGroup(attrs=dict(property="text")),
59-
help_text=_(
60-
"Sets the vertical size relative to the surrounding container or the viewport."
61-
),
57+
help_text=_("Sets the vertical size relative to the surrounding container or the viewport."),
6258
)

djangocms_frontend/common/spacing.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@ def __init__(self, **kwargs):
2828
self.side_choices = kwargs.pop("side_choices")
2929
super().__init__(
3030
[
31-
IconGroup(
32-
choices=[
33-
(self.property + side, verbose)
34-
for side, verbose in self.side_choices
35-
]
36-
),
31+
IconGroup(choices=[(self.property + side, verbose) for side, verbose in self.side_choices]),
3732
DivSelectWidget(choices=kwargs.pop("size_choices")),
3833
],
3934
**kwargs,

djangocms_frontend/common/title.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ def __init__(self, *args, **kwargs):
3636

3737
def clean(self, value):
3838
if value[0] and not value[1]:
39-
raise ValidationError(
40-
_("Please add a title if you want to publish it."), code="incomplete"
41-
)
39+
raise ValidationError(_("Please add a title if you want to publish it."), code="incomplete")
4240
return super().clean(value)
4341

4442
def compress(self, data_list):

djangocms_frontend/contrib/accordion/frameworks/bootstrap5.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,5 @@ def render(self, context, instance, placeholder):
1515
instance.add_classes("accordion-collapse collapse")
1616
if instance.accordion_item_open:
1717
instance.add_classes("show")
18-
instance.font_size = (
19-
context["parent"]
20-
.config.get("accordion_header_type", "")
21-
.replace("h", "fs-")
22-
)
18+
instance.font_size = context["parent"].config.get("accordion_header_type", "").replace("h", "fs-")
2319
return super().render(context, instance, placeholder)

djangocms_frontend/contrib/alert/cms_plugins.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414

1515
@plugin_pool.register_plugin
16-
class AlertPlugin(
17-
mixin_factory("Alert"), AttributesMixin, ResponsiveMixin, SpacingMixin, CMSUIPlugin
18-
):
16+
class AlertPlugin(mixin_factory("Alert"), AttributesMixin, ResponsiveMixin, SpacingMixin, CMSUIPlugin):
1917
"""
2018
Components > "Alerts" Plugin
2119
https://getbootstrap.com/docs/5.0/components/alerts/

djangocms_frontend/contrib/alert/forms.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
mixin_factory = settings.get_forms(alert)
1919

2020

21-
class AlertForm(
22-
mixin_factory("Alert"), ResponsiveFormMixin, SpacingFormMixin, EntangledModelForm
23-
):
21+
class AlertForm(mixin_factory("Alert"), ResponsiveFormMixin, SpacingFormMixin, EntangledModelForm):
2422
"""
2523
Components > "Alerts" Plugin
2624
https://getbootstrap.com/docs/5.0/components/alerts/

djangocms_frontend/contrib/card/forms.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
)
2929

3030
# card allow for a transparent color
31-
CARD_COLOR_STYLE_CHOICES = settings.COLOR_STYLE_CHOICES + (
32-
("transparent", _("Transparent")),
33-
)
31+
CARD_COLOR_STYLE_CHOICES = settings.COLOR_STYLE_CHOICES + (("transparent", _("Transparent")),)
3432

3533
CARD_TEXT_STYLES = COLOR_STYLE_CHOICES + (("white", _("White")),)
3634

@@ -132,9 +130,7 @@ class Meta:
132130
label=_("Alignment"),
133131
choices=settings.EMPTY_CHOICE + CARD_ALIGNMENT_CHOICES,
134132
required=False,
135-
widget=forms.HiddenInput()
136-
if "card_alignment" in getattr(settings, "EXCL_CARD_PROP", ())
137-
else IconGroup(),
133+
widget=forms.HiddenInput() if "card_alignment" in getattr(settings, "EXCL_CARD_PROP", ()) else IconGroup(),
138134
)
139135
card_text_color = forms.ChoiceField(
140136
label=_("Text context"),
@@ -148,9 +144,7 @@ class Meta:
148144
label=_("Full height"),
149145
initial=False,
150146
required=False,
151-
help_text=_(
152-
"If checked cards in one row will automatically extend to the full row height."
153-
),
147+
help_text=_("If checked cards in one row will automatically extend to the full row height."),
154148
widget=forms.HiddenInput()
155149
if "card_full_height" in getattr(settings, "EXCL_CARD_PROP", ())
156150
else forms.CheckboxInput,
@@ -193,9 +187,7 @@ class Meta:
193187
label=_("Content alignment"),
194188
choices=settings.EMPTY_CHOICE + settings.ALIGN_CHOICES,
195189
required=False,
196-
widget=forms.HiddenInput()
197-
if "text_alignment" in getattr(settings, "EXCL_CARD_PROP", ())
198-
else IconGroup(),
190+
widget=forms.HiddenInput() if "text_alignment" in getattr(settings, "EXCL_CARD_PROP", ()) else IconGroup(),
199191
)
200192
attributes = AttributesFormField()
201193
tag_type = TagTypeFormField()

djangocms_frontend/contrib/carousel/cms_plugins.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ class CarouselPlugin(mixin_factory("Carousel"), AttributesMixin, CMSUIPlugin):
4949
]
5050

5151
def get_render_template(self, context, instance, placeholder):
52-
return get_plugin_template(
53-
instance, "carousel", "carousel", CAROUSEL_TEMPLATE_CHOICES
54-
)
52+
return get_plugin_template(instance, "carousel", "carousel", CAROUSEL_TEMPLATE_CHOICES)
5553

5654

5755
@plugin_pool.register_plugin

djangocms_frontend/contrib/carousel/constants.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
(18, 9),
2929
) + tuple(getattr(settings, "DJANGOCMS_FRONTEND_CAROUSEL_ASPECT_RATIOS", tuple()))
3030

31-
CAROUSEL_ASPECT_RATIO_CHOICES = tuple(
32-
(f"{x}x{y}", f"{x}x{y}") for x, y in CAROUSEL_ASPECT_RATIOS
33-
)
31+
CAROUSEL_ASPECT_RATIO_CHOICES = tuple((f"{x}x{y}", f"{x}x{y}") for x, y in CAROUSEL_ASPECT_RATIOS)
3432

3533
CAROUSEL_TRANSITION_CHOICES = (
3634
("", _("Slide")),

djangocms_frontend/contrib/carousel/forms.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,14 @@ class Meta:
111111
label=_("Wrap"),
112112
initial=True,
113113
required=False,
114-
help_text=_(
115-
"Whether the carousel should cycle continuously or have " "hard stops."
116-
),
114+
help_text=_("Whether the carousel should cycle continuously or have " "hard stops."),
117115
)
118116
carousel_aspect_ratio = forms.ChoiceField(
119117
label=_("Aspect ratio"),
120118
choices=settings.EMPTY_CHOICE + CAROUSEL_ASPECT_RATIO_CHOICES,
121119
required=False,
122120
initial=settings.EMPTY_CHOICE[0][0],
123-
help_text=_(
124-
"Determines width and height of the image "
125-
"according to the selected ratio."
126-
),
121+
help_text=_("Determines width and height of the image " "according to the selected ratio."),
127122
)
128123
carousel_transition = forms.ChoiceField(
129124
label=_("Transition"),

djangocms_frontend/contrib/carousel/frameworks/bootstrap5.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ def render(self, context, instance, placeholder):
1717
height = float(context.get("height") or CAROUSEL_DEFAULT_SIZE[1])
1818

1919
if parent.carousel_aspect_ratio:
20-
aspect_width, aspect_height = tuple(
21-
int(i) for i in parent.carousel_aspect_ratio.split("x")
22-
)
20+
aspect_width, aspect_height = tuple(int(i) for i in parent.carousel_aspect_ratio.split("x"))
2321
height = width * aspect_height / aspect_width
2422

2523
instance.add_classes("carousel-item")

djangocms_frontend/contrib/carousel/models.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ def get_short_description(self):
5151
image_text = _("<file is missing>")
5252
elif self.rel_image.name:
5353
image_text = self.rel_image.name
54-
elif (
55-
self.rel_image.original_filename
56-
and os.path.split(self.rel_image.original_filename)[1]
57-
):
54+
elif self.rel_image.original_filename and os.path.split(self.rel_image.original_filename)[1]:
5855
image_text = os.path.split(self.rel_image.original_filename)[1]
5956
else:
6057
image_text = "Image"

djangocms_frontend/contrib/collapse/cms_plugins.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ class CollapsePlugin(mixin_factory("Collapse"), AttributesMixin, CMSUIPlugin):
3838

3939

4040
@plugin_pool.register_plugin
41-
class CollapseTriggerPlugin(
42-
mixin_factory("CollapseTrigger"), AttributesMixin, CMSUIPlugin
43-
):
41+
class CollapseTriggerPlugin(mixin_factory("CollapseTrigger"), AttributesMixin, CMSUIPlugin):
4442
"""
4543
Component > "Collapse" Plugin
4644
https://getbootstrap.com/docs/5.0/components/collapse/
@@ -64,9 +62,7 @@ class CollapseTriggerPlugin(
6462

6563

6664
@plugin_pool.register_plugin
67-
class CollapseContainerPlugin(
68-
mixin_factory("CollapseContainer"), AttributesMixin, CMSUIPlugin
69-
):
65+
class CollapseContainerPlugin(mixin_factory("CollapseContainer"), AttributesMixin, CMSUIPlugin):
7066
"""
7167
Component > "Collapse Container" Plugin
7268
https://getbootstrap.com/docs/5.0/components/collapse/

djangocms_frontend/contrib/grid/forms.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,11 @@ def clean(self):
182182
super().clean()
183183
for size in settings.DEVICE_SIZES:
184184
if f"{size}_col" in self.cleaned_data:
185-
if (
186-
isinstance(self.cleaned_data[f"{size}_col"], str)
187-
and self.cleaned_data[f"{size}_col"].isnumeric()
188-
):
189-
self.cleaned_data[f"{size}_col"] = int(
190-
self.cleaned_data[f"{size}_col"]
191-
)
185+
if isinstance(self.cleaned_data[f"{size}_col"], str) and self.cleaned_data[f"{size}_col"].isnumeric():
186+
self.cleaned_data[f"{size}_col"] = int(self.cleaned_data[f"{size}_col"])
192187
else:
193188
raise ValidationError(
194-
_(
195-
'Column size needs to be empty, "auto", or a '
196-
"number between 1 and %(cols)d"
197-
),
189+
_('Column size needs to be empty, "auto", or a ' "number between 1 and %(cols)d"),
198190
params=dict(cols=GRID_SIZE),
199191
code="invalid_column",
200192
)
@@ -233,16 +225,12 @@ def clean(self):
233225
extra_fields_column[f"{size}_ms"] = forms.BooleanField(
234226
label="ms-auto" if size == "xs" else f"ms-{size}-auto",
235227
required=False,
236-
widget=forms.HiddenInput()
237-
if "{size}_ms" in getattr(settings, "EXCL_COL_PROP", ())
238-
else forms.CheckboxInput(),
228+
widget=forms.HiddenInput() if "{size}_ms" in getattr(settings, "EXCL_COL_PROP", ()) else forms.CheckboxInput(),
239229
)
240230
extra_fields_column[f"{size}_me"] = forms.BooleanField(
241231
label="me-auto" if size == "xs" else f"me-{size}-auto",
242232
required=False,
243-
widget=forms.HiddenInput()
244-
if "{size}_me" in getattr(settings, "EXCL_COL_PROP", ())
245-
else forms.CheckboxInput(),
233+
widget=forms.HiddenInput() if "{size}_me" in getattr(settings, "EXCL_COL_PROP", ()) else forms.CheckboxInput(),
246234
)
247235

248236
GridColumnForm = type(

djangocms_frontend/contrib/grid/frameworks/bootstrap5.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ def get_grid_values(self):
4141
for device in settings.DEVICE_SIZES:
4242
for element in ("col", "order", "offset", "ms", "me"):
4343
size = getattr(self, f"{device}_{element}", None)
44-
if isinstance(size, int) and (
45-
element == "col" or element == "order" or element == "offset"
46-
):
44+
if isinstance(size, int) and (element == "col" or element == "order" or element == "offset"):
4745
if size == 0 and element == "col": # 0 represents auto
4846
size = "auto"
4947
if device == "xs":
@@ -62,9 +60,7 @@ def get_grid_values(self):
6260
class GridColumnRenderMixin:
6361
def render(self, context, instance, placeholder):
6462
instance.add_classes(
65-
f"col text-{instance.text_alignment}"
66-
if instance.config.get("text_alignment", None)
67-
else "col"
63+
f"col text-{instance.text_alignment}" if instance.config.get("text_alignment", None) else "col"
6864
)
6965
instance.add_classes(instance.column_alignment)
7066
instance.add_classes(get_grid_values(instance))

djangocms_frontend/contrib/grid/frameworks/foundation6.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ def get_grid_values(self):
4242
else:
4343
classes.append(f"{foundation_sizes.get(device, device)}-{size}")
4444
else:
45-
classes.append(
46-
f"{foundation_sizes.get(device, device)}-{element}-{size}"
47-
)
45+
classes.append(f"{foundation_sizes.get(device, device)}-{element}-{size}")
4846

4947
return classes
5048

djangocms_frontend/contrib/grid/models.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ class Meta:
2929
_("GridContainer")
3030

3131
def get_short_description(self):
32-
text = self.config.get("plugin_title", {}).get("title", "") or self.config.get(
33-
"attributes", {}
34-
).get("id", "")
32+
text = self.config.get("plugin_title", {}).get("title", "") or self.config.get("attributes", {}).get("id", "")
3533
for item in GRID_CONTAINER_CHOICES[1:]:
3634
if item[0] == self.container_type:
3735
text += f" ({item[1]})"
@@ -56,13 +54,9 @@ class Meta:
5654
_("GridRow")
5755

5856
def get_short_description(self):
59-
descr = self.config.get("plugin_title", {}).get("title", "") or self.config.get(
60-
"attributes", {}
61-
).get("id", "")
57+
descr = self.config.get("plugin_title", {}).get("title", "") or self.config.get("attributes", {}).get("id", "")
6258
column_count = len(self.child_plugin_instances or [])
63-
column_count_str = ngettext(
64-
"(1 column)", "(%(count)i columns)", column_count
65-
) % {"count": column_count}
59+
column_count_str = ngettext("(1 column)", "(%(count)i columns)", column_count) % {"count": column_count}
6660
if descr:
6761
column_count_str = f"{descr} {column_count_str}"
6862
return column_count_str
@@ -80,9 +74,7 @@ class Meta:
8074
_("GridColumn")
8175

8276
def get_short_description(self):
83-
text = self.config.get("plugin_title", {}).get("title", "") or self.config.get(
84-
"attributes", {}
85-
).get("id", "")
77+
text = self.config.get("plugin_title", {}).get("title", "") or self.config.get("attributes", {}).get("id", "")
8678

8779
if self.xs_col:
8880
text += f" (col-{self.xs_col}) "

djangocms_frontend/contrib/icon/cms_plugins.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class IconPlugin(
3434
text_icon = (
3535
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" '
3636
'class="bi bi-emoji-sunglasses" viewBox="0 0 16 16"><path d="M4.968 9.75a.5.5 0 1 0-.866.5A4.5 4.5 '
37-
'0 0 0 8 12.5a4.5 4.5 0 0 0 3.898-2.25.5.5 0 1 0-.866-.5A3.5 3.5 0 0 1 8 11.5a3.5 3.5 0 0 1-3.032-1.75M7 '
38-
'5.116V5a1 1 0 0 0-1-1H3.28a1 1 0 0 0-.97 1.243l.311 1.242A2 2 0 0 0 4.561 8H5a2 2 0 0 0 1.994-1.839A3 '
39-
'3 0 0 1 8 6c.393 0 .74.064 1.006.161A2 2 0 0 0 11 8h.438a2 2 0 0 0 1.94-1.515l.311-1.242A1 1 0 0 0 '
37+
"0 0 0 8 12.5a4.5 4.5 0 0 0 3.898-2.25.5.5 0 1 0-.866-.5A3.5 3.5 0 0 1 8 11.5a3.5 3.5 0 0 1-3.032-1.75M7 "
38+
"5.116V5a1 1 0 0 0-1-1H3.28a1 1 0 0 0-.97 1.243l.311 1.242A2 2 0 0 0 4.561 8H5a2 2 0 0 0 1.994-1.839A3 "
39+
"3 0 0 1 8 6c.393 0 .74.064 1.006.161A2 2 0 0 0 11 8h.438a2 2 0 0 0 1.94-1.515l.311-1.242A1 1 0 0 0 "
4040
'12.72 4H10a1 1 0 0 0-1 1v.116A4.2 4.2 0 0 0 8 5c-.35 0-.69.04-1 .116"/><path d="M16 8A8 8 0 1 1 0 8a8 8 '
4141
'0 0 1 16 0m-1 0A7 7 0 1 0 1 8a7 7 0 0 0 14 0"/></svg>'
4242
)

0 commit comments

Comments
 (0)