2016-07-13 17:13:47 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.db import models
|
2016-08-07 13:49:30 +00:00
|
|
|
from django.utils.text import slugify
|
|
|
|
|
2016-07-13 17:13:47 +00:00
|
|
|
from utils.models import CreatedUpdatedModel
|
|
|
|
|
|
|
|
|
|
|
|
class EventType(CreatedUpdatedModel):
|
2016-07-13 19:44:09 +00:00
|
|
|
""" Every event needs to have a type. """
|
2016-07-13 17:13:47 +00:00
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
slug = models.SlugField()
|
2016-08-04 21:03:39 +00:00
|
|
|
color = models.CharField(max_length=50)
|
|
|
|
light_text = models.BooleanField(default=False)
|
2016-07-13 17:13:47 +00:00
|
|
|
|
2016-08-08 19:56:54 +00:00
|
|
|
def __unicode__(self):
|
2016-07-13 20:37:20 +00:00
|
|
|
return self.name
|
|
|
|
|
2016-07-13 17:13:47 +00:00
|
|
|
|
|
|
|
class Event(CreatedUpdatedModel):
|
2016-07-13 19:44:09 +00:00
|
|
|
""" Something that is on the program. """
|
2016-07-13 17:13:47 +00:00
|
|
|
title = models.CharField(max_length=255)
|
2016-08-07 13:49:30 +00:00
|
|
|
slug = models.SlugField(blank=True, max_length=255)
|
|
|
|
abstract = models.TextField()
|
2016-07-13 19:44:09 +00:00
|
|
|
event_type = models.ForeignKey(EventType)
|
2016-08-08 17:47:48 +00:00
|
|
|
days = models.ManyToManyField('camps.Day', blank=True)
|
2016-08-08 17:36:13 +00:00
|
|
|
start = models.TimeField(null=True, blank=True)
|
|
|
|
end = models.TimeField(null=True, blank=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ['title']
|
2016-07-13 19:44:09 +00:00
|
|
|
|
2016-08-08 19:56:54 +00:00
|
|
|
def __unicode__(self):
|
2016-07-13 20:37:20 +00:00
|
|
|
return self.title
|
|
|
|
|
2016-08-07 13:49:30 +00:00
|
|
|
def save(self, **kwargs):
|
|
|
|
if not self.slug:
|
2016-08-08 19:56:54 +00:00
|
|
|
self.slug = slugify(self.title)
|
2016-08-07 13:49:30 +00:00
|
|
|
super(Event, self).save(**kwargs)
|
|
|
|
|
2016-07-13 17:13:47 +00:00
|
|
|
|
|
|
|
class Speaker(CreatedUpdatedModel):
|
2016-07-13 19:44:09 +00:00
|
|
|
""" Person anchoring an event. """
|
2016-07-13 17:13:47 +00:00
|
|
|
name = models.CharField(max_length=150)
|
|
|
|
biography = models.TextField()
|
2016-07-13 19:44:09 +00:00
|
|
|
picture = models.ImageField(null=True, blank=True)
|
2016-08-08 17:36:13 +00:00
|
|
|
slug = models.SlugField(blank=True, max_length=255)
|
2016-07-13 17:13:47 +00:00
|
|
|
events = models.ManyToManyField(
|
|
|
|
Event,
|
|
|
|
related_name='speakers',
|
2016-08-04 21:03:39 +00:00
|
|
|
related_query_name='speaker',
|
|
|
|
blank=True,
|
2016-07-13 19:44:09 +00:00
|
|
|
)
|
2016-07-13 20:37:20 +00:00
|
|
|
|
2016-08-08 17:36:13 +00:00
|
|
|
class Meta:
|
|
|
|
ordering = ['name']
|
|
|
|
|
2016-08-08 19:56:54 +00:00
|
|
|
def __unicode__(self):
|
2016-07-13 20:37:20 +00:00
|
|
|
return self.name
|
2016-08-08 17:36:13 +00:00
|
|
|
|
|
|
|
def save(self, **kwargs):
|
|
|
|
if not self.slug:
|
2016-08-08 19:56:54 +00:00
|
|
|
self.slug = slugify(self.name)
|
2016-08-08 18:15:04 +00:00
|
|
|
super(Speaker, self).save(**kwargs)
|
2016-08-08 17:36:13 +00:00
|
|
|
|