from django.db import models from django.contrib.auth.models import User import datetime from fields import MultiSelectField, MultiSelectFormField import multilingual from django.utils.translation import ugettext as _ EVENT_TYPES = ( ('workshop', 'Workshop'), ('seminar', 'Seminar'), ('exhibition', 'Exhibition'), ('course', 'Course / Training'), ('other', 'Other'), ) OCCUPATION_TYPES = ( ('make_up_artist', 'Make-up Artist'), ('director', 'Director'), ('actor', 'Actor'), ('other', 'Other'), ) FILE_TYPES = ( ('audio', 'Audio'), ('video', 'Video'), ('pdf', 'PDF'), ('text', 'Text Document'), ('other', 'Other'), ) PP_RELATION_TYPES = ( ('friend', 'Friend'), ('worked_under', 'Worked Under'), ('worked_with', 'Worked with'), ('directed', 'Directed'), ('fanof', 'Fan Of'), ('other', 'Other'), ) PG_RELATION_TYPES = ( ('member', 'Member'), ('admin', 'Admin'), ('fan', 'Fan'), ('other', 'Other'), ) class Script(models.Model): author = models.CharField(max_length=255) downloads = models.ManyToManyField('File', blank=True) links = models.ManyToManyField('Link', blank=True) language = models.CharField(max_length=50, blank=True) class Translation(multilingual.Translation): title = models.CharField(max_length=255) synopsis = models.TextField(blank=True) def __unicode__(self): return self.title class ProfileProduction(models.Model): profile = models.ForeignKey('Profile') production = models.ForeignKey('Production') role = models.CharField(max_length=255) is_approved = models.BooleanField(default=False) is_original = models.BooleanField(default=False) def __unicode__(self): return self.role class Meta: verbose_name = 'Peoples Role in Production' class Production(models.Model): title = models.CharField(max_length=255) description = models.TextField(blank=True) author = models.ForeignKey('Profile', related_name="AuthoredProduction") director = models.ForeignKey('Profile', related_name="DirectedProduction") cast = models.ManyToManyField('Profile', through='ProfileProduction', blank=True, symmetrical=False) theatregroup = models.ForeignKey('TheatreGroup', blank=True, null=True, verbose_name="Theatre Group") script = models.ForeignKey('Script', blank=True, null=True) images = models.ManyToManyField('Image', blank=True) files = models.ManyToManyField('File', blank=True) links = models.ManyToManyField('Link', blank=True) language = models.CharField(max_length=50, blank=True) slug = models.SlugField() def get_absolute_url(self): return "/production/" + str(self.id) def __unicode__(self): return self.title #class Nickname2(models.Model): # name = models.CharField('Nick2', max_length=255, blank=True) ## nick_profile = models.ForeignKey('Profile') # def __unicode__(self): # return self.name #class Nickname3(models.Model): # name = models.CharField('Nick3', max_length=255, blank=True) ## nick_profile = models.ForeignKey('Profile') # def __unicode__(self): # return self.name class Nickname(models.Model): name = models.CharField('Nick', max_length=255, blank=True) profile = models.ForeignKey('Profile') def __unicode__(self): return self.name class Profile(models.Model): user = models.ForeignKey(User, blank=True, unique=True, null=True) phone = models.CharField(max_length=255, blank=True) email = models.CharField(max_length=255, blank=True, db_index=True) groups = models.ManyToManyField('TheatreGroup', through='ProfileGroup', blank=True, symmetrical=False) occupation = MultiSelectField(max_length=1000, choices=OCCUPATION_TYPES, verbose_name="Occupation Type", blank=True) connections = models.ManyToManyField('Profile', through='ProfileProfile', blank=True, symmetrical=False) profile_image = models.ForeignKey('Image', blank=True, null=True, related_name="profile_image") dob = models.DateField(blank=True, verbose_name="DoB", null=True) location = models.ForeignKey('Location', blank=True, null=True) images = models.ManyToManyField('Image', blank=True) files = models.ManyToManyField('File', blank=True) links = models.ManyToManyField('Link', blank=True) related_productions = models.ManyToManyField('Production', blank=True, null=True) # nickname = models.ForeignKey(Nickname, blank=True, null=True) # nickname2 = models.ForeignKey('Nickname2', related_name="MyNick", blank=True) # nickname3 = models.ManyToManyField('Nickname3', blank=True) class Translation(multilingual.Translation): firstname = models.CharField(max_length=255, verbose_name=_("First Name")) lastname = models.CharField(max_length=255, blank=True, verbose_name=_("Last Name")) about = models.TextField(blank=True) def __unicode__(self): return self.firstname + " " + self.lastname class Venue(models.Model): name = models.CharField(max_length=255) location = models.ForeignKey('Location') images = models.ManyToManyField('Image', blank=True) links = models.ManyToManyField('Link', blank=True) slug = models.SlugField() def __unicode__(self): return self.name class Performance(models.Model): production = models.ForeignKey('Production') venue = models.ForeignKey('Venue', blank=True, null=True) datetime = models.DateTimeField(verbose_name="Date & Time", blank=True, null=True) ticketslink = models.URLField(max_length=255, blank=True, verbose_name="Tickets link") images = models.ManyToManyField('Image', blank=True) links = models.ManyToManyField('Link', blank=True) def __unicode__(self): return self.production class Meta: get_latest_by = "datetime" class Event(models.Model): title = models.CharField(max_length=255, blank=True) synopsis = models.TextField(blank=True) venue = models.ForeignKey('Venue') theatregroup = models.ForeignKey('TheatreGroup', blank=True, null=True, verbose_name="Theatre Group") time = models.DateTimeField(blank=True, null=True) eventtype = models.CharField(max_length=255, choices=EVENT_TYPES, verbose_name="Event Type") links = models.ManyToManyField('Link', blank=True) cost = models.CharField(max_length=255, blank=True) language = models.ForeignKey("Language", blank=True, null=True) def __unicode__(self): return self.title class Language(models.Model): name = models.CharField(max_length=100) short_name = models.CharField(max_length=3) class Location(models.Model): address = models.TextField(blank=True) lat = models.CharField(max_length=255, blank=True, verbose_name="Latitude", editable=False) lon = models.CharField(max_length=255, blank=True, verbose_name="Longitude", editable=False) def __unicode__(self): return self.address class ProfileProfile(models.Model): fromProfile = models.ForeignKey('Profile', related_name='relatedFrom', verbose_name="From Profile") toProfile = models.ForeignKey('Profile', related_name='relatedTo', verbose_name="To Profile") rel_type = MultiSelectField(max_length=1000, choices=PP_RELATION_TYPES, verbose_name="Relation Type") is_approved = models.BooleanField(default=False) class Meta: verbose_name = 'Person to Person Relation' class TheatreGroup(models.Model): name = models.CharField(max_length=255) about = models.TextField(blank=True) location = models.ManyToManyField('Location', blank=True) images = models.ManyToManyField('Image', blank=True) files = models.ManyToManyField('File', blank=True) links = models.ManyToManyField('Link', blank=True) slug = models.SlugField() def __unicode__(self): return self.name class ProfileGroup(models.Model): profile = models.ForeignKey('Profile') group = models.ForeignKey('TheatreGroup') rel_type = MultiSelectField(max_length=1000, choices=PG_RELATION_TYPES, verbose_name="Relation Type") is_approved = models.BooleanField(default=False) is_admin = models.BooleanField(default=False) class Meta: verbose_name = 'Person to Theatre Group Relation' class Image(models.Model): image = models.ImageField(upload_to='/profiles/', width_field='width', height_field='height', null=False) width = models.IntegerField(editable=False) height = models.IntegerField(editable=False) caption = models.CharField(max_length=255, blank=True) def __unicode__(self): if self.caption: return self.caption else: return self.path class File(models.Model): file = models.FileField(upload_to='/uploads/') file_type = models.CharField(max_length=255, choices=FILE_TYPES, verbose_name="File Type") description = models.TextField(blank=True) def __unicode__(self): return self.caption class RandomQuote(models.Model): quote = models.TextField() author = models.CharField(max_length=255) class Link(models.Model): url = models.URLField() caption = models.CharField(max_length=255, blank=True) # related_profile = models.ForeignKey(Profile) def __unicode__(self): if self.caption: return self.caption else: return self.url