diff options
| author | 2025-08-08 23:25:39 +0100 | |
|---|---|---|
| committer | 2025-08-08 23:25:39 +0100 | |
| commit | 635fc428492403a6ddf848d528602153ec4934c1 (patch) | |
| tree | 993270441a587167b6444cf09817e757ff81b216 /backend/models | |
| parent | Validate unique responses on submission (diff) | |
Add submission_precheck to public fields list
Diffstat (limited to 'backend/models')
| -rw-r--r-- | backend/models/form.py | 15 | 
1 files changed, 9 insertions, 6 deletions
| diff --git a/backend/models/form.py b/backend/models/form.py index 70a77a9..177427c 100644 --- a/backend/models/form.py +++ b/backend/models/form.py @@ -16,6 +16,8 @@ PUBLIC_FIELDS = [      "description",      "submitted_text",      "discord_role", +    # Member of the FormWithAncillaryData subclass +    "submission_precheck",  ] @@ -73,13 +75,12 @@ class Form(BaseModel):              raise ValueError(msg)          if FormFeatures.REQUIRES_LOGIN.value not in value: -            if FormFeatures.COLLECT_EMAIL.value in value: -                msg = "COLLECT_EMAIL feature require REQUIRES_LOGIN feature." -                raise ValueError(msg) +            require_login_feature = [FormFeatures.COLLECT_EMAIL, FormFeatures.ASSIGN_ROLE, FormFeatures.UNIQUE_RESPONDER] -            if FormFeatures.ASSIGN_ROLE.value in value: -                msg = "ASSIGN_ROLE feature require REQUIRES_LOGIN feature." -                raise ValueError(msg) +            for feature in require_login_feature: +                if feature.value in value: +                    msg = f"{feature.value} feature requires REQUIRES_LOGIN feature." +                    raise ValueError(msg)          return value @@ -110,6 +111,8 @@ class Form(BaseModel):          returned_data = {}          for field in PUBLIC_FIELDS: +            if field not in data: +                continue              fetch_field = "_id" if field == "id" and kwargs.get("by_alias") else field              returned_data[field] = data[fetch_field] | 
