-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
68 lines (59 loc) · 2.38 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from django.db.models import permalink
from django.contrib.auth.models import User
import datetime
import dateutil
class Person(models.Model):
"""Person model."""
first_name = models.CharField(_('first name'), blank=True, max_length=100)
middle_name = models.CharField(_('middle name'), blank=True, max_length=100)
last_name = models.CharField(_('last name'), blank=True, max_length=100)
slug = models.SlugField(_('slug'), unique=True)
user = models.ForeignKey(User, blank=True, null=True)
photo = models.ImageField(_('photo'), upload_to='photos',
blank=True, null=True)
photo_credit = models.CharField(_('photo credit'), blank=True, max_length=200)
role = models.ForeignKey('Role', unique=True)
bio = models.TextField(blank=True)
email = models.EmailField(_('email address'), blank=True, null=True)
website = models.URLField(_('website'), blank=True, verify_exists=True)
class Meta:
verbose_name = _('person')
verbose_name_plural = _('people')
db_table = 'people'
ordering = ('last_name', 'first_name',)
def __unicode__(self):
return u'%s' % self.full_name
@property
def full_name(self):
if self.middle_name:
return u'%s %s %s' % (self.first_name, self.middle_name, self.last_name)
else:
return u'%s %s' % (self.first_name, self.last_name)
@permalink
def get_absolute_url(self):
return ('person_detail', None, {'slug': self.slug})
class Role(models.Model):
ACTING = 0
PRODUCING = 1
MARKETING = 2
DESIGNING = 3
BUILDING = 4
DIRECTING = 5
PRODUCTION_MANAGING = 6
TYPE_CHOICES = (
(ACTING, "Acting"),
(PRODUCING, "Producing"),
(MARKETING, "Marketing"),
(DESIGNING, "Designing"),
(BUILDING, "Building") ,
(DIRECTING, "Directing"),
(PRODUCTION_MANAGING, "Production Managing")
)
type = models.IntegerField(_('type'), choices=TYPE_CHOICES)
position = models.CharField(_('position'), max_length=40)
description = models.TextField(_('description'), blank=True)
def __unicode__(self):
return u'%s: %s' % (self.get_type_display(), self.position)