More and more refactors
This commit is contained in:
@@ -2,16 +2,14 @@ from fastapi import HTTPException
|
||||
from passlib.context import CryptContext
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from src.models import User
|
||||
from src.crud.highscores import (get_highest_high_scores,
|
||||
get_most_recent_high_scores)
|
||||
from src.schemas.users import UserCreate
|
||||
from src.enums import CourseEnum, MinigameEnum
|
||||
from src.models import CourseProgress, LearnableProgress
|
||||
from src.schemas.highscores import SavedMinigameProgress
|
||||
from src.models import CourseProgress, LearnableProgress, User
|
||||
from src.schemas.courseprogress import SavedCourseProgress
|
||||
from src.schemas.highscores import SavedMinigameProgress
|
||||
from src.schemas.learnableprogress import SavedLearnableProgress
|
||||
from src.schemas.users import SavedUser
|
||||
from src.schemas.users import SavedUser, UserCreate
|
||||
|
||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||
|
||||
@@ -28,7 +26,7 @@ def check_empty_fields(username: str, password: str, avatar_index: int):
|
||||
|
||||
def patch_user(db: Session, username: str, user: UserCreate):
|
||||
"""Changes the username and/or the password of a User"""
|
||||
#check_empty_fields(user.username, user.password, user.avatar_index)
|
||||
# check_empty_fields(user.username, user.password, user.avatar_index)
|
||||
db_user = get_user_by_username(db, username)
|
||||
potential_duplicate = get_user_by_username(db, user.username)
|
||||
if potential_duplicate:
|
||||
@@ -46,6 +44,8 @@ def patch_user(db: Session, username: str, user: UserCreate):
|
||||
|
||||
if user.avatar_index > -1:
|
||||
db_user.avatar_index = user.avatar_index
|
||||
elif user.avatar_index < -1:
|
||||
raise HTTPException(status_code=400, detail="Invalid avatar index")
|
||||
|
||||
db_user.playtime += user.playtime
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user