diff options
Diffstat (limited to '')
| -rw-r--r-- | backend/models/form.py | 11 | 
1 files changed, 11 insertions, 0 deletions
| diff --git a/backend/models/form.py b/backend/models/form.py index 8d7fe9b..6b3c8bb 100644 --- a/backend/models/form.py +++ b/backend/models/form.py @@ -5,6 +5,8 @@ from pydantic import BaseModel, Field, validator  from backend.constants import FormFeatures  from .question import Question +PUBLIC_FIELDS = ["id", "features", "questions", "name", "description"] +  class Form(BaseModel):      """Schema model for form.""" @@ -31,3 +33,12 @@ class Form(BaseModel):              raise ValueError("COLLECT_EMAIL feature require REQUIRES_LOGIN feature.")          return value + +    def dict(self, admin: bool = True, **kwargs: t.Dict) -> t.Dict[str, t.Any]: +        """Wrapper for original function to exclude private data for public access.""" +        data = super().dict(**kwargs) + +        if admin: +            return data + +        return {field: data[field] for field in PUBLIC_FIELDS} | 
