schemas.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. relative=True,
  17. attribute='calendar_url'
  18. )
  19. avatar_url = marshmallow.fields.Url()
  20. profile = marshmallow.fields.Nested(
  21. ProfileSchema,
  22. many=False,
  23. )
  24. class BasicAuthSchema(marshmallow.Schema):
  25. email = marshmallow.fields.Email(required=True)
  26. password = marshmallow.fields.String(required=True, load_only=True)
  27. class LoginOutputHeaders(marshmallow.Schema):
  28. expire_after = marshmallow.fields.String()
  29. class OkResponse(marshmallow.Schema):
  30. message = marshmallow.fields.String(required=True)