changes made for production, get_dict and model changes.. sql_diff file not tested tho..

This commit is contained in:
Johnson Chetty 2012-09-03 22:37:57 +02:00
parent 74eb21627e
commit 993305d182
3 changed files with 182 additions and 6 deletions

View File

@ -316,27 +316,38 @@ class Production(ItfModel):
script = models.ForeignKey(Script, blank=True, null=True) script = models.ForeignKey(Script, blank=True, null=True)
name = models.CharField(max_length=255, db_index=True) name = models.CharField(max_length=255, db_index=True)
synopsis = models.TextField(blank=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) group = models.ForeignKey("TheatreGroup", blank=True, null=True)
director = models.ForeignKey(Person, related_name='productions_directed', 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) playwright = models.ForeignKey(Person, related_name='productions_authored', blank=True, null=True)
anecdotes = models.TextField(blank=True) anecdotes = models.TextField(blank=True)
awards = generic.GenericRelation("Award") awards = generic.GenericRelation("Award")
debut_date = models.DateField(blank=True)
reviews= generic.GenericRelation("BuzzItem")
def __unicode__(self): def __unicode__(self):
return self.name return self.name
def get_dict(self): 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 { return {
'name': self.name, 'name': self.name,
'anecdotes': self.anecdotes, 'anecdotes': self.anecdotes,
'group': self.group, 'group': self.group,
'director': self.director, '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 = ( SHOWS_NO_CHOICES = (
('5', '0-5 Shows'), ('5', '0-5 Shows'),
('10', '6-10 Shows'), ('10', '6-10 Shows'),

View File

@ -1,6 +1,7 @@
<span class="orange">Production name: </span> {{ name }} <span class="orange">Production name: </span> {{ name }}
{% if anecdotes %} {% if anecdotes %}
<div class="orange">Anecdotes</div> <div class="orange">Anecdotes</div>
<p>{{ anecdotes }}</p> <p>{{ anecdotes }}</p>
{% endif %} {% endif %}
@ -17,5 +18,113 @@
<span class="orange">Playwright: </span><a href="{{ playwright.get_absolute_url }}">{{ playwright.get_title }}</a> <span class="orange">Playwright: </span><a href="{{ playwright.get_absolute_url }}">{{ playwright.get_title }}</a>
{% endif %} {% endif %}
{% if languages %}
<div id="" class="">
<span class="orange">Languages: </span>
<ul>
{% for elem in languages %}
<li>
{{ elem.name }}
</li>
{% endfor %}
</ul>
</div>
{% endif %} <br/>
{% if awards %}
<div id="" class="">
<span class="orange">Awards: </span>
<ul>
{% for elem in awards %}
<li>
{% if elem.link %}
<a href="{{ elem.link }}">
{% endif %}
{{ elem.title }}
{% if elem.link %}
</a>
{% endif %}
{% if elem.year %}
{{ elem.year }}
{% endif %}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% if buzzitems %}
<div id="" class="">
<span class="orange">Buzz Items: </span>
<ul>
{% for elem in buzzitems %}
<li>
{% if elem.link %}
<a href={{ elem.link }}> {{ elem.title }}>
{% endif %}
{% if elem.link %}
</a>
{% endif %}
<br/> <br/>
Desc: {{ elem.blurb }}
<br/>
Type:{{ elem.typ }}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<br />
{% if sibling_productions %}
<div id="" class="">
<span class="orange">Productions based on the same script: </span>
<ul>
{% for elem in sibling_productions %}
<li>
{% if elem.get_absolute_url %}
<a href={{ elem.get_absolute_url }}> {{ elem.name }}>
{% endif %}
{% if elem.get_absolute_url %}
</a>
{% endif %}
<br/>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<br />
{% if related_productions %}
<div id="" class="">
<span class="orange">Productions based on adaptations of the script: </span>
<ul>
{% for elem in related_productions %}
<li>
{% if elem.get_absolute_url %}
<a href={{ elem.get_absolute_url }}> {{ elem.name }}>
{% endif %}
{% if elem.get_absolute_url %}
</a>
{% endif %}
<br/>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<br />
<a href="{{ edit_url }}">Edit</a> <a href="{{ edit_url }}">Edit</a>

View File

@ -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`);