示例#1
0
class StoreSchema(BaseSchema):
    name = attributes.String()
    created_at = attributes.DateTime()
    updated_at = attributes.DateTime(allow_none=True)
    books = relationships.ToMany(foreign_types=('books', ), allow_none=True)

    class Options:
        resource_cls = Store
        resource_type = 'stores'
示例#2
0
class SeriesSchema(BaseSchema):
    title = attributes.String()
    created_at = attributes.DateTime()
    updated_at = attributes.DateTime(allow_none=True)

    books = relationships.ToMany(foreign_types=('books', ))
    photos = relationships.ToMany(foreign_types=('photos', ))

    class Options:
        resource_cls = Series
        resource_type = 'series'
示例#3
0
class ChapterSchema(BaseSchema):
    title = attributes.String()
    ordering = attributes.Integer()
    created_at = attributes.DateTime()
    updated_at = attributes.DateTime(allow_none=True)

    book = relationships.ToOne(foreign_types=('books', ))

    class Options:
        resource_cls = Chapter
        resource_type = 'chapters'
示例#4
0
class AuthorSchema(BaseSchema):
    name = attributes.String()
    date_of_birth = attributes.Date()
    date_of_death = attributes.Date(allow_none=True)
    created_at = attributes.DateTime()
    updated_at = attributes.DateTime(allow_none=True)

    books = relationships.ToMany(foreign_types=('books', ))
    photos = relationships.ToMany(foreign_types=('photos', ), allow_none=True)

    class Options:
        resource_cls = Author
        resource_type = 'authors'
示例#5
0
class PhotoSchema(BaseSchema):
    title = attributes.String()
    uri = attributes.String()
    created_at = attributes.DateTime()
    updated_at = attributes.DateTime(allow_none=True)

    imageable = relationships.ToOne(foreign_types=('authors', 'books',
                                                   'series')  # polymorphic
                                    )

    class Options:
        resource_cls = Photo
        resource_type = 'photos'
示例#6
0
class BookSchema(BaseSchema):
    title = attributes.String()
    date_published = attributes.Date()
    created_at = attributes.DateTime()
    updated_at = attributes.DateTime(allow_none=True)

    author = relationships.ToOne(foreign_types=('author', ))
    series = relationships.ToOne(foreign_types=('series', ), allow_none=True)
    chapters = relationships.ToMany(foreign_types=('chapters', ))
    photos = relationships.ToMany(foreign_types=('photos', ), allow_none=True)

    class Options:
        resource_cls = Book
        resource_type = 'books'