2017-07-15 09:00:59 +00:00
|
|
|
from django.db import models
|
|
|
|
|
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):
|
|
|
|
return 'public/sponsors/{camp_slug}/{filename}'.format(
|
|
|
|
camp_slug=instance.tier.camp.slug,
|
|
|
|
filename='{}_logo.{}'.format(
|
|
|
|
instance.name.lower(),
|
|
|
|
filename.split('.')[-1]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-03-04 11:04:07 +00:00
|
|
|
class Sponsor(CampRelatedModel):
|
2017-07-15 09:00:59 +00:00
|
|
|
name = models.CharField(
|
|
|
|
max_length=150,
|
|
|
|
help_text='Name of the sponsor'
|
|
|
|
)
|
|
|
|
|
2018-03-04 15:26:35 +00:00
|
|
|
tier = models.ForeignKey('sponsors.SponsorTier', on_delete=models.PROTECT)
|
2017-07-15 09:00:59 +00:00
|
|
|
|
|
|
|
description = models.TextField(
|
|
|
|
help_text='A short description of the sponsorship'
|
|
|
|
)
|
|
|
|
|
2017-07-15 13:21:00 +00:00
|
|
|
logo = models.URLField(
|
|
|
|
max_length=255,
|
|
|
|
help_text='A URL to the logo'
|
2017-07-15 09:00:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
url = models.URLField(
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
2017-07-15 13:21:00 +00:00
|
|
|
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)
|
|
|
|
|
2017-07-15 09:00:59 +00:00
|
|
|
def __str__(self):
|
|
|
|
return '{} ({})'.format(self.name, self.tier.camp)
|
|
|
|
|
2018-03-04 11:04:07 +00:00
|
|
|
@property
|
|
|
|
def camp(self):
|
|
|
|
return self.tier.camp
|
2017-07-15 09:00:59 +00:00
|
|
|
|
2018-06-20 20:03:29 +00:00
|
|
|
camp_filter = 'tier__camp'
|
|
|
|
|
2018-03-04 14:39:22 +00:00
|
|
|
|
2017-07-15 09:00:59 +00:00
|
|
|
class SponsorTier(CampRelatedModel):
|
|
|
|
name = models.CharField(
|
|
|
|
max_length=25,
|
|
|
|
help_text='Name of the tier (gold, silver, etc.)'
|
|
|
|
)
|
|
|
|
|
|
|
|
description = models.TextField(
|
|
|
|
help_text='A description of what the tier includes.'
|
|
|
|
)
|
|
|
|
|
|
|
|
camp = models.ForeignKey(
|
|
|
|
'camps.Camp',
|
|
|
|
null=True,
|
2018-03-04 15:26:35 +00:00
|
|
|
on_delete=models.PROTECT,
|
2017-07-15 09:00:59 +00:00
|
|
|
related_name='sponsor_tiers',
|
|
|
|
help_text='The camp this sponsor tier belongs to',
|
|
|
|
)
|
|
|
|
|
|
|
|
weight = models.IntegerField(
|
|
|
|
default=0,
|
|
|
|
help_text="""This decides where on the list the tier will be shown. I.e.
|
|
|
|
gold should have a lower value than silver."""
|
|
|
|
)
|
|
|
|
|
2018-08-15 09:30:33 +00:00
|
|
|
tickets = models.IntegerField(
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
|
|
|
help_text="If set this is the number of tickets generated for a sponsor in this tier."
|
|
|
|
)
|
|
|
|
|
2017-07-15 09:00:59 +00:00
|
|
|
def __str__(self):
|
|
|
|
return '{} ({})'.format(self.name, self.camp)
|