Added a service that can get all current tournaments list

This commit is contained in:
Stanislas Jouffroy 2024-03-23 11:56:31 +01:00
parent e6023e0687
commit 3d0bd47079
26 changed files with 4305 additions and 204 deletions

View file

@ -3,7 +3,7 @@ import logging
import config
from gestion_sports_services import GestionSportsServices
from models import Action, BookingFilter, Club, Court, User
from models import Action, BookingFilter, Club, Court, Tournament, User
LOGGER = logging.getLogger(__name__)
@ -51,7 +51,18 @@ async def cancel_booking_id(club: Club, user: User, booking_id: int) -> None:
await service.cancel_booking_id(user, club, booking_id)
def main() -> tuple[Court, User] | None:
async def get_tournaments(club: Club, user: User) -> list[Tournament]:
"""
Cancel a booking that matches the booking id
:param club: the club in which the booking was made
:param user: the user who made the booking
"""
service = GestionSportsServices()
return await service.get_all_tournaments(user, club)
def main() -> tuple[Court, User] | list[Tournament] | None:
"""
Main function used to book a court
@ -80,3 +91,8 @@ def main() -> tuple[Court, User] | None:
club = config.get_club()
booking_filter = config.get_booking_filter()
asyncio.run(cancel_booking(club, user, booking_filter))
elif action == Action.TOURNAMENTS:
user = config.get_user()
club = config.get_club()
return asyncio.run(get_tournaments(club, user))