From 993305d182c69ff87cc27d991c2b42d46b1ac672 Mon Sep 17 00:00:00 2001 From: Johnson Chetty Date: Mon, 3 Sep 2012 22:37:57 +0200 Subject: [PATCH] changes made for production, get_dict and model changes.. sql_diff file not tested tho.. --- itf/itfprofiles/models.py | 17 ++- .../modules/itfprofiles/production.html | 115 +++++++++++++++++- migrations/sqldiff030912.sql | 56 +++++++++ 3 files changed, 182 insertions(+), 6 deletions(-) create mode 100644 migrations/sqldiff030912.sql diff --git a/itf/itfprofiles/models.py b/itf/itfprofiles/models.py index 973f1d1..76c5d59 100644 --- a/itf/itfprofiles/models.py +++ b/itf/itfprofiles/models.py @@ -316,27 +316,38 @@ class Production(ItfModel): script = models.ForeignKey(Script, blank=True, null=True) name = models.CharField(max_length=255, db_index=True) synopsis = models.TextField(blank=True) - language = models.ForeignKey("Language", blank=True, null=True) + languages = models.ManyToManyField("Language", blank=True, null=True) group = models.ForeignKey("TheatreGroup", blank=True, null=True) director = models.ForeignKey(Person, related_name='productions_directed', blank=True, null=True) playwright = models.ForeignKey(Person, related_name='productions_authored', blank=True, null=True) anecdotes = models.TextField(blank=True) awards = generic.GenericRelation("Award") + debut_date = models.DateField(blank=True) + reviews= generic.GenericRelation("BuzzItem") def __unicode__(self): return self.name def get_dict(self): + rel_level1 = [obj for obj in Production.objects.filter(script= self.script)] + rel_level2 = list(set(obj.productions_set.all() for obj in self.related_scripts.all())) + return { 'name': self.name, 'anecdotes': self.anecdotes, 'group': self.group, 'director': self.director, - 'playwright': self.playwright + 'playwright': self.playwright, + 'script': self.script, + 'synopsis': self.synopsis, + 'awards': [ obj for obj in self.awards.all()], + 'languages': [ obj for obj in self.languages.all()], + 'debut_date':self.debut_date, + 'sibling_productions': rel_level1, + 'related_productions' : rel_level2, } - SHOWS_NO_CHOICES = ( ('5', '0-5 Shows'), ('10', '6-10 Shows'), diff --git a/itf/templates/modules/itfprofiles/production.html b/itf/templates/modules/itfprofiles/production.html index 208cd0d..5904f0e 100644 --- a/itf/templates/modules/itfprofiles/production.html +++ b/itf/templates/modules/itfprofiles/production.html @@ -1,21 +1,130 @@ Production name: {{ name }} {% if anecdotes %} +
Anecdotes

{{ anecdotes }}

{% endif %} {% if group %} - Group: {{ group.name }}
+Group: {{ group.name }}
{% endif %} {% if director %} - Director: {{ director.get_title }}
+Director: {{ director.get_title }}
{% endif %} {% if playwright %} - Playwright: {{ playwright.get_title }} +Playwright: {{ playwright.get_title }} {% endif %} +{% if languages %} +
+ Languages: + +
+{% endif %}
+ + +{% if awards %} +
+ Awards: + + +
+{% endif %} + + + +{% if buzzitems %} +
+ Buzz Items: + + +
+{% endif %}
+ + +{% if sibling_productions %} +
+ Productions based on the same script: + +
+{% endif %} +
+ +{% if related_productions %} +
+ Productions based on adaptations of the script: + +
+{% endif %} +
+ + Edit diff --git a/migrations/sqldiff030912.sql b/migrations/sqldiff030912.sql new file mode 100644 index 0000000..0b2330a --- /dev/null +++ b/migrations/sqldiff030912.sql @@ -0,0 +1,56 @@ + +DROP TABLE itfprofiles_production; + + +CREATE TABLE `itfprofiles_production_languages` ( + `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, + `production_id` integer NOT NULL, + `language_id` integer NOT NULL, + UNIQUE (`production_id`, `language_id`) +) +; + +CREATE TABLE `itfprofiles_production` ( + `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, + `changed` datetime, + `created` datetime, + `added_by_id` integer NOT NULL, + `script_id` integer, + `name` varchar(255) NOT NULL, + `synopsis` longtext NOT NULL, + `group_id` integer, + `director_id` integer, + `playwright_id` integer, + `anecdotes` longtext NOT NULL, + `debut_date` date NOT NULL +) +; +ALTER TABLE `itfprofiles_production` ADD CONSTRAINT `director_id_refs_id_9fefbcbd` FOREIGN KEY (`director_id`) REFERENCES `itfprofiles_person` (`id`); +ALTER TABLE `itfprofiles_production` ADD CONSTRAINT `playwright_id_refs_id_9fefbcbd` FOREIGN KEY (`playwright_id`) REFERENCES `itfprofiles_person` (`id`); +ALTER TABLE `itfprofiles_production` ADD CONSTRAINT `added_by_id_refs_id_f98027a3` FOREIGN KEY (`added_by_id`) REFERENCES `auth_user` (`id`); +ALTER TABLE `itfprofiles_production` ADD CONSTRAINT `script_id_refs_id_499256c2` FOREIGN KEY (`script_id`) REFERENCES `scriptbank_script` (`id`); +ALTER TABLE `itfprofiles_production` ADD CONSTRAINT `group_id_refs_id_1047a1d6` FOREIGN KEY (`group_id`) REFERENCES `itfprofiles_theatregroup` (`id`); +ALTER TABLE `itfprofiles_production_languages` ADD CONSTRAINT `production_id_refs_id_493fa045` FOREIGN KEY (`production_id`) REFERENCES `itfprofiles_production` (`id`); + + +CREATE TABLE `itfprofiles_award` ( + `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, + `title` varchar(255) NOT NULL, + `year` integer NOT NULL, + `link` varchar(200), + `content_type_id` integer NOT NULL, + `object_id` integer UNSIGNED NOT NULL +) +; +ALTER TABLE `itfprofiles_award` ADD CONSTRAINT `content_type_id_refs_id_8eb1850a` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`); + + + +CREATE INDEX `itfprofiles_production_8d09cb1e` ON `itfprofiles_production` (`added_by_id`); +CREATE INDEX `itfprofiles_production_c0ece17f` ON `itfprofiles_production` (`script_id`); +CREATE INDEX `itfprofiles_production_52094d6e` ON `itfprofiles_production` (`name`); +CREATE INDEX `itfprofiles_production_bda51c3c` ON `itfprofiles_production` (`group_id`); +CREATE INDEX `itfprofiles_production_81c0b88c` ON `itfprofiles_production` (`director_id`); +CREATE INDEX `itfprofiles_production_824a300b` ON `itfprofiles_production` (`playwright_id`); +CREATE INDEX `itfprofiles_personproduction_21b911c5` ON `itfprofiles_personproduction` (`person_id`); +CREATE INDEX `itfprofiles_personproduction_55f55d25` ON `itfprofiles_personproduction` (`production_id`);