schemas.py 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # coding=utf-8
  2. import marshmallow
  3. class ProfileSchema(marshmallow.Schema):
  4. id = marshmallow.fields.Int(dump_only=True)
  5. slug = marshmallow.fields.String(attribute='name')
  6. class UserSchema(marshmallow.Schema):
  7. user_id = marshmallow.fields.Int(dump_only=True)
  8. email = marshmallow.fields.Email(required=True)
  9. display_name = marshmallow.fields.String()
  10. created = marshmallow.fields.DateTime(format='iso8601')
  11. is_active = marshmallow.fields.Bool()
  12. # TODO - G.M - 17-04-2018 - Restrict timezone values
  13. timezone = marshmallow.fields.String()
  14. # TODO - G.M - 17-04-2018 - check this, relative url allowed ?
  15. caldav_url = marshmallow.fields.Url(
  16. allow_none=True,
  17. default=None,
  18. relative=True,
  19. attribute='calendar_url'
  20. )
  21. avatar_url = marshmallow.fields.Url(allow_none=True, default=None)
  22. profile = marshmallow.fields.Nested(
  23. ProfileSchema,
  24. many=False,
  25. )
  26. class BasicAuthSchema(marshmallow.Schema):
  27. email = marshmallow.fields.Email(required=True)
  28. password = marshmallow.fields.String(required=True, load_only=True)
  29. class LoginOutputHeaders(marshmallow.Schema):
  30. expire_after = marshmallow.fields.String()
  31. class OkResponse(marshmallow.Schema):
  32. message = marshmallow.fields.String(required=True)