Skip to content

Commit

Permalink
donats
Browse files Browse the repository at this point in the history
  • Loading branch information
Furrior committed Feb 10, 2025
1 parent acba5dd commit ae36231
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/routes/v1/donate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ async def get_donations(session: SessionDep,
return paginate_selection(session, selection, request, page, page_size)


@router.post("", status_code=status.HTTP_201_CREATED)
async def create_donation(session: SessionDep, donation: Donation) -> Donation:
async def create_donation_helper(session: SessionDep, donation: Donation) -> Donation:
session.add(donation)
session.commit()
session.refresh(donation)
Expand All @@ -60,8 +59,11 @@ async def create_donation(session: SessionDep, donation: Donation) -> Donation:
}


@router.post("/discord", status_code=status.HTTP_201_CREATED, dependencies=[Depends(verify_bearer)], responses=WHITELIST_POST_RESPONSES)
@router.post("", status_code=status.HTTP_201_CREATED, dependencies=[Depends(verify_bearer)], responses=WHITELIST_POST_RESPONSES)
async def create_donation_by_discord(session: SessionDep, new_donation: NewDonationDiscord) -> Donation:
"""
Creating a new donation from any other identifier doesnt make much sense
"""
player = session.exec(
select(Player).where(Player.discord_id == new_donation.discord_id)
).first()
Expand All @@ -75,4 +77,4 @@ async def create_donation_by_discord(session: SessionDep, new_donation: NewDonat
tier=new_donation.tier
)

return await create_donation(session, donation)
return await create_donation_helper(session, donation)

0 comments on commit ae36231

Please sign in to comment.