Add POST /cards/wipe-team
This commit is contained in:
parent
bd4af6e7fa
commit
7bd66b791b
27
main.py
27
main.py
@ -2338,6 +2338,28 @@ async def v1_cards_post_delete(del_ids: str, token: str = Depends(oauth2_scheme)
|
|||||||
logging.info(f'del_ids: {del_ids} / type: {type(del_ids)}')
|
logging.info(f'del_ids: {del_ids} / type: {type(del_ids)}')
|
||||||
# sheets.post_deletion(SHEETS_AUTH, del_ids.split(','))
|
# sheets.post_deletion(SHEETS_AUTH, del_ids.split(','))
|
||||||
|
|
||||||
|
|
||||||
|
@app.post('/api/v1/cards/wipe-team/{team_id}')
|
||||||
|
async def v1_cards_wipe_team(team_id: int, token: str = Depends(oauth2_scheme)):
|
||||||
|
if not valid_token(token):
|
||||||
|
logging.warning(f'Bad Token: {token}')
|
||||||
|
db.close()
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=401,
|
||||||
|
detail='You are not authorized to wipe teams. This event has been logged.'
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
this_team = Team.get_by_id(team_id)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f'/cards/wipe-team/{team_id} - could not find team')
|
||||||
|
raise HTTPException(status_code=404, detail=f'Team {team_id} not found')
|
||||||
|
|
||||||
|
t_query = Card.update(team=None).where(Card.team == this_team).execute()
|
||||||
|
db.close()
|
||||||
|
return f'Wiped {t_query} cards'
|
||||||
|
|
||||||
|
|
||||||
# @app.get('/api/v1/cards/{card_id}/sell')
|
# @app.get('/api/v1/cards/{card_id}/sell')
|
||||||
# async def v1_cards_sell(card_id, ts: int = None):
|
# async def v1_cards_sell(card_id, ts: int = None):
|
||||||
# try:
|
# try:
|
||||||
@ -2405,7 +2427,10 @@ async def v1_cards_patch(
|
|||||||
if player_id is not None:
|
if player_id is not None:
|
||||||
this_card.player_id = player_id
|
this_card.player_id = player_id
|
||||||
if team_id is not None:
|
if team_id is not None:
|
||||||
this_card.team_id = team_id
|
if team_id == 0:
|
||||||
|
this_card.team_id = None
|
||||||
|
else:
|
||||||
|
this_card.team_id = team_id
|
||||||
if pack_id is not None:
|
if pack_id is not None:
|
||||||
this_card.pack_id = pack_id
|
this_card.pack_id = pack_id
|
||||||
if value is not None:
|
if value is not None:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user