2015-07-18 07:09:17 +00:00
|
|
|
from __future__ import unicode_literals
|
2015-09-08 20:07:24 +00:00
|
|
|
|
2012-07-12 04:38:24 +00:00
|
|
|
import datetime
|
|
|
|
|
|
|
|
from django.core.urlresolvers import reverse
|
2015-09-08 20:07:24 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2012-07-12 04:38:24 +00:00
|
|
|
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
|
2015-10-16 17:36:58 +00:00
|
|
|
from symposion.markdown_parser import parse
|
2012-07-12 04:38:24 +00:00
|
|
|
|
|
|
|
|
2015-07-18 07:09:17 +00:00
|
|
|
@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
|
|
|
|
2015-06-26 03:46:09 +00:00
|
|
|
user = models.OneToOneField(User, null=True, related_name="speaker_profile", verbose_name=_("User"))
|
|
|
|
name = models.CharField(verbose_name=_("Name"), max_length=100,
|
|
|
|
help_text=_("As you would like it to appear in the"
|
|
|
|
" conference program."))
|
2015-10-16 17:36:58 +00:00
|
|
|
biography = models.TextField(blank=True, help_text=_("A little bit about you. Edit using "
|
2015-10-17 01:57:18 +00:00
|
|
|
"<a href='http://warpedvisions.org/projects/"
|
|
|
|
"markdown-cheat-sheet/target='_blank'>"
|
|
|
|
"Markdown</a>."), verbose_name=_("Biography"))
|
2015-10-16 17:36:58 +00:00
|
|
|
biography_html = models.TextField(blank=True)
|
2015-06-26 03:46:09 +00:00
|
|
|
photo = models.ImageField(upload_to="speaker_photos", blank=True, verbose_name=_("Photo"))
|
|
|
|
annotation = models.TextField(verbose_name=_("Annotation")) # staff only
|
|
|
|
invite_email = models.CharField(max_length=200, unique=True, null=True, db_index=True, verbose_name=_("Invite_email"))
|
|
|
|
invite_token = models.CharField(max_length=40, db_index=True, verbose_name=_("Invite token"))
|
2012-07-12 04:38:24 +00:00
|
|
|
created = models.DateTimeField(
|
2014-07-30 18:19:26 +00:00
|
|
|
default=datetime.datetime.now,
|
2015-06-26 03:46:09 +00:00
|
|
|
editable=False,
|
|
|
|
verbose_name=_("Created")
|
2012-07-12 04:38:24 +00:00
|
|
|
)
|
2013-04-29 21:00:58 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ['name']
|
2015-06-26 03:46:09 +00:00
|
|
|
verbose_name = _("Speaker")
|
|
|
|
verbose_name_plural = _("Speakers")
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-10-16 17:36:58 +00:00
|
|
|
def save(self, *args, **kwargs):
|
|
|
|
self.biography_html = parse(self.biography)
|
|
|
|
return super(Speaker, self).save(*args, **kwargs)
|
|
|
|
|
2015-07-18 07:09:17 +00:00
|
|
|
def __str__(self):
|
2012-07-12 04:38:24 +00:00
|
|
|
if self.user:
|
|
|
|
return self.name
|
|
|
|
else:
|
2015-07-18 07:09:17 +00:00
|
|
|
return "?"
|
2013-04-29 21:00:58 +00:00
|
|
|
|
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
|