Skip to content

Commit e2350e5

Browse files
authored
fix: Action tab failed form validation if djangocms-link was installed (#30)
* fix: broken Actions tab of form admin * Update djangocms_form_builder/settings.py * Fix sourcery recommendation * Fix form validation for redirect action * Keep required argument * Bump version
1 parent 9c234ff commit e2350e5

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.rst

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

5+
0.3.2 (2025-03-04)
6+
==================
7+
8+
* fix: Action tab failed form validation if djangocms-link was installed
9+
510
0.3.1 (2025-03-03)
611
==================
712

djangocms_form_builder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
_ = lambda x: x # noqa: E731
77

88

9-
__version__ = "0.3.1"
9+
__version__ = "0.3.2"
1010

1111
_form_registry = {}
1212

djangocms_form_builder/actions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def get_action_class(action):
5656
return _action_registry.get(action, None)
5757

5858

59+
def get_hash(action_class):
60+
return hashlib.sha1(action_class.__name__.encode("utf-8")).hexdigest()
61+
62+
5963
class ActionMixin:
6064
"""Adds action form elements to Form plugin admin"""
6165

@@ -283,6 +287,11 @@ class Meta:
283287
required=True,
284288
)
285289

290+
def __init__(self, *args, **kwargs):
291+
super().__init__(*args, **kwargs)
292+
if args:
293+
self.fields["redirect_link"].required = get_hash(RedirectAction) in args[0].get("form_actions", [])
294+
286295
def execute(self, form, request):
287296
form.Meta.options["redirect"] = get_link(
288297
self.get_parameter(form, "redirect_link")

0 commit comments

Comments
 (0)