Skip to content

Commit 0549116

Browse files
author
Biel Frontera
authored
fix: Link template choices from correct setting (#98)
* fix: Link template choices from correct setting Template choices in LinkForm were being computed from the setting DJANGOCMS_LINK_TEMPLATES instead of LINK_TEMPLATE_CHOICES, that is the setting that exists on djangocms_frontend.settings * Add fix link template choices setting to changelog * fix dcf_setting in Link data migration
1 parent e50fb61 commit 0549116

File tree

4 files changed

+7
-21
lines changed

4 files changed

+7
-21
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ unpublished
66
===========
77

88
* Add missing form mixin for link plugin (allowing it to be extended)
9+
* Fix Link template choices from correct setting
910

1011
1.0.1
1112
=====

djangocms_frontend/contrib/link/forms.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,6 @@ def __init__(self, *args, **kwargs):
4545
super().__init__(*args, **kwargs)
4646

4747

48-
def get_templates():
49-
choices = [
50-
("default", _("Default")),
51-
]
52-
choices += getattr(
53-
settings,
54-
"DJANGOCMS_LINK_TEMPLATES",
55-
[],
56-
)
57-
return choices
58-
59-
6048
HOSTNAME = getattr(settings, "DJANGOCMS_LINK_INTRANET_HOSTNAME_PATTERN", None)
6149
LINK_MODELS = getattr(django_settings, "DJANGOCMS_FRONTEND_LINK_MODELS", [])
6250
MINIMUM_INPUT_LENGTH = getattr(
@@ -327,8 +315,8 @@ class Meta:
327315
)
328316
template = forms.ChoiceField(
329317
label=_("Template"),
330-
choices=get_templates(),
331-
initial=first_choice(get_templates()),
318+
choices=settings.LINK_TEMPLATE_CHOICES,
319+
initial=first_choice(settings.LINK_TEMPLATE_CHOICES),
332320
)
333321
link_stretched = forms.BooleanField(
334322
label=_("Stretch link"),

djangocms_frontend/management/bootstrap4_migration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def t001_template(obj, new_obj, bs4_setting, dcf_setting):
505505
x, y, "DJANGOCMS_PICTURE_TEMPLATES", "DJANGOCMS_PICTURE_TEMPLATES"
506506
),
507507
"T001_LINK": lambda x, y: t001_template(
508-
x, y, "DJANGOCMS_LINK_TEMPLATES", "DJANGOCMS_LINK_TEMPLATES"
508+
x, y, "DJANGOCMS_LINK_TEMPLATES", "DJANGOCMS_FRONTEND_LINK_TEMPLATE_CHOICES"
509509
),
510510
"T001_TABS": lambda x, y: t001_template(
511511
x, y, "DJANGOCMS_BOOTSTRAP4_TAB_TEMPLATES", "DJANGOCMS_FRONTEND_TAB_TEMPLATES"

tests/link/test_plugins.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
from cms.test_utils.testcases import CMSTestCase
33
from django.http import HttpRequest
44

5+
from djangocms_frontend import settings
56
from djangocms_frontend.contrib.link.cms_plugins import LinkPlugin
6-
from djangocms_frontend.contrib.link.forms import (
7-
LinkForm,
8-
SmartLinkField,
9-
get_templates,
10-
)
7+
from djangocms_frontend.contrib.link.forms import LinkForm, SmartLinkField
118
from djangocms_frontend.contrib.link.helpers import get_choices
129

1310
from ..fixtures import DJANGO_CMS4, TestFixture
@@ -135,7 +132,7 @@ def test_smart_link_field(self):
135132
def test_link_form(self):
136133
request = HttpRequest()
137134
request.POST = {
138-
"template": get_templates()[0][0],
135+
"template": settings.LINK_TEMPLATE_CHOICES[0][0],
139136
"link_type": "link",
140137
}
141138
form = LinkForm(request.POST)

0 commit comments

Comments
 (0)