Exemplo n.º 1
0
class PostVotesSchema(ModelSchema):

    voter = Related()
    post = Related()

    class Meta:
        model = PostVotes
Exemplo n.º 2
0
class CommentSchema(ModelSchema):
    parent = Related()
    author = Related()
    post = Related()

    class Meta:
        model = Comment
Exemplo n.º 3
0
class AuthorsBooksSchema(ModelSchema):
    book_id = Related(nested=BookSchema)
    author_id = Related(nested=AutorSchema)

    @validates('book_id')
    def validate_book(self, value):
        if not Books.filter(Books.id == value).exists():
            raise ValidationError("Can't find book!")

    @validates('author_id')
    def validate_autor(self, value):
        if not Autors.filter(Autors.id == value).exists():
            raise ValidationError("Can't find author!")
class AuthorBookSchema(BookSchema):
    book = Related(nested=BookSchema)
    author = Related(nested=AuthorSchema)

    class Meta:
        model = AuthorBook

    @validates('book')
    def validate_book(self, book):
        if not Book.filter(Book.id == book).exists():
            raise ValidationError("Can't find book")

    @validates('author')
    def validate_author(self, author):
        if not Author.filter(Author.id == author).exists():
            raise ValidationError("Can't find author")
Exemplo n.º 5
0
class ArtifactSchema(ModelSchema):

    task = Related()

    class Meta:
        model = Artifact
        model_converter = ExtendedConverter
    class UserSchema(ModelSchema):

        role = Related(RoleSchema)

        class Meta:
            model = User
            dump_only_pk = False
Exemplo n.º 7
0
class PostSchema(ModelSchema):

    author = Related()

    #tags = fields.Nested(TagSchema, many=True)

    class Meta:
        model = Post
Exemplo n.º 8
0
    class UserSchema(ModelSchema):

        role = Related(unknown=ma.EXCLUDE)

        class Meta:
            model = User
            dump_only_pk = False
            exclude = 'rating',
    class UserSchema(ModelSchema):

        role = Related()

        class Meta:
            model = User
            dump_only_pk = False
            exclude = 'rating',
Exemplo n.º 10
0
class BookSchema(ModelSchema):
    name = fields.Str(validate=[validate.Length(min=3, max=100)])
    ganre_id = Related(nested=GanreSchema)
    autor = Related(nested=AutorSchema)
    year = fields.Int(validate=[validate.Length(min=4, max=4)])
    publisher = fields.Str(validate=[validate.Length(min=3, max=100)])

    class Meta:
        model = Books

    @validates('autor')
    def validate_autor(self, value):
        if not Autors.filter(Autors.id == value).exists():
            raise ValidationError("Can't find author!")

    @validates('ganre_id')
    def validate_ganre(self, value):
        if not Ganre.filter(Ganre.id == value).exists():
            raise ValidationError("Can't find ganre!")
Exemplo n.º 11
0
class ProjectSchema(ModelSchema):
    name = fields.Str(validate=[validate.Length(min=3, max=100)],
                      required=True)
    color = fields.Str(
        validate=[validate.Regexp('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$')],
        required=True)
    user = Related(nested=UserSchema)

    class Meta:
        model = Project
Exemplo n.º 12
0
class BookSchema(ModelSchema):
    name = fields.Str(validate=[validate.Length(min=3, max=100)])
    author = Related(nested=AuthorSchema)

    class Meta:
        model = Book

    @validates('author')
    def validate_author(self, value):
        if not Author.filter(Author.id == value).exists():
            raise ValidationError("Can't find author")
Exemplo n.º 13
0
class TaskSchema(ModelSchema):
    title = fields.Str(validate=[validate.Length(min=3, max=100)],
                       required=True)
    date = fields.Date(required=True)
    priority = fields.Integer(validate=[validate.Regexp('[0-9]+')])
    project = Related(nested=ProjectSchema)

    class Meta:
        model = Task

    @validates('project')
    def validate_project(self, value):
        if not Project.filter(Project.id == value).exists():
            raise ValidationError("Can't find project")
    class RoleSchema(ModelSchema):

        user_set = Related()

        class Meta:
            model = Role
Exemplo n.º 15
0
class CommentVotesSchema(ModelSchema):
    voter = Related()
    comment = Related()

    class Meta:
        model = CommentVotes
Exemplo n.º 16
0
class TaskEventSchema(ModelSchema):

    task = Related()

    class Meta:
        model = TaskEvent
Exemplo n.º 17
0
class LineitemSchema(ModelSchema):
    invoice = Related()
    class Meta:
        model = Lineitem