Skip to content

Commit 5b8313e

Browse files
committed
fix: Fix form_list view not showing forms with empty submit_groups (v0.6.1)
The ManyToMany field check 'submit_groups__isnull=True' doesn't work correctly when the relationship is empty (no rows in join table). Changed to use Count annotation and check for submit_group_count=0 instead. This fixes the issue where authenticated users saw 'No forms available' even though forms had no submit_group restrictions configured.
1 parent 2c0a8a0 commit 5b8313e

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

django_forms_workflows/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Enterprise-grade, database-driven form builder with approval workflows
44
"""
55

6-
__version__ = "0.6.0"
6+
__version__ = "0.6.1"
77
__author__ = "Django Forms Workflows Contributors"
88
__license__ = "LGPL-3.0-only"
99

django_forms_workflows/views.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ def form_list(request):
3636
forms = FormDefinition.objects.filter(is_active=True)
3737
else:
3838
# Get forms where user is in submit_groups or no groups specified
39+
# Note: For ManyToMany fields, we need to check if the count is 0
40+
# because __isnull=True doesn't work correctly for empty M2M relationships
3941
forms = (
4042
FormDefinition.objects.filter(is_active=True)
43+
.annotate(submit_group_count=models.Count("submit_groups"))
4144
.filter(
4245
models.Q(submit_groups__in=user_groups)
43-
| models.Q(submit_groups__isnull=True)
46+
| models.Q(submit_group_count=0)
4447
)
4548
.distinct()
4649
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-forms-workflows"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
description = "Enterprise-grade, database-driven form builder with approval workflows and external data integration"
55
license = "LGPL-3.0-only"
66
readme = "README.md"

setup.py

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

1414
setup(
1515
name='django-forms-workflows',
16-
version='0.6.0',
16+
version='0.6.1',
1717
description='Enterprise-grade, database-driven form builder with approval workflows and external data integration',
1818
long_description=long_description,
1919
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)