Files
RosterChief/formbuilder/services/__init__.py
Bernard Siebens 5dd3715c1f feat(formbuilder): fix tenancy bugs, add admin + services
Fix multi-tenancy/integrity bugs in the models: Form.slug and Field.key
were globally unique (unique=True), so two clubs couldn't reuse a form
slug and two forms couldn't reuse a field key — make slug unique per club
(constraint already present) and key unique per form. Add a
(submission, field) uniqueness constraint on Answer.

Register all four models in the admin (Field inline on Form, Answer inline
on Submission) and add formbuilder to the admin registration smoke test.

Add a service layer:
- submit_form(form, member, data): enforces is_active / login_required /
  open window / max_submissions, validates required + choice fields, and
  writes a Submission with Answers atomically (FormSubmissionError carries
  per-field errors).
- build_form(form): a live django.forms.Form built from a Form's active
  fields, mapping each FieldType to the matching form field.
- form_report(form): a tabular overview of every submission's answers plus
  per-value tallies for choice-type fields.

Full suite at 100% coverage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-12 21:13:16 +02:00

17 lines
421 B
Python

from .form_factory import build_form, build_form_class
from .options import allowed_values, field_choices
from .reporting import FormReport, ReportRow, form_report
from .submission import FormSubmissionError, submit_form
__all__ = [
"FormReport",
"FormSubmissionError",
"ReportRow",
"allowed_values",
"build_form",
"build_form_class",
"field_choices",
"form_report",
"submit_form",
]