2016-09-30 10:46:05 +00:00
|
|
|
from collections import namedtuple
|
|
|
|
from datetime import timedelta
|
|
|
|
from decimal import Decimal
|
2019-09-22 03:38:33 +00:00
|
|
|
from django.conf import settings
|
2016-09-30 10:46:05 +00:00
|
|
|
from django.contrib.auth.models import Group
|
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
2017-03-05 07:34:15 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
2016-09-30 10:46:05 +00:00
|
|
|
|
|
|
|
from registrasion.models import inventory as inv
|
|
|
|
from registrasion.models import conditions as cond
|
|
|
|
from symposion import proposals
|
|
|
|
|
2017-03-05 07:34:15 +00:00
|
|
|
|
2016-09-30 10:46:05 +00:00
|
|
|
class Command(BaseCommand):
|
2019-09-22 03:38:33 +00:00
|
|
|
help = 'Populates the tickets and product inventory models'
|
2019-09-24 08:36:40 +00:00
|
|
|
count = 0
|
2016-09-30 10:46:05 +00:00
|
|
|
|
|
|
|
def add_arguments(self, parser):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
|
|
|
|
kinds = []
|
2020-10-05 12:13:28 +00:00
|
|
|
for i in settings.MAIN_CONFERENCE_PROPOSAL_KINDS:
|
2016-09-30 10:46:05 +00:00
|
|
|
kinds.append(proposals.models.ProposalKind.objects.get(name=i))
|
|
|
|
self.main_conference_proposals = kinds
|
|
|
|
|
|
|
|
self.populate_groups()
|
|
|
|
self.populate_inventory()
|
|
|
|
self.populate_restrictions()
|
|
|
|
self.populate_discounts()
|
|
|
|
|
|
|
|
def populate_groups(self):
|
|
|
|
self.group_team = self.find_or_make(
|
|
|
|
Group,
|
|
|
|
("name", ),
|
|
|
|
name="Conference organisers",
|
|
|
|
)
|
|
|
|
self.group_volunteers = self.find_or_make(
|
|
|
|
Group,
|
|
|
|
("name", ),
|
|
|
|
name="Conference volunteers",
|
|
|
|
)
|
|
|
|
self.group_unpublish = self.find_or_make(
|
|
|
|
Group,
|
|
|
|
("name", ),
|
|
|
|
name="Can see unpublished products",
|
|
|
|
)
|
2017-09-24 02:30:35 +00:00
|
|
|
self.group_prepurchase = self.find_or_make(
|
|
|
|
Group,
|
|
|
|
("name", ),
|
|
|
|
name="Pre-purchase",
|
|
|
|
)
|
2016-09-30 10:46:05 +00:00
|
|
|
|
|
|
|
def populate_inventory(self):
|
|
|
|
# Categories
|
|
|
|
|
|
|
|
self.ticket = self.find_or_make(
|
|
|
|
inv.Category,
|
|
|
|
("name",),
|
|
|
|
name="Ticket",
|
|
|
|
description="Each type of ticket has different included products. "
|
|
|
|
"For details of what products are included, see our "
|
2019-10-13 11:31:27 +00:00
|
|
|
"<a href=\"/attend/tickets/\">registration page</a>.",
|
2017-03-05 07:34:15 +00:00
|
|
|
required=True,
|
2016-09-30 10:46:05 +00:00
|
|
|
render_type=inv.Category.RENDER_TYPE_RADIO,
|
|
|
|
limit_per_user=1,
|
|
|
|
order=1,
|
|
|
|
)
|
2017-10-01 08:14:37 +00:00
|
|
|
self.terms = self.find_or_make(
|
|
|
|
inv.Category,
|
|
|
|
("name",),
|
|
|
|
name="Terms, Conditions, and Code of Conduct Acceptance",
|
|
|
|
description="I agree to the "
|
2019-10-13 11:31:27 +00:00
|
|
|
"<a href=\"/attend/terms-and-conditions/\"> "
|
2017-10-01 08:14:37 +00:00
|
|
|
"terms and conditions of attendance</a>, and I have read, "
|
|
|
|
"understood, and agree to act according to the standards set "
|
2019-10-13 11:31:27 +00:00
|
|
|
"forth in our <a href=\"/attend/code-of-conduct/\">"
|
2017-10-01 08:14:37 +00:00
|
|
|
"Code of Conduct</a>.",
|
|
|
|
required=True,
|
|
|
|
render_type=inv.Category.RENDER_TYPE_CHECKBOX,
|
|
|
|
order=10,
|
|
|
|
)
|
2016-09-30 10:46:05 +00:00
|
|
|
self.penguin_dinner = self.find_or_make(
|
|
|
|
inv.Category,
|
|
|
|
("name",),
|
|
|
|
name="Penguin Dinner Ticket",
|
|
|
|
description="Tickets to our conference dinner on the evening of "
|
2019-09-22 03:38:33 +00:00
|
|
|
f"{settings.PENGUIN_DINNER_TICKET_DATE: %A %d %B}. "
|
|
|
|
"All attendees may purchase "
|
2016-09-30 10:46:05 +00:00
|
|
|
"seats at the dinner, even if a dinner ticket is not "
|
|
|
|
"included in your conference ticket price.",
|
2017-03-05 07:34:15 +00:00
|
|
|
required=False,
|
2016-09-30 10:46:05 +00:00
|
|
|
render_type=inv.Category.RENDER_TYPE_QUANTITY,
|
|
|
|
limit_per_user=10,
|
2017-10-01 08:14:37 +00:00
|
|
|
order=20,
|
2016-09-30 10:46:05 +00:00
|
|
|
)
|
|
|
|
self.speakers_dinner_ticket = self.find_or_make(
|
|
|
|
inv.Category,
|
|
|
|
("name",),
|
|
|
|
name="Speakers' Dinner Ticket",
|
|
|
|
description="Tickets to our exclusive Speakers' Dinner on the "
|
2019-09-22 03:38:33 +00:00
|
|
|
"evening of "
|
2019-10-02 13:25:17 +00:00
|
|
|
f"{settings.SPEAKER_DINNER_TICKET_DATE: %A %d %B}.",
|
2017-03-05 07:34:15 +00:00
|
|
|
required=False,
|
2016-09-30 10:46:05 +00:00
|
|
|
render_type=inv.Category.RENDER_TYPE_QUANTITY,
|
2019-10-02 13:25:17 +00:00
|
|
|
limit_per_user=1,
|
2017-10-01 08:14:37 +00:00
|
|
|
order=30,
|
2016-09-30 10:46:05 +00:00
|
|
|
)
|
2017-09-24 02:30:35 +00:00
|
|
|
self.pdns_category = self.find_or_make(
|
2016-09-30 10:46:05 +00:00
|
|
|
inv.Category,
|
|
|
|
("name",),
|
2017-09-24 02:30:35 +00:00
|
|
|
name="Professional Delegates Networking Session Ticket",
|
2019-09-22 03:38:33 +00:00
|
|
|
description="Tickets to our Professional Delegates Networking session. "
|
|
|
|
"This event will be held on the evening of "
|
|
|
|
f"{settings.PDNS_TICKET_DATE: %A %d %B} "
|
|
|
|
"and is restricted to Professional Ticket "
|
2016-09-30 10:46:05 +00:00
|
|
|
"holders, speakers, miniconf organisers, and invited "
|
|
|
|
"guests.",
|
2017-03-05 07:34:15 +00:00
|
|
|
required=False,
|
2016-09-30 10:46:05 +00:00
|
|
|
render_type=inv.Category.RENDER_TYPE_RADIO,
|
|
|
|
limit_per_user=1,
|
2017-10-01 08:14:37 +00:00
|
|
|
order=40,
|
2016-09-30 10:46:05 +00:00
|
|
|
)
|
|
|
|
self.t_shirt = self.find_or_make(
|
|
|
|
inv.Category,
|
|
|
|
("name",),
|
2017-09-30 13:40:46 +00:00
|
|
|
name="Shirt",
|
2019-10-02 13:25:17 +00:00
|
|
|
description="Commemorative conference shirts, featuring the "
|
|
|
|
f"linux.conf.au {settings.LCA_START.year} artwork. "
|
2019-10-13 11:31:27 +00:00
|
|
|
"View the <a href=\"/attend/shirts/\">"
|
2019-10-02 13:25:17 +00:00
|
|
|
"sizing guide</a>.",
|
2017-03-05 07:34:15 +00:00
|
|
|
required=False,
|
2016-09-30 10:46:05 +00:00
|
|
|
render_type=inv.Category.RENDER_TYPE_ITEM_QUANTITY,
|
2017-10-01 08:14:37 +00:00
|
|
|
order=50,
|
2016-09-30 10:46:05 +00:00
|
|
|
)
|
2017-09-24 02:30:35 +00:00
|
|
|
# self.accommodation = self.find_or_make(
|
|
|
|
# inv.Category,
|
|
|
|
# ("name",),
|
|
|
|
# name="Accommodation at University of Tasmania",
|
|
|
|
# description="Accommodation at the University of Tasmania colleges "
|
|
|
|
# "and apartments. You can come back and book your "
|
|
|
|
# "accommodation at a later date, provided rooms remain "
|
|
|
|
# "available. Rooms may only be booked from Sunday 15 "
|
|
|
|
# "January--Saturday 21 January. If you wish to stay "
|
|
|
|
# "for only a part of the 6-day period, you must book "
|
|
|
|
# "accommodation for the full 6-day period. Rooms at "
|
|
|
|
# "other hotels, including Wrest Point can be booked "
|
|
|
|
# "elsewhere. For full details, see [LINK]our "
|
|
|
|
# "accommodation page.[/LINK]",
|
|
|
|
# required=False,
|
|
|
|
# render_type=inv.Category.RENDER_TYPE_RADIO,
|
|
|
|
# limit_per_user=1,
|
|
|
|
# order=50,
|
|
|
|
# )
|
2016-09-30 10:46:05 +00:00
|
|
|
self.extras = self.find_or_make(
|
|
|
|
inv.Category,
|
|
|
|
("name",),
|
|
|
|
name="Extras",
|
|
|
|
description="Other items that can improve your conference "
|
|
|
|
"experience.",
|
2017-03-05 07:34:15 +00:00
|
|
|
required=False,
|
2016-09-30 10:46:05 +00:00
|
|
|
render_type=inv.Category.RENDER_TYPE_QUANTITY,
|
|
|
|
order=60,
|
|
|
|
)
|
|
|
|
|
|
|
|
# Tickets
|
|
|
|
|
2019-09-22 04:07:11 +00:00
|
|
|
self.ticket_contributor = self.find_or_make(
|
2016-09-30 10:46:05 +00:00
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.ticket,
|
2019-09-22 05:11:55 +00:00
|
|
|
name=settings.CONTRIBUTOR.name,
|
|
|
|
price=settings.CONTRIBUTOR.regular_price,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=1,
|
|
|
|
)
|
|
|
|
self.ticket_professional = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.ticket,
|
2019-09-22 05:11:55 +00:00
|
|
|
name=settings.PROFESSIONAL.name,
|
|
|
|
price=settings.PROFESSIONAL.regular_price,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=10,
|
|
|
|
)
|
|
|
|
self.ticket_hobbyist = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.ticket,
|
2019-09-22 05:11:55 +00:00
|
|
|
name=settings.HOBBYIST.name,
|
|
|
|
price=settings.HOBBYIST.regular_price,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=20,
|
|
|
|
)
|
|
|
|
self.ticket_student = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.ticket,
|
2019-09-22 05:11:55 +00:00
|
|
|
name=settings.STUDENT.name,
|
|
|
|
price=settings.STUDENT.regular_price,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=30,
|
|
|
|
)
|
|
|
|
self.ticket_miniconfs_mt = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.ticket,
|
2019-09-22 05:11:55 +00:00
|
|
|
name=settings.MINICONF_MT.name,
|
|
|
|
price=settings.MINICONF_MT.regular_price,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=40,
|
|
|
|
)
|
|
|
|
self.ticket_miniconfs_mon = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.ticket,
|
2019-09-22 05:11:55 +00:00
|
|
|
name=settings.MINICONF_M.name,
|
|
|
|
price=settings.MINICONF_M.regular_price,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=42,
|
|
|
|
)
|
|
|
|
self.ticket_miniconfs_tue = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.ticket,
|
2019-09-22 05:11:55 +00:00
|
|
|
name=settings.MINICONF_MT.name,
|
|
|
|
price=settings.MINICONF_MT.regular_price,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=44,
|
|
|
|
)
|
|
|
|
self.ticket_speaker = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.ticket,
|
2019-09-22 05:11:55 +00:00
|
|
|
name=settings.SPEAKER.name,
|
|
|
|
price=settings.SPEAKER.regular_price,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=50,
|
|
|
|
)
|
|
|
|
self.ticket_media = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.ticket,
|
2019-09-22 05:11:55 +00:00
|
|
|
name=settings.MEDIA.name,
|
|
|
|
price=settings.MEDIA.regular_price,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=60,
|
|
|
|
)
|
|
|
|
self.ticket_sponsor = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.ticket,
|
2019-09-22 05:11:55 +00:00
|
|
|
name=settings.SPONSOR.name,
|
|
|
|
price=settings.SPONSOR.regular_price,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=70,
|
|
|
|
)
|
|
|
|
self.ticket_team = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.ticket,
|
2019-09-22 05:11:55 +00:00
|
|
|
name=settings.CONFERENCE_ORG.name,
|
|
|
|
price=settings.CONFERENCE_ORG.regular_price,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=80,
|
|
|
|
)
|
|
|
|
self.ticket_volunteer = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.ticket,
|
2019-09-22 05:11:55 +00:00
|
|
|
name=settings.CONFERENCE_VOL.name,
|
|
|
|
price=settings.CONFERENCE_VOL.regular_price,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=90,
|
|
|
|
)
|
|
|
|
|
2017-10-01 08:14:37 +00:00
|
|
|
# Agreements
|
|
|
|
self.accept_terms = self.find_or_make(
|
|
|
|
inv.Product,
|
2019-09-22 03:41:57 +00:00
|
|
|
("name", "category",),
|
|
|
|
category=self.terms,
|
2017-10-01 08:14:37 +00:00
|
|
|
name="I Accept",
|
|
|
|
price=Decimal("00.00"),
|
|
|
|
reservation_duration=hours(24),
|
|
|
|
order=10,
|
|
|
|
limit_per_user=1,
|
|
|
|
)
|
2016-09-30 10:46:05 +00:00
|
|
|
|
2019-09-24 08:36:40 +00:00
|
|
|
for t in settings.PENGUIN_DINNER.tickets:
|
|
|
|
self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.penguin_dinner,
|
|
|
|
name=t.name,
|
|
|
|
description=t.description,
|
|
|
|
price=t.price,
|
|
|
|
reservation_duration=t.reservation,
|
|
|
|
order=t.order()
|
|
|
|
)
|
2016-09-30 10:46:05 +00:00
|
|
|
|
2019-09-24 08:36:40 +00:00
|
|
|
for t in settings.SPEAKERS_DINNER.tickets:
|
|
|
|
self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.speakers_dinner_ticket,
|
|
|
|
name=t.name,
|
|
|
|
description=t.description,
|
|
|
|
price=t.price,
|
|
|
|
reservation_duration=t.reservation,
|
|
|
|
order=t.order()
|
|
|
|
)
|
2016-09-30 10:46:05 +00:00
|
|
|
|
2017-09-24 02:30:35 +00:00
|
|
|
# PDNS
|
2016-09-30 10:46:05 +00:00
|
|
|
|
|
|
|
self.pdns = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
2017-09-24 02:30:35 +00:00
|
|
|
category=self.pdns_category,
|
2016-09-30 10:46:05 +00:00
|
|
|
name="Conference Attendee",
|
|
|
|
price=Decimal("00.00"),
|
|
|
|
reservation_duration=hours(1),
|
|
|
|
limit_per_user=1,
|
|
|
|
order=10,
|
|
|
|
)
|
|
|
|
|
2017-09-24 02:30:35 +00:00
|
|
|
# # Accommodation
|
2016-09-30 10:46:05 +00:00
|
|
|
|
2017-09-24 02:30:35 +00:00
|
|
|
# self.accommodation_week = self.find_or_make(
|
|
|
|
# inv.Product,
|
|
|
|
# ("name", "category",),
|
|
|
|
# category=self.accommodation,
|
|
|
|
# name="Single Bedroom with Shared Bathrooms, includes full "
|
|
|
|
# "breakfast, Sunday 15 January 2017--Saturday 21 January 2017",
|
|
|
|
# price=Decimal("396.00"),
|
|
|
|
# reservation_duration=hours(24),
|
|
|
|
# limit_per_user=1,
|
|
|
|
# order=10,
|
|
|
|
# )
|
2016-09-30 10:46:05 +00:00
|
|
|
|
|
|
|
# Extras
|
|
|
|
|
|
|
|
self.carbon_offset = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
category=self.extras,
|
2017-09-30 13:40:16 +00:00
|
|
|
name="Offset the carbon pollution generated by your attendance, "
|
2016-09-30 10:46:05 +00:00
|
|
|
"thanks to fifteen trees.",
|
|
|
|
price=Decimal("5.00"),
|
|
|
|
reservation_duration=hours(1),
|
|
|
|
order=10,
|
|
|
|
)
|
|
|
|
|
|
|
|
# Shirts
|
|
|
|
ShirtGroup = namedtuple("ShirtGroup", ("prefix", "sizes"))
|
|
|
|
shirt_names = {
|
2019-10-02 13:25:17 +00:00
|
|
|
"straight": ShirtGroup(
|
|
|
|
"Straight Cut",
|
|
|
|
("S", "M", "L", "XL", "2XL", "3XL", "4XL", "5XL"),
|
|
|
|
),
|
|
|
|
"semi_fitted": ShirtGroup(
|
|
|
|
"Semi-Fitted",
|
|
|
|
("XS", "S", "M", "L", "XL", "2XL"),
|
2016-09-30 10:46:05 +00:00
|
|
|
),
|
2019-10-02 13:25:17 +00:00
|
|
|
"fitted": ShirtGroup(
|
|
|
|
"Fitted",
|
|
|
|
("XS", "S", "M", "L", "XL", "2XL"),
|
2016-09-30 10:46:05 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
|
|
|
|
self.shirts = {}
|
|
|
|
order = 0
|
|
|
|
for name, group in shirt_names.items():
|
|
|
|
self.shirts[name] = {}
|
|
|
|
prefix = group.prefix
|
|
|
|
for size in group.sizes:
|
|
|
|
product_name = "%s %s" % (prefix, size)
|
|
|
|
order += 10
|
|
|
|
self.shirts[name][size] = self.find_or_make(
|
|
|
|
inv.Product,
|
|
|
|
("name", "category",),
|
|
|
|
name=product_name,
|
|
|
|
category=self.t_shirt,
|
2019-09-22 07:15:23 +00:00
|
|
|
price=settings.TSHIRT_PRICE,
|
2016-09-30 10:46:05 +00:00
|
|
|
reservation_duration=hours(1),
|
|
|
|
order=order,
|
|
|
|
)
|
|
|
|
|
|
|
|
def populate_restrictions(self):
|
|
|
|
|
|
|
|
# Hide the products that will eventually need a voucher
|
|
|
|
hide_voucher_products = self.find_or_make(
|
|
|
|
cond.GroupMemberFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Can see hidden products",
|
|
|
|
condition=cond.FlagBase.ENABLE_IF_TRUE,
|
|
|
|
)
|
|
|
|
hide_voucher_products.group.set([self.group_unpublish])
|
|
|
|
hide_voucher_products.products.set([
|
|
|
|
self.ticket_media,
|
|
|
|
self.ticket_sponsor,
|
2017-09-24 02:30:35 +00:00
|
|
|
self.ticket_miniconfs_mt,
|
|
|
|
self.ticket_miniconfs_mon,
|
|
|
|
self.ticket_miniconfs_tue,
|
|
|
|
])
|
|
|
|
|
|
|
|
hide_all_tickets = self.find_or_make(
|
|
|
|
cond.GroupMemberFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Can pre-purchase tickets",
|
|
|
|
condition=cond.FlagBase.ENABLE_IF_TRUE,
|
|
|
|
)
|
|
|
|
hide_all_tickets.group.set([self.group_prepurchase])
|
|
|
|
hide_all_tickets.products.set([
|
2019-09-22 04:07:11 +00:00
|
|
|
self.ticket_contributor,
|
2017-09-24 02:30:35 +00:00
|
|
|
self.ticket_professional,
|
|
|
|
self.ticket_hobbyist,
|
|
|
|
self.ticket_student,
|
2016-09-30 10:46:05 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
# Set limits.
|
|
|
|
public_ticket_cap = self.find_or_make(
|
|
|
|
cond.TimeOrStockLimitFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Public ticket cap",
|
|
|
|
condition=cond.FlagBase.DISABLE_IF_FALSE,
|
2017-09-24 02:30:35 +00:00
|
|
|
limit=600,
|
2016-09-30 10:46:05 +00:00
|
|
|
)
|
|
|
|
public_ticket_cap.products.set([
|
2019-09-22 04:07:11 +00:00
|
|
|
self.ticket_contributor,
|
2016-09-30 10:46:05 +00:00
|
|
|
self.ticket_professional,
|
|
|
|
self.ticket_hobbyist,
|
|
|
|
self.ticket_student,
|
|
|
|
])
|
|
|
|
|
2017-09-24 02:30:35 +00:00
|
|
|
student_ticket_cap = self.find_or_make(
|
2016-09-30 10:46:05 +00:00
|
|
|
cond.TimeOrStockLimitFlag,
|
|
|
|
("description", ),
|
2017-09-24 02:30:35 +00:00
|
|
|
description="Student ticket cap",
|
2016-09-30 10:46:05 +00:00
|
|
|
condition=cond.FlagBase.DISABLE_IF_FALSE,
|
2017-09-24 02:30:35 +00:00
|
|
|
limit=100,
|
2016-09-30 10:46:05 +00:00
|
|
|
)
|
2019-09-22 03:41:57 +00:00
|
|
|
|
|
|
|
student_ticket_cap.products.set([
|
|
|
|
self.ticket_student,
|
|
|
|
])
|
|
|
|
|
2017-09-24 02:30:35 +00:00
|
|
|
public_ticket_cap.products.set([
|
2019-09-22 04:07:11 +00:00
|
|
|
self.ticket_contributor,
|
2017-09-24 02:30:35 +00:00
|
|
|
self.ticket_professional,
|
|
|
|
self.ticket_hobbyist,
|
|
|
|
self.ticket_student,
|
|
|
|
])
|
|
|
|
|
|
|
|
sponsor_ticket_cap = self.find_or_make(
|
|
|
|
cond.TimeOrStockLimitFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Reserved for sponsors",
|
|
|
|
condition=cond.FlagBase.DISABLE_IF_FALSE,
|
|
|
|
limit=70,
|
|
|
|
)
|
|
|
|
sponsor_ticket_cap.products.set([
|
2016-09-30 10:46:05 +00:00
|
|
|
self.ticket_sponsor,
|
2017-09-24 02:30:35 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
volunteer_ticket_cap = self.find_or_make(
|
|
|
|
cond.TimeOrStockLimitFlag,
|
|
|
|
("description", ),
|
2019-10-02 13:25:17 +00:00
|
|
|
description="Reserved for volunteers and organisers",
|
2017-09-24 02:30:35 +00:00
|
|
|
condition=cond.FlagBase.DISABLE_IF_FALSE,
|
|
|
|
limit=62,
|
|
|
|
)
|
|
|
|
volunteer_ticket_cap.products.set([
|
2016-09-30 10:46:05 +00:00
|
|
|
self.ticket_team,
|
|
|
|
self.ticket_volunteer,
|
|
|
|
])
|
|
|
|
|
2017-09-24 02:30:35 +00:00
|
|
|
media_ticket_cap = self.find_or_make(
|
|
|
|
cond.TimeOrStockLimitFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Reserved for media",
|
|
|
|
condition=cond.FlagBase.DISABLE_IF_FALSE,
|
|
|
|
limit=10,
|
|
|
|
)
|
|
|
|
media_ticket_cap.products.set([
|
|
|
|
self.ticket_media,
|
|
|
|
])
|
|
|
|
|
|
|
|
speaker_ticket_cap = self.find_or_make(
|
|
|
|
cond.TimeOrStockLimitFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Reserved for speakers (and miniconf organisers)",
|
|
|
|
condition=cond.FlagBase.DISABLE_IF_FALSE,
|
|
|
|
limit=104,
|
|
|
|
)
|
|
|
|
speaker_ticket_cap.products.set([
|
|
|
|
self.ticket_speaker,
|
|
|
|
])
|
|
|
|
|
2016-09-30 10:46:05 +00:00
|
|
|
penguin_dinner_cap = self.find_or_make(
|
|
|
|
cond.TimeOrStockLimitFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Penguin dinner ticket cap",
|
|
|
|
condition=cond.FlagBase.DISABLE_IF_FALSE,
|
2017-09-24 02:30:35 +00:00
|
|
|
limit=900,
|
2016-09-30 10:46:05 +00:00
|
|
|
)
|
|
|
|
penguin_dinner_cap.categories.set([
|
|
|
|
self.penguin_dinner,
|
|
|
|
])
|
|
|
|
|
|
|
|
speakers_dinner_cap = self.find_or_make(
|
|
|
|
cond.TimeOrStockLimitFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Speakers dinner ticket cap",
|
|
|
|
condition=cond.FlagBase.DISABLE_IF_FALSE,
|
2017-09-24 02:30:35 +00:00
|
|
|
limit=135,
|
2016-09-30 10:46:05 +00:00
|
|
|
)
|
|
|
|
speakers_dinner_cap.categories.set([
|
|
|
|
self.speakers_dinner_ticket,
|
|
|
|
])
|
|
|
|
|
|
|
|
pdns_cap = self.find_or_make(
|
|
|
|
cond.TimeOrStockLimitFlag,
|
|
|
|
("description", ),
|
2017-09-24 02:30:35 +00:00
|
|
|
description="PDNS ticket cap",
|
2016-09-30 10:46:05 +00:00
|
|
|
condition=cond.FlagBase.DISABLE_IF_FALSE,
|
|
|
|
limit=400,
|
|
|
|
)
|
|
|
|
pdns_cap.categories.set([
|
2017-09-24 02:30:35 +00:00
|
|
|
self.pdns_category,
|
2016-09-30 10:46:05 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
# Volunteer tickets are for volunteers only
|
|
|
|
volunteers = self.find_or_make(
|
|
|
|
cond.GroupMemberFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Volunteer tickets",
|
|
|
|
condition=cond.FlagBase.ENABLE_IF_TRUE,
|
|
|
|
)
|
|
|
|
volunteers.group.set([self.group_volunteers])
|
|
|
|
volunteers.products.set([
|
|
|
|
self.ticket_volunteer,
|
|
|
|
])
|
|
|
|
|
|
|
|
# Team tickets are for team members only
|
|
|
|
team = self.find_or_make(
|
|
|
|
cond.GroupMemberFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Team tickets",
|
|
|
|
condition=cond.FlagBase.ENABLE_IF_TRUE,
|
|
|
|
)
|
|
|
|
team.group.set([self.group_team])
|
|
|
|
team.products.set([
|
|
|
|
self.ticket_team,
|
|
|
|
])
|
|
|
|
|
|
|
|
# Speaker tickets are for primary speakers only
|
|
|
|
speaker_tickets = self.find_or_make(
|
|
|
|
cond.SpeakerFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Speaker tickets",
|
|
|
|
condition=cond.FlagBase.ENABLE_IF_TRUE,
|
|
|
|
is_presenter=True,
|
|
|
|
is_copresenter=False,
|
|
|
|
)
|
|
|
|
speaker_tickets.proposal_kind.set(self.main_conference_proposals)
|
|
|
|
speaker_tickets.products.set([self.ticket_speaker, ])
|
|
|
|
|
2019-10-02 13:25:17 +00:00
|
|
|
# Speaker dinner tickets are for primary speakers only
|
2016-09-30 10:46:05 +00:00
|
|
|
speaker_dinner_tickets = self.find_or_make(
|
|
|
|
cond.SpeakerFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Speaker dinner tickets",
|
|
|
|
condition=cond.FlagBase.ENABLE_IF_TRUE,
|
|
|
|
is_presenter=True,
|
2019-10-02 13:25:17 +00:00
|
|
|
is_copresenter=False,
|
2016-09-30 10:46:05 +00:00
|
|
|
)
|
|
|
|
speaker_dinner_tickets.proposal_kind.set(self.main_conference_proposals)
|
|
|
|
speaker_dinner_tickets.categories.set([self.speakers_dinner_ticket, ])
|
|
|
|
|
|
|
|
# PDNS tickets are complicated.
|
|
|
|
# They can be enabled by tickets
|
|
|
|
pdns_by_ticket = self.find_or_make(
|
|
|
|
cond.ProductFlag,
|
|
|
|
("description", ),
|
|
|
|
description="PDNS available by ticket",
|
|
|
|
condition=cond.FlagBase.ENABLE_IF_TRUE,
|
|
|
|
)
|
|
|
|
pdns_by_ticket.enabling_products.set([
|
|
|
|
self.ticket_professional,
|
2019-09-22 04:07:11 +00:00
|
|
|
self.ticket_contributor,
|
2016-09-30 10:46:05 +00:00
|
|
|
self.ticket_media,
|
|
|
|
self.ticket_sponsor,
|
|
|
|
])
|
2017-09-24 02:30:35 +00:00
|
|
|
pdns_by_ticket.categories.set([self.pdns_category, ])
|
2016-09-30 10:46:05 +00:00
|
|
|
|
|
|
|
# They are available to speakers
|
|
|
|
pdns_by_speaker = self.find_or_make(
|
|
|
|
cond.SpeakerFlag,
|
|
|
|
("description", ),
|
|
|
|
description="PDNS available to speakers",
|
|
|
|
condition=cond.FlagBase.ENABLE_IF_TRUE,
|
|
|
|
is_presenter=True,
|
|
|
|
is_copresenter=True,
|
|
|
|
|
|
|
|
)
|
|
|
|
pdns_by_speaker.proposal_kind.set(self.main_conference_proposals)
|
2017-09-24 02:30:35 +00:00
|
|
|
pdns_by_speaker.categories.set([self.pdns_category, ])
|
2016-09-30 10:46:05 +00:00
|
|
|
|
|
|
|
# They are available to staff
|
|
|
|
pdns_by_staff = self.find_or_make(
|
|
|
|
cond.GroupMemberFlag,
|
|
|
|
("description", ),
|
|
|
|
description="PDNS available to staff",
|
|
|
|
condition=cond.FlagBase.ENABLE_IF_TRUE,
|
|
|
|
)
|
|
|
|
pdns_by_staff.group.set([
|
|
|
|
self.group_team,
|
|
|
|
])
|
2017-09-24 02:30:35 +00:00
|
|
|
pdns_by_staff.categories.set([self.pdns_category, ])
|
|
|
|
|
2019-09-22 03:41:57 +00:00
|
|
|
# Don't allow people to get anything if they don't have a ticket first
|
2017-09-24 02:30:35 +00:00
|
|
|
needs_a_ticket = self.find_or_make(
|
|
|
|
cond.CategoryFlag,
|
|
|
|
("description", ),
|
|
|
|
description="GottaGettaTicketFirst",
|
2017-10-01 13:02:15 +00:00
|
|
|
condition=cond.FlagBase.DISABLE_IF_FALSE,
|
2019-09-22 03:41:57 +00:00
|
|
|
enabling_category=self.ticket
|
2017-09-24 02:30:35 +00:00
|
|
|
)
|
|
|
|
needs_a_ticket.categories.set([
|
|
|
|
self.extras,
|
|
|
|
self.t_shirt,
|
|
|
|
self.penguin_dinner,
|
2017-10-01 08:14:37 +00:00
|
|
|
self.pdns_category,
|
2017-09-24 02:30:35 +00:00
|
|
|
])
|
2017-10-01 08:14:37 +00:00
|
|
|
# Require attendees to accept the T&Cs and Code of Conduct
|
|
|
|
needs_agreement = self.find_or_make(
|
|
|
|
cond.CategoryFlag,
|
|
|
|
("description", ),
|
|
|
|
description="Must Accept Terms",
|
|
|
|
condition=cond.FlagBase.DISABLE_IF_FALSE,
|
2019-09-22 03:41:57 +00:00
|
|
|
enabling_category=self.terms,
|
2017-10-01 08:14:37 +00:00
|
|
|
)
|
|
|
|
needs_agreement.categories.set([
|
|
|
|
self.extras,
|
|
|
|
self.t_shirt,
|
|
|
|
self.penguin_dinner,
|
|
|
|
self.pdns_category,
|
2017-10-01 22:12:21 +00:00
|
|
|
self.speakers_dinner_ticket,
|
2017-10-01 08:14:37 +00:00
|
|
|
])
|
|
|
|
|
2016-09-30 10:46:05 +00:00
|
|
|
def populate_discounts(self):
|
|
|
|
def add_early_birds(discount):
|
|
|
|
self.find_or_make(
|
|
|
|
cond.DiscountForProduct,
|
|
|
|
("discount", "product"),
|
|
|
|
discount=discount,
|
2019-09-22 04:07:11 +00:00
|
|
|
product=self.ticket_contributor,
|
2019-09-22 07:15:23 +00:00
|
|
|
price=settings.CONTRIBUTOR.earlybird_discount(),
|
2016-09-30 10:46:05 +00:00
|
|
|
quantity=1, # Per user
|
|
|
|
)
|
|
|
|
self.find_or_make(
|
|
|
|
cond.DiscountForProduct,
|
|
|
|
("discount", "product"),
|
|
|
|
discount=discount,
|
|
|
|
product=self.ticket_professional,
|
2019-09-22 07:15:23 +00:00
|
|
|
price=settings.PROFESSIONAL.earlybird_discount(),
|
2016-09-30 10:46:05 +00:00
|
|
|
quantity=1, # Per user
|
|
|
|
)
|
|
|
|
|
|
|
|
def free_category(parent_discount, category, quantity=1):
|
|
|
|
self.find_or_make(
|
|
|
|
cond.DiscountForCategory,
|
|
|
|
("discount", "category",),
|
|
|
|
discount=parent_discount,
|
|
|
|
category=category,
|
|
|
|
percentage=Decimal("100.00"),
|
|
|
|
quantity=quantity,
|
|
|
|
)
|
|
|
|
|
|
|
|
# Early Bird Discount (general public)
|
2017-09-24 02:30:35 +00:00
|
|
|
early_bird_hobbyist_discount = self.find_or_make(
|
|
|
|
cond.TimeOrStockLimitDiscount,
|
|
|
|
("description", ),
|
2017-10-01 03:50:53 +00:00
|
|
|
description="Early Bird Discount - Hobbyist",
|
2019-09-22 03:38:33 +00:00
|
|
|
end_time=settings.EARLY_BIRD_DEADLINE,
|
2017-09-24 02:30:35 +00:00
|
|
|
limit=150, # Across all users
|
|
|
|
)
|
|
|
|
self.find_or_make(
|
|
|
|
cond.DiscountForProduct,
|
|
|
|
("discount", "product"),
|
|
|
|
discount=early_bird_hobbyist_discount,
|
|
|
|
product=self.ticket_hobbyist,
|
2019-09-22 07:15:23 +00:00
|
|
|
price=settings.HOBBYIST.earlybird_discount(),
|
2017-09-24 02:30:35 +00:00
|
|
|
quantity=1, # Per user
|
|
|
|
)
|
|
|
|
|
2016-09-30 10:46:05 +00:00
|
|
|
early_bird = self.find_or_make(
|
|
|
|
cond.TimeOrStockLimitDiscount,
|
|
|
|
("description", ),
|
2017-10-01 03:50:53 +00:00
|
|
|
description="Early Bird Discount - Professional",
|
2019-09-22 03:38:33 +00:00
|
|
|
end_time=settings.EARLY_BIRD_DEADLINE,
|
2017-10-01 03:50:53 +00:00
|
|
|
limit=200, # Across professionals and fairy sponsors
|
2016-09-30 10:46:05 +00:00
|
|
|
)
|
|
|
|
add_early_birds(early_bird)
|
|
|
|
|
|
|
|
# Early bird rates for speakers
|
|
|
|
speaker_ticket_discounts = self.find_or_make(
|
|
|
|
cond.SpeakerDiscount,
|
|
|
|
("description", ),
|
|
|
|
description="Speaker Ticket Discount",
|
|
|
|
is_presenter=True,
|
|
|
|
is_copresenter=True,
|
|
|
|
)
|
|
|
|
speaker_ticket_discounts.proposal_kind.set(
|
|
|
|
self.main_conference_proposals,
|
|
|
|
)
|
|
|
|
add_early_birds(speaker_ticket_discounts)
|
|
|
|
|
|
|
|
# Primary speaker gets a free speaker dinner ticket
|
|
|
|
primary_speaker = self.find_or_make(
|
|
|
|
cond.SpeakerDiscount,
|
|
|
|
("description", ),
|
|
|
|
description="Complimentary for primary proposer",
|
|
|
|
is_presenter=True,
|
|
|
|
is_copresenter=False,
|
|
|
|
)
|
|
|
|
primary_speaker.proposal_kind.set(self.main_conference_proposals)
|
|
|
|
free_category(primary_speaker, self.speakers_dinner_ticket)
|
|
|
|
|
|
|
|
# Professional-Like ticket inclusions
|
|
|
|
ticket_prolike_inclusions = self.find_or_make(
|
|
|
|
cond.IncludedProductDiscount,
|
|
|
|
("description", ),
|
|
|
|
description="Complimentary for ticket holder (Professional-level)",
|
|
|
|
)
|
|
|
|
ticket_prolike_inclusions.enabling_products.set([
|
2019-09-22 04:07:11 +00:00
|
|
|
self.ticket_contributor,
|
2016-09-30 10:46:05 +00:00
|
|
|
self.ticket_professional,
|
|
|
|
self.ticket_media,
|
|
|
|
self.ticket_sponsor,
|
|
|
|
self.ticket_speaker,
|
|
|
|
])
|
|
|
|
free_category(ticket_prolike_inclusions, self.penguin_dinner)
|
|
|
|
free_category(ticket_prolike_inclusions, self.t_shirt)
|
|
|
|
|
|
|
|
# Hobbyist ticket inclusions
|
|
|
|
ticket_hobbyist_inclusions = self.find_or_make(
|
|
|
|
cond.IncludedProductDiscount,
|
|
|
|
("description", ),
|
|
|
|
description="Complimentary for ticket holder (Hobbyist-level)",
|
|
|
|
)
|
|
|
|
ticket_hobbyist_inclusions.enabling_products.set([
|
|
|
|
self.ticket_hobbyist,
|
|
|
|
])
|
|
|
|
free_category(ticket_hobbyist_inclusions, self.t_shirt)
|
|
|
|
|
|
|
|
# Student ticket inclusions
|
|
|
|
ticket_student_inclusions = self.find_or_make(
|
|
|
|
cond.IncludedProductDiscount,
|
|
|
|
("description", ),
|
|
|
|
description="Complimentary for ticket holder (Student-level)",
|
|
|
|
)
|
|
|
|
ticket_student_inclusions.enabling_products.set([
|
|
|
|
self.ticket_student,
|
|
|
|
])
|
|
|
|
free_category(ticket_student_inclusions, self.t_shirt)
|
|
|
|
|
2017-10-01 13:02:15 +00:00
|
|
|
# Team ticket inclusions
|
2016-09-30 10:46:05 +00:00
|
|
|
ticket_staff_inclusions = self.find_or_make(
|
|
|
|
cond.IncludedProductDiscount,
|
|
|
|
("description", ),
|
2019-10-02 13:25:17 +00:00
|
|
|
description="Complimentary for ticket holder (Staff)",
|
2016-09-30 10:46:05 +00:00
|
|
|
)
|
|
|
|
ticket_staff_inclusions.enabling_products.set([
|
|
|
|
self.ticket_team,
|
|
|
|
])
|
|
|
|
free_category(ticket_staff_inclusions, self.penguin_dinner)
|
|
|
|
|
2017-09-30 13:40:46 +00:00
|
|
|
# Team & volunteer shirts, regardless of ticket type
|
2016-09-30 10:46:05 +00:00
|
|
|
staff_t_shirts = self.find_or_make(
|
|
|
|
cond.GroupMemberDiscount,
|
|
|
|
("description", ),
|
2017-09-30 13:40:46 +00:00
|
|
|
description="Shirts complimentary for staff and volunteers",
|
2016-09-30 10:46:05 +00:00
|
|
|
)
|
|
|
|
staff_t_shirts.group.set([
|
|
|
|
self.group_team,
|
|
|
|
self.group_volunteers,
|
|
|
|
])
|
|
|
|
free_category(staff_t_shirts, self.t_shirt, quantity=5)
|
|
|
|
|
2019-09-24 08:36:40 +00:00
|
|
|
print(f"{self.count} categories found/made")
|
|
|
|
|
2016-09-30 10:46:05 +00:00
|
|
|
def find_or_make(self, model, search_keys, **k):
|
|
|
|
''' Either makes or finds an object of type _model_, with the given
|
|
|
|
kwargs.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
search_keys ([str, ...]): A sequence of keys that are used to search
|
|
|
|
for an existing version in the database. The remaining arguments are
|
|
|
|
only used when creating a new object.
|
|
|
|
'''
|
2019-09-24 08:36:40 +00:00
|
|
|
self.count += 1
|
2016-09-30 10:46:05 +00:00
|
|
|
try:
|
|
|
|
keys = dict((key, k[key]) for key in search_keys)
|
|
|
|
a = model.objects.get(**keys)
|
|
|
|
self.stdout.write("FOUND : " + str(keys))
|
|
|
|
model.objects.filter(id=a.id).update(**k)
|
|
|
|
a.refresh_from_db()
|
|
|
|
return a
|
|
|
|
except ObjectDoesNotExist:
|
|
|
|
a = model.objects.create(**k)
|
|
|
|
self.stdout.write("CREATED: " + str(k))
|
|
|
|
return a
|
|
|
|
|
|
|
|
|
|
|
|
def hours(n):
|
|
|
|
return timedelta(hours=n)
|