class VerificationSchema(ma.SQLAlchemyAutoSchema): class Meta: model = Verification include_fk = True status = EnumField(Status) value = EnumField(Value) pub_date = ma.DateTime(format='%d/%m\n%H:%M') results = ma.List(ma.HyperlinkRelated("api.results_result_by_id")) model = ma.HyperlinkRelated("api.models_model_by_id")
class AdminEventSchema(ma.Schema): class Meta: fields = ( 'start_at', 'name', 'id', 'teacher', ) start_at = ma.DateTime() teacher = ma.Nested(AdminEventTeacher)
class UserSchema(ma.Schema): id = ma.Integer() username = ma.String(required=True) email = ma.Email(required=True) password = ma.String(required=True) profile_pic = ma.String() bio = ma.String() location = ma.String() website = ma.Url() is_active = ma.Boolean() is_admin = ma.Boolean() joined_date = ma.DateTime()
class NotificationSchema(ma.Schema): id = ma.Integer() body = ma.String(required=True) created_by = ma.Integer(required=True) target_user = ma.Integer(required=True) notification_date = ma.DateTime() @validates('body') def validate_body(self, body): if len(body) <= 0: raise ValidationError("This field can't be empty.") elif len(body) > 255: raise ValidationError('max character of 255 characters exceeded.')
class PostSchema(ma.Schema): id = ma.Integer() body = ma.String(required=True) created_by = ma.Integer() no_likes = ma.Integer() no_comments = ma.Integer() posted_date = ma.DateTime() liked = ma.Boolean() @validates('body') def validate_body(self, body): if len(body) <= 0: raise ValidationError("This field can't be empty.") elif len(body) > 255: raise ValidationError('max character of 255 characters exceeded.')
class CommentSchema(ma.Schema): id = ma.Integer() body = ma.String(required=True) post_id = ma.Integer() commented_by = ma.Integer(required=True) comment_date = ma.DateTime()