more ticket information as data
This commit is contained in:
parent
cf7e67a747
commit
9d37326953
2 changed files with 83 additions and 80 deletions
|
@ -13,6 +13,7 @@ from symposion import proposals
|
|||
|
||||
class Command(BaseCommand):
|
||||
help = 'Populates the tickets and product inventory models'
|
||||
count = 0
|
||||
|
||||
def add_arguments(self, parser):
|
||||
pass
|
||||
|
@ -286,71 +287,30 @@ class Command(BaseCommand):
|
|||
order=10,
|
||||
limit_per_user=1,
|
||||
)
|
||||
# Penguin dinner
|
||||
|
||||
self.penguin_adult = self.find_or_make(
|
||||
inv.Product,
|
||||
("name", "category",),
|
||||
category=self.penguin_dinner,
|
||||
name=settings.PENGUIN_DINNER_ADULT.name,
|
||||
description=settings.PENGUIN_DINNER_ADULT.description,
|
||||
price=settings.PENGUIN_DINNER_ADULT.price,
|
||||
reservation_duration=hours(1),
|
||||
order=10,
|
||||
)
|
||||
self.penguin_child = self.find_or_make(
|
||||
inv.Product,
|
||||
("name", "category",),
|
||||
category=self.penguin_dinner,
|
||||
name=settings.PENGUIN_DINNER_CHILD.name,
|
||||
description=settings.PENGUIN_DINNER_CHILD.description,
|
||||
price=settings.PENGUIN_DINNER_CHILD.price,
|
||||
reservation_duration=hours(1),
|
||||
order=20,
|
||||
)
|
||||
self.penguin_infant = self.find_or_make(
|
||||
inv.Product,
|
||||
("name", "category",),
|
||||
category=self.penguin_dinner,
|
||||
name=settings.PENGUIN_DINNER_INFANT.name,
|
||||
description=settings.PENGUIN_DINNER_INFANT.description,
|
||||
price=settings.PENGUIN_DINNER_INFANT.price,
|
||||
reservation_duration=hours(1),
|
||||
order=30,
|
||||
)
|
||||
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()
|
||||
)
|
||||
|
||||
# Speakers' dinner
|
||||
|
||||
self.speakers_adult = self.find_or_make(
|
||||
inv.Product,
|
||||
("name", "category",),
|
||||
category=self.speakers_dinner_ticket,
|
||||
name=settings.SPEAKERS_DINNER_ADULT.name,
|
||||
description=settings.SPEAKERS_DINNER_ADULT.description,
|
||||
price=settings.SPEAKERS_DINNER_ADULT.price,
|
||||
reservation_duration=hours(1),
|
||||
order=10,
|
||||
)
|
||||
self.speakers_child = self.find_or_make(
|
||||
inv.Product,
|
||||
("name", "category",),
|
||||
category=self.speakers_dinner_ticket,
|
||||
name=settings.SPEAKERS_DINNER_CHILD.name,
|
||||
description=settings.SPEAKERS_DINNER_CHILD.description,
|
||||
price=settings.SPEAKERS_DINNER_CHILD.price,
|
||||
reservation_duration=hours(1),
|
||||
order=20,
|
||||
)
|
||||
self.speaker_infant = self.find_or_make(
|
||||
inv.Product,
|
||||
("name", "category",),
|
||||
category=self.speakers_dinner_ticket,
|
||||
name=settings.SPEAKERS_DINNER_INFANT.name,
|
||||
description=settings.SPEAKERS_DINNER_INFANT.description,
|
||||
price=settings.SPEAKERS_DINNER_INFANT.price,
|
||||
reservation_duration=hours(1),
|
||||
order=30,
|
||||
)
|
||||
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()
|
||||
)
|
||||
|
||||
# PDNS
|
||||
|
||||
|
@ -826,6 +786,8 @@ class Command(BaseCommand):
|
|||
])
|
||||
free_category(staff_t_shirts, self.t_shirt, quantity=5)
|
||||
|
||||
print(f"{self.count} categories found/made")
|
||||
|
||||
def find_or_make(self, model, search_keys, **k):
|
||||
''' Either makes or finds an object of type _model_, with the given
|
||||
kwargs.
|
||||
|
@ -835,7 +797,7 @@ class Command(BaseCommand):
|
|||
for an existing version in the database. The remaining arguments are
|
||||
only used when creating a new object.
|
||||
'''
|
||||
|
||||
self.count += 1
|
||||
try:
|
||||
keys = dict((key, k[key]) for key in search_keys)
|
||||
a = model.objects.get(**keys)
|
||||
|
|
|
@ -7,7 +7,7 @@ import dj_database_url
|
|||
import saml2
|
||||
import saml2.saml
|
||||
|
||||
from datetime import date, datetime
|
||||
from datetime import date, datetime, timedelta
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
@ -444,7 +444,15 @@ if DEV_MODE and DEV_MODE == "LAPTOP":
|
|||
print("ENABLING LAPTOP MODE")
|
||||
from .devmode_settings import *
|
||||
|
||||
# Ticket information
|
||||
|
||||
class Category(object):
|
||||
tickets = []
|
||||
|
||||
@classmethod
|
||||
def order(cls, ticket) -> int:
|
||||
return (cls.tickets.index(ticket) + 1) * 10
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Ticket:
|
||||
name: str
|
||||
|
@ -456,17 +464,39 @@ class Ticket:
|
|||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PenguinDinnerTicket:
|
||||
class DinnerTicket:
|
||||
name: str
|
||||
price: Decimal
|
||||
description: str
|
||||
reservation: timedelta
|
||||
cat: Category
|
||||
|
||||
def order(self):
|
||||
return self.cat.order(self)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SpeakersDinnerTicket:
|
||||
name: str
|
||||
price: Decimal
|
||||
description: str
|
||||
class PenguinDinnerTicket(DinnerTicket):
|
||||
pass
|
||||
|
||||
|
||||
class SpeakersDinnerTicket(DinnerTicket):
|
||||
pass
|
||||
|
||||
|
||||
class SpeakersDinnerCat(Category):
|
||||
@classmethod
|
||||
def create(cls, name: str, price: Decimal, description: str, reservation: timedelta) -> SpeakersDinnerTicket:
|
||||
t = SpeakersDinnerTicket(name, price, description, reservation, cls)
|
||||
cls.tickets.append(t)
|
||||
return t
|
||||
|
||||
|
||||
class PenguinDinnerCat(Category):
|
||||
@classmethod
|
||||
def create(cls, name: str, price: Decimal, description: str, reservation: timedelta) -> PenguinDinnerTicket:
|
||||
t = PenguinDinnerTicket(name, price, description, reservation, cls)
|
||||
cls.tickets.append(t)
|
||||
return t
|
||||
|
||||
|
||||
LCA_START = datetime(2020, 1, 13)
|
||||
|
@ -502,11 +532,22 @@ PENGUIN_DINNER_CHILD = PenguinDinnerTicket("Child", Decimal("50.00"),
|
|||
PENGUIN_DINNER_INFANT = PenguinDinnerTicket("Infant", Decimal("0.0"),
|
||||
"Includes no food or beverage service.")
|
||||
|
||||
SPEAKERS_DINNER_ADULT = SpeakersDinnerTicket("Adult", Decimal("100.00"),
|
||||
"Includes an adult's meal and full beverage service.")
|
||||
SPEAKERS_DINNER_CHILD = SpeakersDinnerTicket("Child", Decimal("60.00"),
|
||||
"Children 14 and under. "
|
||||
"Includes a child's meal and soft drink service.")
|
||||
SPEAKERS_DINNER_INFANT = SpeakersDinnerTicket("Infant", Decimal("00.00"),
|
||||
"Infant must be seated in an adult's lap. "
|
||||
"No food or beverage service.")
|
||||
SPEAKERS_DINNER = SpeakersDinnerCat
|
||||
PENGUIN_DINNER = PenguinDinnerCat
|
||||
|
||||
SPEAKERS_DINNER_ADULT = SpeakersDinnerCat.create(
|
||||
"Adult", Decimal("100.00"),
|
||||
"Includes an adult's meal and full beverage service.",
|
||||
timedelta(hours=1))
|
||||
|
||||
SPEAKERS_DINNER_CHILD = SpeakersDinnerCat.create(
|
||||
"Child", Decimal("60.00"),
|
||||
"Children 14 and under. "
|
||||
"Includes a child's meal and soft drink service.",
|
||||
timedelta(hours=1))
|
||||
|
||||
SPEAKERS_DINNER_INFANT = SpeakersDinnerCat.create(
|
||||
"Infant", Decimal("00.00"),
|
||||
"Infant must be seated in an adult's lap. "
|
||||
"No food or beverage service.",
|
||||
timedelta(hours=1))
|
||||
|
|
Loading…
Reference in a new issue