bornhack-website/camps/models.py

61 lines
1.6 KiB
Python
Raw Normal View History

import datetime
2015-10-03 01:07:05 +00:00
from django.db import models
from utils.models import UUIDModel, CreatedUpdatedModel
from program.models import EventType
from django.contrib.postgres.fields import DateTimeRangeField
2015-10-03 01:07:05 +00:00
class Camp(CreatedUpdatedModel, UUIDModel):
class Meta:
verbose_name = 'Camp'
verbose_name_plural = 'Camps'
2015-10-03 01:07:05 +00:00
title = models.CharField(
verbose_name='Title',
help_text='Title of the camp, ie. Bornhack 2016.',
2015-10-03 01:07:05 +00:00
max_length=255,
)
tagline = models.CharField(
verbose_name='Tagline',
help_text='Tagline of the camp, ie. "Initial Commit"',
max_length=255,
2015-10-03 01:07:05 +00:00
)
slug = models.SlugField(
verbose_name='Url Slug',
help_text='The url slug to use for this camp'
2015-10-03 01:07:05 +00:00
)
buildup = DateTimeRangeField(
verbose_name='Buildup Period',
help_text='The camp buildup period.',
2016-05-06 20:33:59 +00:00
)
camp = DateTimeRangeField(
verbose_name='Camp Period',
help_text='The camp period.',
)
teardown = DateTimeRangeField(
verbose_name='Teardown period',
help_text='The camp teardown period.',
)
def __unicode__(self):
return "%s - %s" % (self.title, self.tagline)
2016-07-13 19:44:09 +00:00
@property
def event_types(self):
# return all event types with at least one event in this camp
return EventType.objects.filter(event__instances__isnull=False, event__camp=self).distinct()
2015-10-03 01:07:05 +00:00
@property
def logo_small(self):
return 'img/%(slug)s/logo/%(slug)s-logo-small.png' % {'slug': self.slug}
2015-10-03 01:07:05 +00:00
@property
def logo_large(self):
return 'img/%(slug)s/logo/%(slug)s-logo-large.png' % {'slug': self.slug}