diff --git a/backend/clubs/management/commands/populate.py b/backend/clubs/management/commands/populate.py index 0ea8e7d63..5de5d06c5 100644 --- a/backend/clubs/management/commands/populate.py +++ b/backend/clubs/management/commands/populate.py @@ -15,6 +15,7 @@ ApplicationQuestion, ApplicationSubmission, Badge, + Cart, Club, ClubApplication, ClubFair, @@ -28,6 +29,7 @@ StudentType, Tag, Testimonial, + Ticket, Year, ) @@ -662,7 +664,10 @@ def get_image(url): status_counter % len(ApplicationSubmission.STATUS_TYPES) ][0] ApplicationSubmission.objects.create( - status=status, user=user, application=application, committee=None, + status=status, + user=user, + application=application, + committee=None, ) status_counter += 1 for committee in application.committees.all(): @@ -746,4 +751,31 @@ def get_image(url): first_mship.save() count += 1 + # add tickets + + hr = Club.objects.get(code="harvard-rejects") + + hr_events = Event.objects.filter(club=hr) + + for idx, e in enumerate(hr_events[:3]): + # Switch up person every so often + person = ben if idx < 2 else user_objs[1] + + # Create some unowned tickets + Ticket.objects.bulk_create( + [Ticket(event=e, type="Regular") for _ in range(10)] + ) + + Ticket.objects.bulk_create( + [Ticket(event=e, type="Premium") for _ in range(5)] + ) + + # Create some owned tickets and tickets in cart + for i in range((idx + 1) * 10): + if i % 5: + Ticket.objects.create(event=e, owner=person, type="Regular") + else: + c, _ = Cart.objects.get_or_create(owner=person) + c.tickets.add(Ticket.objects.create(event=e, type="Premium")) + self.stdout.write("Finished populating database!") diff --git a/backend/clubs/views.py b/backend/clubs/views.py index 694e8dab2..d970c062f 100644 --- a/backend/clubs/views.py +++ b/backend/clubs/views.py @@ -2436,6 +2436,8 @@ def tickets(self, request, *args, **kwargs): @transaction.atomic def create_tickets(self, request, *args, **kwargs): """ + Create ticket offerings for event + --- requestBody: content: application/json: @@ -2456,12 +2458,13 @@ def create_tickets(self, request, *args, **kwargs): content: application/json: schema: - type: object properties: detail: type: string + --- """ event = self.get_object() + quantities = request.data.get("quantities") # Atomicity ensures idempotency