예제 #1
0
파일: schema.py 프로젝트: interphx/mvs
class PrivateMessageSchema(ma.Schema):
    class Meta:
        strict = True
        fields = ('id', 'sender', 'receiver', 'created_at', 'text', 'self_url')

    self_url = ma.Function(
        lambda pm: url_for('api.pm', id=pm.id, _external=True))
    sender = ma.Nested(UserSchema, only=('id', 'full_name', 'self_url'))
    receiver = ma.Nested(UserSchema, only=('id', 'full_name', 'self_url'))
예제 #2
0
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'))
예제 #3
0
파일: schema.py 프로젝트: interphx/mvs
class TaskListSchema(ma.Schema):
    class Meta:
        json_module = json
        strict = True
        fields = ('tasks', )

    tasks = ma.Nested(TaskSchema, only=('id', 'title', 'status'), many=True)
예제 #4
0
파일: schema.py 프로젝트: interphx/mvs
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()
예제 #5
0
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()
예제 #6
0
파일: schema.py 프로젝트: interphx/mvs
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)
예제 #7
0
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)
예제 #8
0
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'))
예제 #9
0
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)