update docs and api endpoints

This commit is contained in:
Sam
2019-07-19 12:02:49 +02:00
parent 1247e2253a
commit 715da8fc64
21 changed files with 148 additions and 3 deletions

View File

@ -130,11 +130,12 @@ def get_activities(user_id, filter_type):
@stats_blueprint.route('/stats/<int:user_id>/by_time', methods=['GET'])
@authenticate
def get_activities_by_time(auth_user_id, user_id):
"""Get activities statistics for a user"""
"""Get activities statistics for a user by time"""
return get_activities(user_id, 'by_time')
@stats_blueprint.route('/stats/<int:user_id>/by_sport', methods=['GET'])
@authenticate
def get_activities_by_sport(auth_user_id, user_id):
"""Get activities statistics for a user by sport"""
return get_activities(user_id, 'by_sport')

View File

@ -15,6 +15,7 @@ auth_blueprint = Blueprint('auth', __name__)
@auth_blueprint.route('/auth/register', methods=['POST'])
def register_user():
""" register a user """
# get post data
post_data = request.get_json()
if not post_data or post_data.get('username') is None \
@ -91,6 +92,7 @@ def register_user():
@auth_blueprint.route('/auth/login', methods=['POST'])
def login_user():
""" user login """
# get post data
post_data = request.get_json()
if not post_data:
@ -133,6 +135,7 @@ def login_user():
@auth_blueprint.route('/auth/logout', methods=['GET'])
@authenticate
def logout_user(user_id):
""" user logout """
# get auth token
auth_header = request.headers.get('Authorization')
if auth_header:
@ -161,6 +164,7 @@ def logout_user(user_id):
@auth_blueprint.route('/auth/profile', methods=['GET'])
@authenticate
def get_user_status(user_id):
""" get authenticated user info """
user = User.query.filter_by(id=user_id).first()
response_object = {
'status': 'success',
@ -172,6 +176,7 @@ def get_user_status(user_id):
@auth_blueprint.route('/auth/profile/edit', methods=['POST'])
@authenticate
def edit_user(user_id):
""" edit authenticated user """
# get post data
post_data = request.get_json()
if not post_data:
@ -237,6 +242,7 @@ def edit_user(user_id):
@auth_blueprint.route('/auth/picture', methods=['POST'])
@authenticate
def edit_picture(user_id):
""" update authenticated user picture """
code = 400
response_object = verify_extension('picture', request)
if response_object['status'] != 'success':
@ -287,6 +293,7 @@ def edit_picture(user_id):
@auth_blueprint.route('/auth/picture', methods=['DELETE'])
@authenticate
def del_picture(user_id):
""" delete authenticated user picture """
try:
user = User.query.filter_by(id=user_id).first()
picture_path = get_absolute_file_path(user.picture)

View File

@ -42,6 +42,7 @@ def get_single_user(user_id):
@users_blueprint.route('/users/<user_id>/picture', methods=['GET'])
def get_picture(user_id):
""" get user picture """
response_object = {
'status': 'fail',
'message': 'User does not exist'
@ -59,6 +60,7 @@ def get_picture(user_id):
@users_blueprint.route('/ping', methods=['GET'])
def ping_pong():
""" health check endpoint """
return jsonify({
'status': 'success',
'message': 'pong!'