Exemplo n.º 1
0
 def cancel_match(match_id):
     paid_money = TicketDAO.get_paid_money(match_id)
     for card_id, price in paid_money:
         if card_id is not None:
             FanIDCardDAO.increase_balance(card_id, price)
     TicketDAO.delete_tickets_by_match_id(match_id)
     MatchDAO.delete_match(match_id)
Exemplo n.º 2
0
 def add_match(match):
     new_match_id = MatchDAO.add_match(match)
     match.id = new_match_id
     seats = Seat.get_seats()
     for seat in seats:
         price = 20 * seat.block + 5 * seat.row + 3 * seat.place + 0.99
         ticket = SingleTicket(None, None, price, match, seat)
         TicketDAO.add_ticket(ticket)
Exemplo n.º 3
0
def get_available_seats(match_id):
    result = TicketDAO.get_available_tickets_id_and_seats_and_price(match_id)
    tickets_id_and_seats_and_prices = ""
    for row in result:
        tickets_id_and_seats_and_prices += str(row[0]) + ": " + str(
            Seat(row[1], row[2], row[3])) + ". Price: ${}\n".format(row[4])
    return tickets_id_and_seats_and_prices
Exemplo n.º 4
0
def get_tickets():
    card_id = user.person.fan_id_card
    result = TicketDAO.get_tickets_id_by_card_id(card_id.id)
    tickets = ""
    for row in result:
        ticket_id = row[0]
        tickets += str(SingleTicket.construct(ticket_id)) + "\n\n"
    return tickets
Exemplo n.º 5
0
def choose_seat(message):
    try:
        ticket_id = int(message.text)
        if not TicketDAO.does_exist(ticket_id):
            send(message,
                 "The entered ID does not exist. Please enter the ID again",
                 choose_seat)
            return
        ticket = SingleTicket.construct(ticket_id)
        user.person.buy_ticket(ticket)
        send(
            message,
            "The seat and ticket were successfully reserved. Balance: ${}".
            format(round(user.person.fan_id_card.balance, 2)))
    except ValueError:
        send(
            message,
            "You should enter an ID for choosing a seat. Please enter the ID again",
            choose_seat)
    except NotEnoughMoneyError as error:
        send(message, str(error) + ". Please enter another seat", choose_seat)
Exemplo n.º 6
0
 def delete_match(match_id):
     TicketDAO.delete_tickets_by_match_id(match_id)
     MatchDAO.delete_match(match_id)
Exemplo n.º 7
0
 def return_ticket(self, ticket):
     TicketDAO.return_ticket(ticket.id)
     refund_price = FanIDCard.calculate_refund_price(ticket.price)
     FanIDCardDAO.increase_balance(self.id, refund_price)
     self.balance += refund_price
Exemplo n.º 8
0
 def reserve_ticket(self, ticket):
     if self.balance < ticket.price:
         raise NotEnoughMoneyError("Not enough money to pay for the ticket")
     TicketDAO.reserve_ticket(ticket.id, self.id)
     FanIDCardDAO.reduce_balance(self.id, ticket.price)
     self.balance -= ticket.price