예제 #1
0
class TagSchema(ma.SQLAlchemySchema):
    class Meta:
        model = TagModel

    name = ma.auto_field()
    _links = ma.Hyperlinks({
        'self':
        ma.URLFor('tagresource', values=dict(tag_id="<id>")),
        'collection':
        ma.URLFor('tagslistresource')
    })
class TarefaSchema(ma.ModelSchema):
    class Meta:
        model = tarefa_model.Tarefa
        fields = ("id", "titulo", "descricao", "data_expiracao", "_links")

    titulo = fields.String(required=True)
    descricao = fields.String(required=True)
    data_expiracao = fields.Date(required=True)
    _links = ma.Hyperlinks({
        "get": ma.URLFor("tarefadetail", id="<id>"),
        "put": ma.URLFor("tarefadetail", id="<id>"),
        "delete": ma.URLFor("tarefadetail", id="<id>"),
    })
예제 #3
0
class UserSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = UserModel
        fields = ('id', 'username')

    id = ma.auto_field()
    username = ma.auto_field()
    _links = ma.Hyperlinks({
        'self':
        ma.URLFor('userresource', values=dict(user_id="<id>")),
        'collection':
        ma.URLFor('userslistresource')
    })
예제 #4
0
class ProdutoSchema(ma.SQLAlchemySchema):
    class Meta:
        model = produto_model.Produto
        fields = ("id", "nome", "descricao", "data_validade", "valor", "_links")
    
    nome = fields.String(required=True)
    descricao = fields.String(required=True)
    data_validade = fields.Date(required=True)
    valor = fields.Float(required=True)
    _links = ma.Hyperlinks({
        "get": ma.URLFor("produtodetail", id="<id>"),
        "put": ma.URLFor("produtodetail", id="<id>"),
        "delete": ma.URLFor("produtodetail", id="<id>")
    })
예제 #5
0
class NoteSchema(ma.SQLAlchemySchema):
    class Meta:
        model = NoteModel

    id = ma.auto_field()
    text = ma.auto_field()
    private = ma.auto_field()
    author = ma.Nested(UserSchema())
    tags = ma.Nested(TagSchema(many=True))

    _links = ma.Hyperlinks({
        'self':
        ma.URLFor('noteresource', values=dict(note_id="<id>")),
        'collection':
        ma.URLFor('noteslistresource')
    })