From 3373baf8a466d33241054c54980cffe1b7a7ecee Mon Sep 17 00:00:00 2001 From: Johnson Chetty Date: Mon, 20 Aug 2012 22:44:18 +0200 Subject: [PATCH] TheatreGroup model and getdict complete. rev1 --- itf/itfprofiles/models.py | 26 ++++++++++++++++++++++---- itf/scriptbank/models.py | 3 ++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/itf/itfprofiles/models.py b/itf/itfprofiles/models.py index 1a6fb74..77df791 100644 --- a/itf/itfprofiles/models.py +++ b/itf/itfprofiles/models.py @@ -267,7 +267,7 @@ class TheatreGroup(ItfModel): email = models.EmailField(blank=True, null=True) # location = models.ForeignKey(Location, blank=True, null=True, related_name="theatregroup_location") 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) year_founded = models.IntegerField(blank=True, null=True) @@ -275,7 +275,7 @@ class TheatreGroup(ItfModel): awards = generic.GenericRelation("Award") buzzitems = generic.GenericRelation("BuzzItem") 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 = models.ManyToManyField("Location", blank=True, null=True, related_name="theatregroup_locations") 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) founded = models.CharField(max_length=10) trainings = models.ManyToManyField("Training", blank=True, null=True) + def __unicode__(self): @@ -291,17 +292,34 @@ class TheatreGroup(ItfModel): def get_dict(self): return { 'name': self.name, - 'about': self.about, 'email': self.email, 'tel':self.tel, 'nature_of_work': [ obj for obj in self.nature_of_work.all().order_by('groupgroupoccupation__is_main')], '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): 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): person = models.ForeignKey(Person, db_index=True) group = models.ForeignKey(TheatreGroup, db_index=True) diff --git a/itf/scriptbank/models.py b/itf/scriptbank/models.py index 1ccfd26..bdf4cd3 100755 --- a/itf/scriptbank/models.py +++ b/itf/scriptbank/models.py @@ -3,6 +3,7 @@ from django.contrib.auth.models import User from tagging.fields import TagField from django.core.paginator import Paginator, InvalidPage, EmptyPage from app.models import ItfModel +from itfprofiles.models import TheatreGroup GENRES = ( ('Fiction', 'Fiction'), @@ -41,7 +42,7 @@ class Script(ItfModel): license_perform = models.ForeignKey("License", related_name="performance_license", help_text="License for performance rights") fts_fields = ['title', 'synopsis', 'author'] fk_fields = ['license_adapt', 'license_perform'] - + theatre_group = models.ForeignKey("TheatreGroup", help_text="Theatre Group, if any") # add_form = 'ScriptForm' #Meta