related_scripts(), related_people, worked_with_people model methods added

This commit is contained in:
Johnson Chetty 2013-01-02 19:06:39 +01:00
parent 82e75e0fc3
commit 77573f8252
2 changed files with 39 additions and 0 deletions

View File

@ -104,6 +104,13 @@ class Person(ItfModel):
'resources': self.resources.all()
}
def related_scripts(self):
prod_scripts = [ p.script for p in self.productions.all() ]
prod_scripts.extend( [ p.script for p in self.productions_authored.all() ] )
prod_scripts.extend( [ p.script for p in self.productions_directed.all() ] )
#auth_scripts = Script.objects.filter(author__iexact=)
return prod_scripts
OCCUPATION_TYPES = (
@ -349,6 +356,15 @@ class TheatreGroup(ItfModel):
'people' : [obj for obj in self.persongroup_set.all() ],
}
def worked_with_people(self):
people = []
for p in self.production_set.all():
if p.get_people():
people.extend(p.get_people())
#script_auths = [ {"person":s.author, "role":"author","assoc_type":'script', "assoc_name":s.title } for s in self.script_set.all() ]
return people
def get_title(self):
return self.__unicode__()
@ -395,6 +411,17 @@ class Production(ItfModel):
def __unicode__(self):
return self.name
def get_people(self):
persons = [{"person":self.director, "role":"director", "assoc_type":'production', "assoc_name":self.name },
{"person":self.playwright, "role":"playwright", "assoc_type":'production', "assoc_name":self.name }
]
cast_list=[]
for p in self.personproduction_set.all():
cast_list.append({"person":p.person, "role":p.role, "assoc_type":'production', "assoc_name":self.name})
if cast_list:
persons.extend(cast_list)
return persons
def get_dict(self):
rel_level1 = [obj for obj in Production.objects.filter(script=self.script)]
rel_level2 = list(set(obj.production_set.all() for obj in self.script.related_scripts.all()))

View File

@ -89,6 +89,18 @@ class Script(ItfModel):
'productions': self.production_set.all(),
'related_scripts': self.related_scripts
}
def related_people(self):
people = []
for p in self.production_set.all():
if p.get_people():
people.extend(p.get_people())
script_auths = [ {"person":s.author, "role":"author", "assoc_type":"related_script", "assoc_name":s.title } for s in self.related_scripts.all() ]
if script_auths:
people.extend(script_auths)
return people
SCRIPT_RELATIONS = (
('adaptation', 'Adaptation Of'),