-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created users.py in pydatalab route to update users
- Loading branch information
1 parent
e0c831d
commit ecf6517
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from flask import Blueprint, jsonify, request | ||
from flask_login import current_user | ||
from bson import ObjectId | ||
|
||
from pydatalab.mongo import flask_mongo | ||
|
||
user = Blueprint("users", __name__) | ||
|
||
|
||
@user.route('/users/<user_id>', methods=['PATCH']) | ||
def save_user(user_id): | ||
|
||
user_name = request.json.get('data', {}).get('user_name') | ||
|
||
user_id_object = ObjectId(user_id) | ||
flask_mongo.db.users.update_one({"_id": user_id_object}, {'$set': {'display_name': user_name}}) | ||
|
||
return jsonify(status="success"), 200 | ||
|
||
|