symposion_app/symposion/speakers/models.py

65 lines
2 KiB
Python
Raw Normal View History

from __future__ import unicode_literals
2012-07-12 04:38:24 +00:00
import datetime
from django.utils.encoding import python_2_unicode_compatible
2012-07-12 04:38:24 +00:00
from django.db import models
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
from markitup.fields import MarkupField
@python_2_unicode_compatible
2012-07-12 04:38:24 +00:00
class Speaker(models.Model):
2014-07-30 18:19:26 +00:00
2012-07-12 04:38:24 +00:00
SESSION_COUNT_CHOICES = [
(1, "One"),
(2, "Two")
]
2014-07-30 18:19:26 +00:00
2012-07-12 04:38:24 +00:00
user = models.OneToOneField(User, null=True, related_name="speaker_profile")
2014-07-30 18:19:26 +00:00
name = models.CharField(max_length=100, help_text=("As you would like it to appear in the "
"conference program."))
biography = MarkupField(blank=True, help_text=("A little bit about you. Edit using "
"<a href='http://warpedvisions.org/projects/"
"markdown-cheat-sheet/target='_blank'>"
"Markdown</a>."))
2012-07-12 04:38:24 +00:00
photo = models.ImageField(upload_to="speaker_photos", blank=True)
annotation = models.TextField() # staff only
2012-07-12 04:38:24 +00:00
invite_email = models.CharField(max_length=200, unique=True, null=True, db_index=True)
invite_token = models.CharField(max_length=40, db_index=True)
created = models.DateTimeField(
2014-07-30 18:19:26 +00:00
default=datetime.datetime.now,
editable=False
2012-07-12 04:38:24 +00:00
)
class Meta:
ordering = ['name']
2014-07-30 18:19:26 +00:00
def __str__(self):
2012-07-12 04:38:24 +00:00
if self.user:
return self.name
else:
return "?"
2012-07-12 04:38:24 +00:00
def get_absolute_url(self):
return reverse("speaker_edit")
2014-07-30 18:19:26 +00:00
2012-07-12 04:38:24 +00:00
@property
def email(self):
if self.user is not None:
return self.user.email
else:
return self.invite_email
2014-07-30 18:19:26 +00:00
2012-12-20 06:51:52 +00:00
@property
def all_presentations(self):
presentations = []
if self.presentations:
for p in self.presentations.all():
presentations.append(p)
for p in self.copresentations.all():
presentations.append(p)
return presentations