Esempio n. 1
0
class LabelSchema(ma.ModelSchema, JavaScriptMixin):
    class Meta:
        model = Label
        # FIXME: make `id` read-only, schema -> ValueType object
        fields = ('id', 'label', '_links')

    # Smart hyperlinking
    _links = ma.Hyperlinks(
        {"self": ma.URLFor("label_items_api", entity="<id>"), "collection": ma.URLFor("labels_api")}
    )
Esempio n. 2
0
class UserSchema(ma.SQLAlchemyAutoSchema, JavaScriptMixin):
    class Meta:
        model = User
        strict = True
        only = ('login', 'password', 'first_name', 'last_name', 'email',
                'activated', 'lang_key', '_links')

    # Smart hyperlinking
    _links = ma.Hyperlinks({
        "self": ma.URLFor("users.get_one", user_id="<uid>"),
        "collection": ma.URLFor("users.get_all")
    })
Esempio n. 3
0
class BankAccountSchema(ma.ModelSchema, JavaScriptMixin):
    class Meta:
        model = BankAccount
        fields = ('balance', 'id', 'name', 'operations', 'user', '_links')

    user = ma.Nested(UserSchema)
    operations = ma.List(ma.Nested(OperationSchema))

    # Smart hyperlinking
    _links = ma.Hyperlinks(
        {"self": ma.URLFor("account_items_api", entity="<id>"), "collection": ma.URLFor("accounts_api")}
    )