class CategorySchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Category
        fields = ('id', 'title', 'order', '_links')
        dump_only = ('_links', )

    order = ma.auto_field(validate=[Range(min=0)])
    _links = ma.Hyperlinks({
        'self':
        ma.URLFor('category', values={'category_id': '<id>'}),
        'collection':
        ma.URLFor('categories'),
        'pages':
        ma.URLFor('pages', values={'category_id': '<id>'})
    })
Пример #2
0
class EventSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Event
        fields = ('id', 'name', 'details', 'start', 'end', 'owner', '_links')
        dump_only = ('id', 'owner', '_links')
        include_fk = True

    id = fields.UUID()
    owner = ma.auto_field('owner_id')
    _links = ma.Hyperlinks({
        'self':
        ma.URLFor('event', values={'event_id': '<id>'}),
        'collection':
        ma.URLFor('events'),
        'owner':
        ma.URLFor('user', values={'user_id': '<owner>'})
    })
Пример #3
0
class GallerySchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Gallery
        fields = ('id', 'title', 'owner', 'media', '_links')
        dump_only = ('id', 'owner', 'media', '_links')
        include_relationships = True
        include_fk = True

    id = fields.UUID()
    owner = ma.auto_field('owner_id')
    media = fields.Nested(MediaSchema, many=True)
    _links = ma.Hyperlinks({
        'self':
        ma.URLFor('gallery', values={'gallery_id': '<id>'}),
        'collection':
        ma.URLFor('galleries'),
        'owner':
        ma.URLFor('user', values={'user_id': '<owner>'})
    })
Пример #4
0
class MediaSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Media
        fields = ('id', 'name', 'mimetype', 'extension', 'owner', '_links')
        dump_only = ('id', 'owner', '_links')
        include_fk = True

    id = fields.UUID()
    owner = ma.auto_field('owner_id')
    _links = ma.Hyperlinks({
        'self':
        ma.URLFor('media', values={'media_id': '<id>'}),
        'collection':
        ma.URLFor('medias'),
        'image':
        ma.URLFor('media_file', values={'media_id': '<id>'}),
        'thumbnail':
        ma.URLFor('media_file', values={
            'media_id': '<id>',
            'thumb': ''
        }),
        'owner':
        ma.URLFor('user', values={'user_id': '<owner>'})
    })
Пример #5
0
class PageSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Page
        fields = ('category', 'id', 'title', 'order', '_links')
        dump_only = ('_links', )
        include_fk = True

    order = ma.auto_field(validate=[Range(min=0)])
    _links = ma.Hyperlinks({
        'self':
        ma.URLFor('page',
                  values={
                      'category_id': '<category>',
                      'page_id': '<id>'
                  }),
        'collection':
        ma.URLFor('pages', values={'category_id': '<category>'}),
        'content':
        ma.URLFor('content',
                  values={
                      'category_id': '<category>',
                      'page_id': '<id>'
                  })
    })