class AlbumSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Album
        dump_only = ["user_rating"]

    album_type = ma.String(
        validate=[Length(
            max=20), OneOf(["album", "compilation", "single"])])
    artist = ma.Nested("ArtistSchema",
                       only=("id", "href", "name", "object_type", "uri"))
    copyright = ma.String(required=True, validate=Length(max=100))
    copyright_type = ma.String(required=True,
                               validate=[Length(max=1),
                                         OneOf(["C", "P"])])
    genre = ma.String(required=True, validate=Length(max=20))
    href = ma.String()
    label = ma.String(required=True, validate=Length(max=50))
    name = ma.String(required=True)
    release_date = ma.Integer(required=True, validate=Range(min=1, max=2020))
    release_date_precision = ma.String(required=True, validate=Equal("year"))
    object_type = ma.String(required=True, validate=Equal("album"))
    tracks = ma.Nested("TrackSchema",
                       many=True,
                       only=("id", "href", "name", "duration_ms",
                             "duration_min", "duration_sec", "explicit",
                             "popularity", "uri", "user_rating"))
    uri = ma.String()
    user_rating = ma.Integer(validate=Range(min=1, max=5))
class UserSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = User
        load_only = ["password"]

    email = ma.String(required=True, validate=Length(min=4))
    password = ma.String(required=True, validate=Length(min=6))
    username = ma.String(required=True, validate=Length(min=3, max=30))
    teams = ma.Nested("TeamSchema",
                      many=True,
                      only=("id", "name", "is_private"))
class TeamSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Team

    name = ma.String(required=True, validate=Length(min=3, max=50))
    description = ma.String(validate=Length(max=2000))
    is_private = ma.Boolean()
    owner_id = ma.Integer(required=True)
    team_pokemon = ma.Nested("TeamsPokemonSchema",
                             many=True,
                             only=("id", "team_index", "pokemon_id",
                                   "pokemon"))
    owner = ma.Nested("UserSchema", only=("username", ))
class PokemonSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Pokemon

    pokeapi_id = ma.Integer(required=True,
                            validate=OneOf(
                                {*range(1, 899), *range(10001, 10221)}))
    pokemon_id = ma.Integer(required=True, validate=Range(min=1, max=898))
    pokemon_name = ma.String(required=True)
Beispiel #5
0
class ArtistSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Artist

    albums = ma.Nested("AlbumSchema",
                       many=True,
                       only=("album_type", "id", "href", "name",
                             "release_date", "uri"))
    followers = ma.Integer()
    genre = ma.String(required=True, validate=Length(max=20))
    href = ma.String()
    name = ma.String(required=True)
    popularity = ma.Integer(validate=Range(min=0, max=100))
    object_type = ma.String(required=True, validate=Equal("artist"))
    tracks = ma.Nested("TrackSchema",
                       many=True,
                       only=("album.name", "id", "href", "name", "duration_ms",
                             "explicit", "popularity", "uri"))
    uri = ma.String()
Beispiel #6
0
class ItemSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Item
        ordered = True
        dump_only = ["completion_date"]

    name = ma.String(required=True, validate=Length(min=1))
    status = ma.Boolean()
    index = ma.Integer()
    checklist_id = ma.Integer()
    assigned_id = ma.Integer()
    completion_date = ma.DateTime()
class UserSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = User
        ordered = True
        load_only = ["password"]

    username = ma.String(required=True, validate=Length(min=4))
    email = ma.String(required=True, validate=Length(min=4))
    password = ma.String(required=True, validate=Length(min=6))
    name = ma.String()
    profile_image = ma.String()
    timezone = ma.Integer()
    has_reminders = ma.Boolean()
    reminder_time = ma.Integer()
    owned_checklists = ma.Nested("ChecklistSchema",
                                 many=True,
                                 only=("id", "title"))
    checklists = ma.Nested("ChecklistSchema", many=True, only=("id", "title"))
    items = ma.Nested("ItemSchema",
                      many=True,
                      only=("id", "name", "checklist_id"))
class UserSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = User
        load_only = ["password"]
        dump_only = ["admin"]

    email = ma.String(required=True, validate=Length(min=4))
    password = ma.String(required=True, validate=Length(min=6))
    country = ma.String(validate=Length(equal=2))
    display_name = ma.String(validate=Length(max=30))
    href = ma.String()
    product = ma.String(validate=[
        Length(max=20),
        OneOf(["free", "premium", "student", "duo", "family"])
    ])
    object_type = ma.String(validate=Equal("user"))
    uri = ma.String()
    admin = ma.Boolean()
Beispiel #9
0
class TrackSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Track
        dump_only = ["duration_min", "duration_sec", "user_rating"]

    album = ma.Nested("AlbumSchema",
                      only=("album_type", "id", "href", "name", "release_date",
                            "uri"))
    artist = ma.Nested("ArtistSchema",
                       only=("id", "href", "name", "object_type", "uri"))
    disc_number = ma.Integer()
    duration_ms = ma.Integer(required=True)
    duration_min = ma.String()
    duration_sec = ma.String()
    explicit = ma.Boolean()
    href = ma.String()
    name = ma.String(required=True)
    popularity = ma.Integer(validate=Range(min=0, max=100))
    preview_url = ma.String()
    track_number = ma.Integer(required=True)
    object_type = ma.String(required=True, validate=Equal("track"))
    uri = ma.String()
    user_rating = ma.Integer()
    is_local = ma.Boolean()
Beispiel #10
0
class MoveSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = Move

    move_id = ma.Integer(validate=Range(min=1, max=826))
    move_name = ma.String()