예제 #1
0
 def get_tickets_for_user(self, user):
     try:
         return Ticket.objects.all().filter(
             customer_id=user,
             credit_card_id__isnull=False).order_by("concert_id__date_time")
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in ticket_repo")
예제 #2
0
 def create_concert(self, concert_data):
     try:
         concert = Concert(concert_id=concert_data["concert_id"],
                           concert_name=concert_data["concert_name"],
                           venue_id=concert_data["venue_id"],
                           artist_id=concert_data["artist_id"],
                           date_time=concert_data["date_time"])
         concert.save()
         return concert
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in concert_repo")
예제 #3
0
 def create_ticket_no_save(self, ticket_id, concert, price, seat_col,
                           seat_row):
     try:
         return Ticket(ticket_id=ticket_id,
                       concert_id=concert,
                       customer_id=None,
                       price=price,
                       seat_col=seat_col,
                       seat_row=seat_row)
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in ticket_repo")
예제 #4
0
 def get_seat_rank_price(self, venue_id, col, row):
     try:
         seat_rank = SeatRank.objects.filter(venue_id=venue_id,
                                             row=row,
                                             col=col).first()
         if seat_rank:
             return seat_rank.price
         else:
             return None
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in seat_rank_repo")
예제 #5
0
 def create_credit_card(self, credit_card):
     try:
         credit_card = CreditCard(
             credit_card_id=uuid.uuid4(),
             credit_card_number=credit_card["credit_card_number"],
             security_code=credit_card["security_code"],
             expiration_date=credit_card["expiration_date"],
             card_nickname=credit_card["card_nickname"],
             customer_id=credit_card["customer_id"])
         credit_card.save()
         return credit_card
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in credit_card_repo")
예제 #6
0
    def create_customer(self, customer_data):
        try:
            user = User.objects.create_user(username=customer_data["username"],password=customer_data["password"])

            user.save()

            role_num = Role.objects.get(role_num=customer_data["role_num"])
            cust_user = CustomUser(role_num=role_num, user=user)
            cust_user.save()

            return cust_user
        except Exception as e:
            raise DatabaseError(e.__class__.__name__ + ": in customer_repo")
예제 #7
0
    def create_artist(self, artist_data):
        try:
            user = User.objects.create_user(username=artist_data["username"],
                                            password=artist_data["password"])
            user.save()

            role_num = Role.objects.get(role_num=artist_data["role_num"])
            cust_user = CustomUser(role_num=role_num, user=user)
            cust_user.save()

            artist = Artist(artist_id=cust_user,
                            genre=artist_data["genre"],
                            band_name=artist_data["band_name"])
            artist.save()
            return artist
        except Exception as e:
            raise DatabaseError(e.__class__.__name__ + ": in artist_repo")
예제 #8
0
    def create_venue(self, venue_data):
        try:
            user = User.objects.create_user(username=venue_data["username"],
                                            password=venue_data["password"])
            user.save()

            role_num = Role.objects.get(role_num=venue_data["role_num"])
            cust_user = CustomUser(role_num=role_num, user=user)
            cust_user.save()

            venue = Venue(venue_name=venue_data["venue_name"],
                          address=venue_data["address"],
                          seat_rows=venue_data["seat_rows"],
                          seat_cols=venue_data["seat_cols"],
                          location=venue_data["location"],
                          venue_id=cust_user)
            venue.save()
            return venue
        except Exception as e:
            raise DatabaseError(e.__class__.__name__ + ": in venue_repo")
예제 #9
0
    def find_concerts(self, request_params):
        try:
            concerts = {"date_time__gte": request_params["start_date"]}

            for k, v in request_params.items():
                # if k == "genre":
                #     concerts["artist_id__genre__contains"] = v
                # elif k == ""
                if k == "start_date":
                    continue
                elif v[0] == "":
                    continue
                elif k == "end_date":
                    concerts["date_time__lte"] = v[0]
                else:
                    concerts[k + "__icontains"] = v[0]
            return Concert.objects.filter(**concerts).order_by(
                "date_time", "concert_name")
        except Exception as e:
            raise DatabaseError(e.__class__.__name__ + ": in concert_repo")
예제 #10
0
 def get_credit_card_by_credit_id(self, credit_id):
     try:
         credit_card = CreditCard.objects.get(credit_card_id=credit_id)
         return credit_card
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in credit_card_repo")
예제 #11
0
 def get_tickets_by_concert_id(self, concert_id):
     try:
         return Ticket.objects.all().filter(concert_id=concert_id).order_by(
             "seat_row", "seat_col")
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in ticket_repo")
예제 #12
0
 def save(self, ticket):
     try:
         ticket.save()
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in ticket_repo")
예제 #13
0
 def bulk_insert_tickets(self, tickets):
     try:
         Ticket.objects.bulk_create(tickets)
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in ticket_repo")
예제 #14
0
 def get_ticket_by_id(self, ticket_id):
     try:
         ticket = Ticket.objects.get(ticket_id=ticket_id)
         return ticket
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in ticket_repo")
예제 #15
0
 def get_artist_by_id(self, artist_id):
     try:
         artist = Artist.objects.get(artist_id=artist_id)
         return artist
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in artist_repo")
예제 #16
0
 def get_venue_by_id(self, venue_id):
     try:
         venue = Venue.objects.get(venue_id=venue_id)
         return venue
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in venue_repo")
예제 #17
0
 def get_concerts_by_venue(self, venue):
     try:
         return Concert.objects.filter(venue_id=venue).order_by("date_time")
     except Exception as e:
         raise DatabaseError(e.__class__.__name__ + ": in concert_repo")