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
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
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
class PostSearchSettingsDtoSerializer(Serializer): query = fields.StringField(required=True, validators=[NotEmptyValidator()]) options = fields.ListField(fields.StringField()) class Meta(object): model = PostSearchSettingsDto
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
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
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
class PostViewDtoSerializer(Serializer): ip_address = fields.StringField(name='ipAddress', required=True) view_time = fields.DateTimeField(name='viewTime', required=True) class Meta(object): model = PostViewDto
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
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
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
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
class TokenDtoSerializer(Serializer): token = fields.StringField(required=True) class Meta(object): model = TokenDto
class LinkDtoSerializer(Serializer): href = fields.StringField() rel = fields.StringField() class Meta(object): model = LinkDto