Exemplo n.º 1
0
class UserFormDtoSerializer(Serializer):

    username = fields.StringField(
        required=True,
        validators=[
            NotEmptyValidator(),
            CharLenValidator(min=settings.rules.user.username_min_char,
                             max=settings.rules.user.username_max_char),
            RegexValidator(pattern=USERNAME_PATTERN)
        ])
    full_name = fields.StringField(
        required=True,
        name='fullName',
        validators=[
            NotEmptyValidator(),
            CharLenValidator(min=settings.rules.user.name_min_char,
                             max=settings.rules.user.name_max_char)
        ])
    email = fields.StringField(required=True, validators=[EmailValidator()])
    password = fields.StringField(
        required=True,
        validators=[
            NotEmptyValidator(),
            CharLenValidator(min=settings.rules.user.password_min_char,
                             max=settings.rules.user.password_max_char)
        ])
    avatar_href = fields.StringField(name='avatarHref')

    class Meta(object):

        model = UserFormDto
Exemplo n.º 2
0
class UserProfileDtoSerializer(Serializer):

    href = fields.StringField(required=True)
    username = fields.StringField(
        required=True,
        validators=[
            NotEmptyValidator(),
            CharLenValidator(min=settings.rules.user.username_min_char,
                             max=settings.rules.user.username_max_char),
            RegexValidator(pattern=USERNAME_PATTERN)
        ])
    full_name = fields.StringField(
        required=True,
        name='fullName',
        validators=[
            NotEmptyValidator(),
            CharLenValidator(min=settings.rules.user.name_min_char,
                             max=settings.rules.user.name_max_char)
        ])
    avatar_href = fields.StringField(name='avatarHref')
    email = fields.StringField(
        required=True, validators=[NotEmptyValidator(),
                                   EmailValidator()])
    posts = fields.ListField(fields.ObjectField(PostDtoSerializer))
    comments = fields.ListField(fields.ObjectField(CommentDtoSerializer))
    liked_posts = fields.ListField(fields.ObjectField(PostDtoSerializer),
                                   name='likedPosts')
    last_posted = fields.DateTimeField(name='lastPosted')
    last_activity = fields.DateTimeField(name='lastActivity')
    register_date = fields.DateTimeField(required=True, name='registerDate')
    links = fields.ListField(fields.ObjectField(LinkDtoSerializer))

    class Meta(object):

        model = UserProfileDto
Exemplo n.º 3
0
class PostFormDtoSerializer(Serializer):

    title = fields.StringField(required=True,
                               validators=[
                                   NotEmptyValidator(),
                                   CharLenValidator(
                                       min=settings.rules.post.title_min_char,
                                       max=settings.rules.post.title_max_char)
                               ])
    description = fields.StringField(
        required=True,
        validators=[
            NotEmptyValidator(),
            CharLenValidator(min=settings.rules.post.title_min_char,
                             max=settings.rules.post.title_max_char)
        ])
    content = fields.StringField(required=True,
                                 validators=[NotEmptyValidator()])
    tags = fields.ListField(fields.StringField())
    private = fields.BooleanField()
    featured = fields.BooleanField()

    class Meta(object):

        model = PostFormDto
Exemplo n.º 4
0
class PostDtoSerializer(Serializer):

    href = fields.StringField()
    author = fields.StringField()
    title = fields.StringField(validators=[
        NotEmptyValidator(),
        CharLenValidator(min=settings.rules.post.title_min_char,
                         max=settings.rules.post.title_max_char)
    ])
    description = fields.StringField(validators=[
        NotEmptyValidator(),
        CharLenValidator(min=settings.rules.post.title_min_char,
                         max=settings.rules.post.title_max_char)
    ])
    content = fields.StringField(validators=[NotEmptyValidator()])
    tags = fields.ListField(
        fields.StringField(validators=[
            NotEmptyValidator(),
            CharLenValidator(min=settings.rules.post.tag_min_char,
                             max=settings.rules.post.tag_max_char)
        ]))
    private = fields.BooleanField()
    featured = fields.BooleanField()
    created = fields.DateTimeField()
    edited = fields.DateTimeField()
    comments = fields.ListField(fields.ObjectField(CommentDtoSerializer))
    likes = fields.IntegerField()
    views = fields.IntegerField()
    links = fields.ListField(fields.ObjectField(LinkDtoSerializer))

    class Meta(object):

        model = PostDto
Exemplo n.º 5
0
class UserUpdateFormDtoSerializer(Serializer):

    full_name = fields.StringField(
        name='fullName',
        validators=[
            CharLenValidator(min=settings.rules.user.name_min_char,
                             max=settings.rules.user.name_max_char)
        ])
    email = fields.StringField(validators=[EmailValidator()])
    password = fields.StringField(validators=[
        CharLenValidator(min=settings.rules.user.password_min_char,
                         max=settings.rules.user.password_max_char)
    ])
    avatar_href = fields.StringField(name='avatarHref')

    class Meta(object):

        model = UserUpdateFormDto
Exemplo n.º 6
0
class CommentFormDtoSerializer(Serializer):

    content = fields.StringField(
        required=True,
        validators=[
            NotEmptyValidator(),
            CharLenValidator(min=settings.rules.comment.content_min_char,
                             max=settings.rules.comment.content_max_char)
        ])

    class Meta(object):

        model = CommentFormDto
Exemplo n.º 7
0
class UserAuthDtoSerializer(Serializer):

    username = fields.StringField(
        required=True,
        validators=[
            NotEmptyValidator(),
            CharLenValidator(min=settings.rules.user.username_min_char,
                             max=settings.rules.user.username_max_char),
            RegexValidator(pattern=USERNAME_PATTERN)
        ])
    password = fields.StringField(required=True)

    class Meta(object):

        model = UserAuthDto
Exemplo n.º 8
0
class CommentDtoSerializer(Serializer):

    href = fields.StringField()
    author = fields.StringField()
    content = fields.StringField(validators=[
        NotEmptyValidator(),
        CharLenValidator(min=settings.rules.comment.content_min_char,
                         max=settings.rules.comment.content_max_char)
    ])
    created = fields.DateTimeField()
    edited = fields.DateTimeField()
    likes = fields.IntegerField()
    links = fields.ListField(fields.ObjectField(LinkDtoSerializer))

    class Meta(object):

        model = CommentDto