[System] Added util for 201&204 HTTP response and some code formatting

This commit is contained in:
Ferdinand Thiessen 2020-11-12 00:12:52 +01:00
parent 7074c29d63
commit 53c39f4f92
3 changed files with 14 additions and 5 deletions

View File

@ -27,9 +27,7 @@ class Role(db.Model, ModelSerializeMixin):
__tablename__ = "role"
id: int = db.Column(db.Integer, primary_key=True)
name: str = db.Column(db.String(30), unique=True)
permissions: [Permission] = db.relationship(
"Permission", secondary=role_permission_association_table
)
permissions: [Permission] = db.relationship("Permission", secondary=role_permission_association_table)
class User(db.Model, ModelSerializeMixin):

View File

@ -87,8 +87,8 @@ def get_user(userid, current_session):
logger.debug("Get information of user {{ {} }}".format(userid))
user: User = userController.get_user(userid)
serial = user.serialize()
if (userid == current_session._user.userid):
serial['permissions'] = user.get_permissions()
if userid == current_session._user.userid:
serial["permissions"] = user.get_permissions()
return jsonify(serial)

View File

@ -0,0 +1,11 @@
from http.client import NO_CONTENT, CREATED
from flask import make_response, jsonify
def no_content():
return make_response(jsonify(""), NO_CONTENT)
def created(obj=None):
return make_response(jsonify(obj if obj is not None else ""), CREATED)