Exemplo n.º 1
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'
Exemplo n.º 2
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'
Exemplo n.º 3
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'
Exemplo n.º 4
0
class ArticleSchema(BaseSchema):
    title = attributes.String(required=Event.CREATE, max_length=256)
    author = relationships.ToOne(required=Event.CREATE,
                                 foreign_types=('people', ))
    comments = relationships.ToMany(foreign_types=('comments', ))

    class Options:
        resource_cls = Article
        resource_type = 'articles'
Exemplo n.º 5
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'