feature/balance #13

Merged
ferfissimo merged 4 commits from feature/balance into develop 2021-08-09 10:06:54 +00:00
1 changed files with 18 additions and 0 deletions
Showing only changes of commit 471bfd534d - Show all commits

View File

@ -231,3 +231,21 @@ def notifications(current_session):
def remove_notifications(nid, current_session):
userController.delete_notification(nid, current_session.user_)
return no_content()
@UsersPlugin.blueprint.route("/users/<userid>/shortcuts", methods=["GET", "PUT"])
@login_required()
def shortcuts(userid, current_session):
if userid != current_session.user_.userid:
raise Forbidden
user = userController.get_user(userid)
if request.method == "GET":
return jsonify(user.get_attribute("users_link_shortcuts", []))
else:
data = request.get_json()
if not isinstance(data, list) or not all(isinstance(n, dict) for n in data):
raise BadRequest
user.set_attribute("users_link_shortcuts", data)
userController.persist()
return no_content()