TheatreGroup model and getdict complete. rev1

This commit is contained in:
Johnson Chetty 2012-08-20 22:44:18 +02:00
parent 0d68ce2388
commit 3373baf8a4
2 changed files with 24 additions and 5 deletions

View File

@ -267,7 +267,7 @@ class TheatreGroup(ItfModel):
email = models.EmailField(blank=True, null=True) email = models.EmailField(blank=True, null=True)
# location = models.ForeignKey(Location, blank=True, null=True, related_name="theatregroup_location") # location = models.ForeignKey(Location, blank=True, null=True, related_name="theatregroup_location")
tel = models.IntegerField(blank=True, null=True) tel = models.IntegerField(blank=True, null=True)
# -- FIXME tel = models.CharField(blank=True, null=True) # -- FIXME tel = models.CharField(blank=True, null=True)
languages = models.ManyToManyField("Language", blank=True, null=True) languages = models.ManyToManyField("Language", blank=True, null=True)
year_founded = models.IntegerField(blank=True, null=True) year_founded = models.IntegerField(blank=True, null=True)
@ -275,7 +275,7 @@ class TheatreGroup(ItfModel):
awards = generic.GenericRelation("Award") awards = generic.GenericRelation("Award")
buzzitems = generic.GenericRelation("BuzzItem") buzzitems = generic.GenericRelation("BuzzItem")
website = models.URLField(blank=True, verify_exists=False) website = models.URLField(blank=True, verify_exists=False)
# resources = models.ManyToManyField("Resource", blank=True, null=True) resources = models.ManyToManyField("Resource", blank=True, null=True)
locations = generic.GenericRelation("Location"), locations = generic.GenericRelation("Location"),
# locations = models.ManyToManyField("Location", blank=True, null=True, related_name="theatregroup_locations") # locations = models.ManyToManyField("Location", blank=True, null=True, related_name="theatregroup_locations")
nature_of_work = models.ManyToManyField("GroupOccupation", blank=True, null=True, through="GroupGroupOccupation") nature_of_work = models.ManyToManyField("GroupOccupation", blank=True, null=True, through="GroupGroupOccupation")
@ -283,6 +283,7 @@ class TheatreGroup(ItfModel):
#nature_of_work = models.CharField(max_length=255) #nature_of_work = models.CharField(max_length=255)
founded = models.CharField(max_length=10) founded = models.CharField(max_length=10)
trainings = models.ManyToManyField("Training", blank=True, null=True) trainings = models.ManyToManyField("Training", blank=True, null=True)
def __unicode__(self): def __unicode__(self):
@ -291,17 +292,34 @@ class TheatreGroup(ItfModel):
def get_dict(self): def get_dict(self):
return { return {
'name': self.name, 'name': self.name,
'about': self.about,
'email': self.email, 'email': self.email,
'tel':self.tel, 'tel':self.tel,
'nature_of_work': [ obj for obj in self.nature_of_work.all().order_by('groupgroupoccupation__is_main')], 'nature_of_work': [ obj for obj in self.nature_of_work.all().order_by('groupgroupoccupation__is_main')],
'venues': [obj for obj in self.locations], 'venues': [obj for obj in self.locations],
#'trainings': [obj for obj in self.trainings_set.all()] 'trainings': [obj for obj in self.trainings_set.all()],
'languages': [obj.name for obj in self.languages],
'venues': [obj for obj in self.locations],
'founded': year_founded,
'about': self.about,
'awards': [obj for obj in self.awards],
'website': self.website,
'resources': [obj for obj in self.resources],
'buzzitems': [obj for obj in self.buzzitems],
'productions': [obj for obj in self.productions_set.all() ],
'scripts': [obj for obj in self.scripts_set.all() ],
} }
def get_title(self): def get_title(self):
return self.__unicode__() return self.__unicode__()
class Resource():
title = models.CharField(max_length=255, blank=True)
desc = models.TextField(max_length=10000, blank=True, null =True, help_text="Optional Description, 500 words or less")
fil = models.FileField(upload_to='upload/docs', blank=True, null=True)
url = models.URLField(blank=True, null=True, verify_exists=True)
thumbnail= models.ImageField(upload_to='uploads/docs', blank=True, null=True)
class PersonGroup(models.Model): class PersonGroup(models.Model):
person = models.ForeignKey(Person, db_index=True) person = models.ForeignKey(Person, db_index=True)
group = models.ForeignKey(TheatreGroup, db_index=True) group = models.ForeignKey(TheatreGroup, db_index=True)

View File

@ -3,6 +3,7 @@ from django.contrib.auth.models import User
from tagging.fields import TagField from tagging.fields import TagField
from django.core.paginator import Paginator, InvalidPage, EmptyPage from django.core.paginator import Paginator, InvalidPage, EmptyPage
from app.models import ItfModel from app.models import ItfModel
from itfprofiles.models import TheatreGroup
GENRES = ( GENRES = (
('Fiction', 'Fiction'), ('Fiction', 'Fiction'),
@ -41,7 +42,7 @@ class Script(ItfModel):
license_perform = models.ForeignKey("License", related_name="performance_license", help_text="License for performance rights") license_perform = models.ForeignKey("License", related_name="performance_license", help_text="License for performance rights")
fts_fields = ['title', 'synopsis', 'author'] fts_fields = ['title', 'synopsis', 'author']
fk_fields = ['license_adapt', 'license_perform'] fk_fields = ['license_adapt', 'license_perform']
theatre_group = models.ForeignKey("TheatreGroup", help_text="Theatre Group, if any")
# add_form = 'ScriptForm' # add_form = 'ScriptForm'
#Meta #Meta