def get_full_user(blizzard_id: int, token: str): BlizzardUsersUtils.id__safe(token) WAccountUtils.eval_token(token) db = blizzard_db() return DatabaseUtils.core_query( db.query(WAccountModel).filter( WAccountModel.user_id == blizzard_id)).all()
def add_user(body: BlizzardUserCreate): """ Adds the user :param body: :return: """ blizzard_id = BlizzardUsersUtils.id__safe(body.token) WAccountUtils.eval_token(body.token) return BlizzardUsersUtils.add(blizzard_id=blizzard_id, blizzard_name=body.blizzard_name)
def get_user(blizzard_id: int): """ Returns blizzard user utils :param blizzard_id: :return: """ return BlizzardUsersUtils.get(blizzard_id)
async def create_upload_files(token: str, files: List[UploadFile] = File(...), db=Depends(get_db)): blizzard_id = BlizzardUsersUtils.id__safe(token) data = [] for file in files: ext = file.filename.split('.') ext = ext[len(ext) - 1] temp_name = md5(file.filename.encode()).hexdigest() + '.' + ext with open(default_files_path + '/' + temp_name, 'wb') as f: cnt = await file.read() f.write(cnt) db.add( FileModel(user_id=blizzard_id, real_name=file.filename, file_name=temp_name, directory_name='')) data.append({ 'temp_name': temp_name, 'file_path': 'http://server.prestij.xyz/static/files/' + temp_name }) db.commit() return data
def add_player(body: StaticMemberCreate): blizzard_id = BlizzardUsersUtils.id__safe(body.token) db = blizzard_db() q = DatabaseUtils.core_query( db.query(WAccountModel).filter( WAccountModel.user_id == blizzard_id).filter( WAccountModel.wow_id == body.wow_id)) if q.count() < 1: raise HTTPException(404, 'You have not got this player') return StaticUtils.add_player(static_id=body.static_id, wow_id=body.wow_id, role_id=body.role_id, comment=body.request_comment, blizzard_id=blizzard_id)
def add_player(body: AcceptCreate): blizzard_id = BlizzardUsersUtils.id__safe(body.token) db = blizzard_db() qs = DatabaseUtils.core_query(db.query(StaticIndexModel)) \ .filter(StaticIndexModel.owner_blizzard_id == blizzard_id) if qs.count() < 1: raise HTTPException(503, 'You cant accept player to not your static') q = DatabaseUtils.core_query(db.query(StaticMemberModel)) \ .filter(StaticMemberModel.id == body.member_id) if q.count() < 1: raise HTTPException(404, 'You have not got this player') q.update({'request_state': 2}) db.commit() return True
def create_static_(body: StaticIndexCreate): blizzard_id = BlizzardUsersUtils.id__safe(body.token) return StaticUtils.create_static(title=body.title, description=body.description, image=body.image, owner_blizzard_id=blizzard_id)
async def get_files(token: str, db=Depends(get_db)): blizzard_id = BlizzardUsersUtils.id__safe(token) return db.query(FileModel).filter(FileModel.user_id == blizzard_id).all()