def change_username(self,user_id,username): if (UserDAO().username_not_taken(username,user_id)): if (len(username) < 2): return 'must be at least 2 characters' else: return UserDAO().change_username(user_id, username) else: return 'Username has been taken'
def vote_Puzzle_Action(self,vote,user_id,puzzleid,action): hasvoted = UserDAO().has_user_voted(puzzleid,user_id) if hasvoted and action=='remove': UserDAO().delete_vote_user(user_id,puzzleid) return {'votes': GameDAO().get_likes_game(puzzleid)} elif not hasvoted and action=='create': UserDAO().insert_vote_user(vote,user_id,puzzleid) return {'votes': GameDAO().get_likes_game(puzzleid)} else: return {'votes': 'wrong request parameters for Voting in UserService.vote_Puzzle_Action'}
def get_wc_highscores(self, wc_id): userlist = WC_DAO().get_wc_winners() highscores = WC_DAO().get_wc_highscores(wc_id) highscoreslist = list() for score in highscores: if score['logintype'] != 'anon': if userlist.get(score['user_id']) != None: score['wins'] = userlist[score['user_id']] else: score['wins'] = 0 highscoreslist.append({ **score, **UserDAO().get_user_metadata(score['user_id']) }) else: highscoreslist.append({ **score, **UserDAO().get_user_metadata(score['user_id']) }) return highscoreslist
def get_highscores(self, uri, metadata=True): row = GameDAO().get_game_uri(uri) game = Game(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7]) highscores = GameDAO().get_highscores(game.id) if metadata: newhighscores = list() for highscore in highscores: metadata = UserDAO().get_user_metadata(highscore['userid']) newhighscores.append({**highscore, **metadata}) return newhighscores else: return highscores
def get_user(self,userID): return UserDAO().get_user(userID)
def delete_user(self,userID): return UserDAO().delete_user(userID)
def insert_user(self,username,logintype, accountID, profilePicture, email, activeFlag): return UserDAO().insert_user(username,logintype, accountID, profilePicture, email, activeFlag)
def get_user_by_logintype(self,accountID,logintype): return UserDAO().get_user_by_logintype(accountID,logintype)
def change_name(self, user_id, username): return UserDAO().change_username(user_id, username)
def get_user_puzzlerush_view(self,userID): return UserDAO().get_user_puzzlerush_view(userID)
def get_user_solutions_view(self,userID): return UserDAO().get_user_solutions_view(userID)
def get_user_games_view(self,userID): return UserDAO().get_user_games_view(userID)
def change_settings(self,userID, LineDir): return UserDAO().change_settings(userID,LineDir)