From 75ec1aa0ccc2d885a7d6669a18ff26ec5be5cb9e Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 2 Sep 2012 16:53:21 +0530 Subject: [PATCH] Production form inline for people and widget for Script --- itf/itfprofiles/forms.py | 18 +++++++++++++----- itf/scriptbank/forms.py | 8 ++++++++ itf/scriptbank/models.py | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/itf/itfprofiles/forms.py b/itf/itfprofiles/forms.py index 3278ae1..0ef5cb3 100644 --- a/itf/itfprofiles/forms.py +++ b/itf/itfprofiles/forms.py @@ -11,7 +11,7 @@ from django.contrib.contenttypes.models import ContentType from app.forms import * from imagestore.forms import AlbumForm, ImageForm from itfprofiles.models import * - +from scriptbank.models import Script #Forms and Inlines for Generic Classes #class AlbumInlineForm(ItfForm, AlbumForm): @@ -152,14 +152,14 @@ class GroupOccupationForm(ItfForm): model = GroupGroupOccupation -PersonsInline = itf_inlineformset_factory(TheatreGroup, PersonGroup, form=GroupPersonForm, title="People in the Group") +PersonGroupInline = itf_inlineformset_factory(TheatreGroup, PersonGroup, form=GroupPersonForm, title="People in the Group") -GroupOccupationsInline = itf_inlineformset_factory(TheatreGroup, GroupGroupOccupation, form=GroupOccupationForm, title="Nature of work for the group") +GroupOccupationInline = itf_inlineformset_factory(TheatreGroup, GroupGroupOccupation, form=GroupOccupationForm, title="Nature of work for the group") class TheatreGroupForm(ItfForm): languages = forms.ModelMultipleChoiceField(Language.objects.all(), widget=forms.CheckboxSelectMultiple()) - inlines = [GroupOccupationsInline, PersonsInline, BuzzItemsInline, AwardsInline, LocationsInline] + inlines = [GroupOccupationInline, PersonGroupInline, BuzzItemsInline, AwardsInline, LocationsInline] class Meta: model = TheatreGroup @@ -168,9 +168,17 @@ class TheatreGroupForm(ItfForm): #Inline definitions and form for Production +class PersonProductionForm(ItfForm): + person = forms.ModelChoiceField(Person.objects.all(), widget=AutocompleteAddWidget(model_class=Person)) + + class Meta: + model = PersonProduction + +PersonProductionInline = itf_inlineformset_factory(Production, PersonProduction, form=PersonProductionForm, title="People associated with the production") class ProductionForm(ItfForm): - inlines = [] + inlines = [PersonProductionInline] + script = forms.ModelChoiceField(Script.objects.all(), widget=AutocompleteAddWidget(model_class=Script)) director = forms.ModelChoiceField(Person.objects.all(), widget=AutocompleteAddWidget(model_class=Person)) playwright = forms.ModelChoiceField(Person.objects.all(), widget=AutocompleteAddWidget(model_class=Person)) group = forms.ModelChoiceField(TheatreGroup.objects.all(), widget=AutocompleteAddWidget(model_class=TheatreGroup)) diff --git a/itf/scriptbank/forms.py b/itf/scriptbank/forms.py index 28f5a2b..cdf6724 100755 --- a/itf/scriptbank/forms.py +++ b/itf/scriptbank/forms.py @@ -8,3 +8,11 @@ class ScriptForm(ItfForm): class Meta: model = Script exclude = ('added_by',) + + +class PopupScriptForm(PopupForm): + + class Meta: + model = Script + #fields = ('name', 'email',) + diff --git a/itf/scriptbank/models.py b/itf/scriptbank/models.py index 046163e..567f408 100755 --- a/itf/scriptbank/models.py +++ b/itf/scriptbank/models.py @@ -24,7 +24,7 @@ LANGUAGE_CHOICES = ( class Script(ItfModel): added_by = models.ForeignKey(User) - form_names = ['ScriptForm'] + form_names = ['ScriptForm', 'PopupScriptForm'] main_form = 'ScriptForm' title = models.CharField(max_length=255) synopsis = models.TextField(blank=True)