Skip to content

Commit 635fc42

Browse files
committed
Add submission_precheck to public fields list
1 parent 3593ec7 commit 635fc42

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

backend/models/form.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"description",
1717
"submitted_text",
1818
"discord_role",
19+
# Member of the FormWithAncillaryData subclass
20+
"submission_precheck",
1921
]
2022

2123

@@ -73,13 +75,12 @@ def validate_features(cls, value: list[str]) -> list[str]:
7375
raise ValueError(msg)
7476

7577
if FormFeatures.REQUIRES_LOGIN.value not in value:
76-
if FormFeatures.COLLECT_EMAIL.value in value:
77-
msg = "COLLECT_EMAIL feature require REQUIRES_LOGIN feature."
78-
raise ValueError(msg)
78+
require_login_feature = [FormFeatures.COLLECT_EMAIL, FormFeatures.ASSIGN_ROLE, FormFeatures.UNIQUE_RESPONDER]
7979

80-
if FormFeatures.ASSIGN_ROLE.value in value:
81-
msg = "ASSIGN_ROLE feature require REQUIRES_LOGIN feature."
82-
raise ValueError(msg)
80+
for feature in require_login_feature:
81+
if feature.value in value:
82+
msg = f"{feature.value} feature requires REQUIRES_LOGIN feature."
83+
raise ValueError(msg)
8384

8485
return value
8586

@@ -110,6 +111,8 @@ def dict(self, admin: bool = True, **kwargs) -> dict[str, t.Any]: # noqa: FBT00
110111
returned_data = {}
111112

112113
for field in PUBLIC_FIELDS:
114+
if field not in data:
115+
continue
113116
fetch_field = "_id" if field == "id" and kwargs.get("by_alias") else field
114117
returned_data[field] = data[fetch_field]
115118

0 commit comments

Comments
 (0)