Skip to content

Commit

Permalink
Created users.py in pydatalab route to update users
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminCharmes committed Mar 8, 2024
1 parent e0c831d commit ecf6517
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pydatalab/pydatalab/routes/v0_1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .info import ENDPOINTS as info_endpoints
from .items import ENDPOINTS as items_endpoints
from .remotes import remote
from .users import user

ENDPOINTS: Dict[str, Callable] = {
**blocks_endpoints,
Expand All @@ -21,6 +22,6 @@
**info_endpoints,
}

BLUEPRINTS = [collection, remote]
BLUEPRINTS = [collection, remote, user]

__all__ = ("ENDPOINTS", "BLUEPRINTS", "__api_version__")
20 changes: 20 additions & 0 deletions pydatalab/pydatalab/routes/v0_1/users.py
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


0 comments on commit ecf6517

Please sign in to comment.