2017-07-15 09:00:59 +00:00
|
|
|
from django.db import models
|
2021-07-19 13:06:10 +00:00
|
|
|
|
2018-03-04 13:41:51 +00:00
|
|
|
from utils.models import CampRelatedModel
|
2017-07-15 09:00:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_sponsor_upload_path(instance, filename):
|
2019-06-16 12:32:24 +00:00
|
|
|
return "public/sponsors/{camp_slug}/{filename}".format(
|
2017-07-15 09:00:59 +00:00
|
|
|
camp_slug=instance.tier.camp.slug,
|
2019-06-16 12:32:24 +00:00
|
|
|
filename="{}_logo.{}".format(instance.name.lower(), filename.split(".")[-1]),
|
2017-07-15 09:00:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-03-04 11:04:07 +00:00
|
|
|
class Sponsor(CampRelatedModel):
|
2019-06-16 12:32:24 +00:00
|
|
|
name = models.CharField(max_length=150, help_text="Name of the sponsor")
|
2017-07-15 09:00:59 +00:00
|
|
|
|
2019-06-16 12:32:24 +00:00
|
|
|
tier = models.ForeignKey("sponsors.SponsorTier", on_delete=models.PROTECT)
|
2017-07-15 09:00:59 +00:00
|
|
|
|
2019-06-16 12:32:24 +00:00
|
|
|
description = models.TextField(help_text="A short description of the sponsorship")
|
2017-07-15 09:00:59 +00:00
|
|
|
|
2019-06-16 12:32:24 +00:00
|
|
|
logo_filename = models.CharField(max_length=255, help_text="Filename of the logo")
|
2017-07-15 09:00:59 +00:00
|
|
|
|
2019-06-16 12:32:24 +00:00
|
|
|
url = models.URLField(null=True, blank=True, help_text="An URL to the sponsor.")
|
2017-07-15 09:00:59 +00:00
|
|
|
|
2018-08-15 09:30:33 +00:00
|
|
|
tickets_generated = models.BooleanField(default=False)
|
|
|
|
|
2020-02-07 17:46:34 +00:00
|
|
|
ticket_email = models.EmailField(
|
|
|
|
null=True, blank=True, help_text="The email to send the tickets to"
|
|
|
|
)
|
2019-08-08 07:44:47 +00:00
|
|
|
|
2020-02-07 17:46:34 +00:00
|
|
|
ticket_ready = models.BooleanField(
|
|
|
|
default=False,
|
|
|
|
help_text="Check when we are ready to send tickets to this sponsor.",
|
|
|
|
)
|
2019-08-08 07:44:47 +00:00
|
|
|
|
2020-02-07 17:46:34 +00:00
|
|
|
tickets_sent = models.BooleanField(
|
|
|
|
default=False,
|
|
|
|
help_text="True when the tickets have been emailed to the sponsor",
|
|
|
|
)
|
2019-08-08 07:44:47 +00:00
|
|
|
|
2017-07-15 09:00:59 +00:00
|
|
|
def __str__(self):
|
2019-06-16 12:32:24 +00:00
|
|
|
return "{} ({})".format(self.name, self.tier.camp)
|
2017-07-15 09:00:59 +00:00
|
|
|
|
2018-03-04 11:04:07 +00:00
|
|
|
@property
|
|
|
|
def camp(self):
|
|
|
|
return self.tier.camp
|
2017-07-15 09:00:59 +00:00
|
|
|
|
2019-06-16 12:32:24 +00:00
|
|
|
camp_filter = "tier__camp"
|
2018-06-20 20:03:29 +00:00
|
|
|
|
2018-03-04 14:39:22 +00:00
|
|
|
|
2017-07-15 09:00:59 +00:00
|
|
|
class SponsorTier(CampRelatedModel):
|
|
|
|
name = models.CharField(
|
2019-06-16 12:32:24 +00:00
|
|
|
max_length=25, help_text="Name of the tier (gold, silver, etc.)"
|
2017-07-15 09:00:59 +00:00
|
|
|
)
|
|
|
|
|
2019-06-16 12:32:24 +00:00
|
|
|
description = models.TextField(help_text="A description of what the tier includes.")
|
2017-07-15 09:00:59 +00:00
|
|
|
|
|
|
|
camp = models.ForeignKey(
|
2019-06-16 12:32:24 +00:00
|
|
|
"camps.Camp",
|
2017-07-15 09:00:59 +00:00
|
|
|
null=True,
|
2018-03-04 15:26:35 +00:00
|
|
|
on_delete=models.PROTECT,
|
2019-06-16 12:32:24 +00:00
|
|
|
related_name="sponsor_tiers",
|
|
|
|
help_text="The camp this sponsor tier belongs to",
|
2017-07-15 09:00:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
weight = models.IntegerField(
|
|
|
|
default=0,
|
|
|
|
help_text="""This decides where on the list the tier will be shown. I.e.
|
2019-06-16 12:32:24 +00:00
|
|
|
gold should have a lower value than silver.""",
|
2017-07-15 09:00:59 +00:00
|
|
|
)
|
|
|
|
|
2018-08-15 09:30:33 +00:00
|
|
|
tickets = models.IntegerField(
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
2019-06-16 12:32:24 +00:00
|
|
|
help_text="If set this is the number of tickets generated for a sponsor in this tier.",
|
2018-08-15 09:30:33 +00:00
|
|
|
)
|
|
|
|
|
2017-07-15 09:00:59 +00:00
|
|
|
def __str__(self):
|
2019-06-16 12:32:24 +00:00
|
|
|
return "{} ({})".format(self.name, self.camp)
|