class CategoryTasksSchema(ma.Schema): class Meta: json_module = json strict = True fields = ('items', 'category_url', 'self_url') test = ma.String('132323') items = ma.Nested(TaskSchema, only=('id', 'title', 'self_url'), many=True) category_url = ma.Url() self_url = ma.Url()
class TaskOfferSchema(ma.Schema): class Meta: json_module = json strict = True fields = ('id', 'text', 'created_at', 'task', 'doer', 'price') self_url = ma.Url(attribute='selfApiUrl') price = ma.Float() task = ma.Nested(TaskSchema, only=('id', 'title', 'status')) doer = ma.Nested(UserSchema, only=('id', 'full_name', 'age'))
class TaskSchema(ma.Schema): class Meta: json_module = json strict = True fields = ('id', 'title', 'description', 'created_at', 'due', 'contacts', 'addresses', 'reward', 'status', 'additional_data', 'category', 'self_url') self_url = ma.Url(attribute='selfApiUrl') reward = ma.Float() category = ma.Nested(CategorySchema)
class CategorySchema(ma.Schema): class Meta: json_module = json strict = True fields = ('id', 'name', 'url_name', 'tasks_url', 'self_url', 'children') tasks_url = ma.Function(lambda cat: url_for( 'api.category_tasks', url_name=cat.url_name, _external=True)) self_url = ma.Url(attribute='selfApiUrl') children = ma.Nested('self', only=('id', 'name', 'url_name', 'self_url', 'tasks_url'), many=True)
class TrustedPersonSchema(ma.Schema): class Meta: json_module = json strict = True fields = ( 'id', 'description', 'full_name', 'phone', 'user' ) self_url = ma.Url(attribute='selfApiUrl') user = ma.Nested(UserSchema, only=('id', 'full_name', 'age'))
class UserSchema(ma.Schema): class Meta: json_module = json strict = True fields = ('id', 'full_name', 'registered_at', 'last_visited_at', 'phone', 'email', 'city', 'active', 'doer', 'task_categories', 'balance', 'roles', 'age', 'about', 'rating', 'email_confirmed', 'self_url') self_url = ma.Url(attribute='selfApiUrl') balance = ma.Float() task_categories = ma.Nested(CategorySchema, only=('id', 'name', 'url_name', 'self_url'), many=True)
class TaskCommentSchema(ma.Schema): class Meta: json_module = json strict = True fields = ( 'id', 'text', 'created_at', 'task', 'author', ) self_url = ma.Url(attribute='selfApiUrl') reward = ma.Float() task = ma.Nested(TaskSchema, only=('id', 'title', 'status')) author = ma.Nested(UserSchema, only=('id', 'full_name', 'age')) #customer = ma.Nested(TaskStatusEnumSchema, exclude=('created_tasks',)) #customer = db.Nested()