-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#4321] Allow specific amount of submissions per form
- Loading branch information
Showing
23 changed files
with
544 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/openforms/forms/migrations/0107_form_submission_counter_form_submission_limit.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 4.2.17 on 2024-12-12 10:00 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("forms", "0106_convert_price_logic_rules"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="form", | ||
name="submission_counter", | ||
field=models.PositiveIntegerField( | ||
default=0, | ||
help_text="Counter to track how many submissions have been completed for the specific form. This works in combination with the maximum allowed submissions per form and can be reset via the frontend.", | ||
verbose_name="submissions counter", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="form", | ||
name="submission_limit", | ||
field=models.PositiveIntegerField( | ||
blank=True, | ||
help_text="Maximum number of allowed submissions per form. Leave this empty if no limit is needed.", | ||
null=True, | ||
verbose_name="maximum allowed submissions", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -333,3 +333,22 @@ def test_patching_registrations_with_a_booboo(self): | |
self.assertEqual(backend2.name, "#2") | ||
self.assertEqual(backend2.backend, "email") | ||
self.assertEqual(backend2.options["to_emails"], ["[email protected]"]) | ||
|
||
def test_submission_limit_method_field(self): | ||
context = {"request": None} | ||
|
||
with self.subTest("submission_limit equal to submission_counter"): | ||
form = FormFactory.create(submission_limit=2, submission_counter=2) | ||
data = FormSerializer(context=context).to_representation(form) | ||
|
||
self.assertTrue(data["submission_limit_reached"]) | ||
with self.subTest("submission_max_allowed bigger than submission_counter"): | ||
form = FormFactory.create(submission_limit=2, submission_counter=1) | ||
data = FormSerializer(context=context).to_representation(form) | ||
|
||
self.assertFalse(data["submission_limit_reached"]) | ||
with self.subTest("submission_max_allowed smaller than submission_counter"): | ||
form = FormFactory.create(submission_limit=1, submission_counter=2) | ||
data = FormSerializer(context=context).to_representation(form) | ||
|
||
self.assertTrue(data["submission_limit_reached"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.