Exemple #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
Exemple #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
Exemple #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
Exemple #4
0
class PostSearchSettingsDtoSerializer(Serializer):

    query = fields.StringField(required=True, validators=[NotEmptyValidator()])
    options = fields.ListField(fields.StringField())

    class Meta(object):

        model = PostSearchSettingsDto
Exemple #5
0
class LinkDtoSerializer(Serializer):

    rel = fields.StringField(required=True)
    href = fields.StringField(required=True)
    accepted_methods = fields.ListField(fields.StringField(),
                                        name='acceptedMethods')

    class Meta(object):
        model = LinkDto
Exemple #6
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
Exemple #7
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
Exemple #8
0
class PostViewDtoSerializer(Serializer):

    ip_address = fields.StringField(name='ipAddress', required=True)
    view_time = fields.DateTimeField(name='viewTime', required=True)

    class Meta(object):

        model = PostViewDto
Exemple #9
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
Exemple #10
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
Exemple #11
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
Exemple #12
0
class CategoryDtoSerializer(Serializer):
    links = fields.ListField(fields.ObjectField(LinkDtoSerializer))
    category_id = fields.IntegerField(name='categoryId')
    category_parent_id = fields.IntegerField(name='categoryParentId')
    category_level = fields.IntegerField(name='categoryLevel')
    category_name = fields.StringField(name='categoryName')
    category_updated = fields.IntegerField(name='categoryUpdated')
    best_offer_enabled = fields.BooleanField(name='bestOffersEnabled')
    expired = fields.BooleanField()
    last_updated = fields.IntegerField(name='lastUpdated')

    class Meta(object):
        model = CategoryDto
Exemple #13
0
class TokenDtoSerializer(Serializer):

    token = fields.StringField(required=True)

    class Meta(object):
        model = TokenDto
Exemple #14
0
class LinkDtoSerializer(Serializer):
    href = fields.StringField()
    rel = fields.StringField()

    class Meta(object):
        model = LinkDto