-
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.
Merge pull request #4885 from open-formulieren/feature/4321-allow-max…
…imum-number-of-submissions [#4321] Allow max number of submissions per form
- Loading branch information
Showing
27 changed files
with
651 additions
and
54 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from django.urls import reverse | ||
|
||
from ...models import Category | ||
|
||
|
||
class FormListAjaxMixin: | ||
def _get_form_changelist(self, query=None, **kwargs): | ||
""" | ||
Utility to mimick the ajax-loading of form tables per category. | ||
""" | ||
query = query or {} | ||
|
||
url = reverse("admin:forms_form_changelist") | ||
# get the server rendered scaffolding | ||
changelist = self.app.get(url, params=query, **kwargs) | ||
|
||
return self._load_async_category_form_lists(changelist, **kwargs) | ||
|
||
def _load_async_category_form_lists(self, response, query=None, **kwargs): | ||
url = reverse("admin:forms_form_changelist") | ||
query = dict(response.request.params) | ||
|
||
# get the ajax call responses | ||
category_ids = [""] + list(Category.objects.values_list("id", flat=True)) | ||
for category_id in category_ids: | ||
ajax_response = self.app.get( | ||
url, params={**query, "_async": 1, "category": category_id}, **kwargs | ||
) | ||
if not ajax_response.text.strip(): | ||
continue | ||
|
||
pq = response.pyquery("html") | ||
rows = ajax_response.pyquery("tbody") | ||
if not rows: | ||
continue | ||
|
||
# rewrite the response body with the new HTML as if injected by JS | ||
pq("table").append(rows.html()) | ||
response.text = pq.html() | ||
|
||
response._forms_indexed = None | ||
|
||
return response |
Oops, something went wrong.