API - move set-admin
command in users blueprint
This commit is contained in:
@ -2,6 +2,7 @@ import os
|
||||
import shutil
|
||||
from typing import Any, Dict, Tuple, Union
|
||||
|
||||
import click
|
||||
from flask import Blueprint, request, send_file
|
||||
from sqlalchemy import exc
|
||||
|
||||
@ -18,13 +19,26 @@ from fittrackee.workouts.models import Record, Workout, WorkoutSegment
|
||||
from fittrackee.workouts.utils_files import get_absolute_file_path
|
||||
|
||||
from .decorators import authenticate, authenticate_as_admin
|
||||
from .exceptions import UserNotFoundException
|
||||
from .models import User, UserSportPreference
|
||||
from .utils import set_admin_rights
|
||||
|
||||
users_blueprint = Blueprint('users', __name__)
|
||||
|
||||
USER_PER_PAGE = 10
|
||||
|
||||
|
||||
@users_blueprint.cli.command('set-admin')
|
||||
@click.argument('username')
|
||||
def set_admin(username: str) -> None:
|
||||
"""Set admin rights for given user"""
|
||||
try:
|
||||
set_admin_rights(username)
|
||||
print(f"User '{username}' updated.")
|
||||
except UserNotFoundException:
|
||||
print(f"User '{username}' not found.")
|
||||
|
||||
|
||||
@users_blueprint.route('/users', methods=['GET'])
|
||||
@authenticate
|
||||
def get_users(auth_user: User) -> Dict:
|
||||
|
Reference in New Issue
Block a user