schemas.py 1.2KB

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