From 40f401b5471590ffd00af04dedc94af2ceb6faaf Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 31 Aug 2012 17:37:59 +0530 Subject: [PATCH] form widgets / inlines --- itf/itfprofiles/forms.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/itf/itfprofiles/forms.py b/itf/itfprofiles/forms.py index 1897c5a..c1aada0 100644 --- a/itf/itfprofiles/forms.py +++ b/itf/itfprofiles/forms.py @@ -9,11 +9,17 @@ from crispy_forms.helper import FormHelper from crispy_forms.layout import Submit from django.contrib.contenttypes.models import ContentType from app.forms import * -from imagestore.forms import AlbumForm +from imagestore.forms import AlbumForm, ImageForm #Forms and Inlines for Generic Classes +#class AlbumInlineForm(ItfForm, AlbumForm): +# pass + +#class ImageInlineForm(ItfForm, ImageForm): +# pass + class LocationForm(ItfForm): class Meta: @@ -47,7 +53,8 @@ class PadmaClipForm(ItfForm): PadmaClipsInline = itf_inlineformset_factory(PadmaClip, extra=1, is_generic=True, form=PadmaClipForm, title="Videos") -AlbumsInline = itf_inlineformset_factory(Album, extra=1, is_generic=True, form=AlbumForm, title="Photo Albums") +#AlbumsInline = itf_inlineformset_factory(Album, extra=1, is_generic=True, form=AlbumInlineForm, title="Photo Albums") + #Popup Form Classes: class PopupPersonForm(PopupForm): @@ -73,6 +80,11 @@ class PopupProductionForm(PopupForm): #Inline form definitions and inlines for Person form +class PersonOccupationForm(ItfForm): + + class Meta: + model = PersonOccupation + class ConnectionsForm(ItfForm): #ctype = ContentType.objects.get_for_model(Person) person2 = forms.ModelChoiceField(Person.objects.all(), widget=AutocompleteAddWidget(model_class=Person)) @@ -96,6 +108,7 @@ class PersonGroupForm(ItfForm): ConnectionsInline = itf_inlineformset_factory(Person, PersonPerson, fk_name='person1', form=ConnectionsForm, extra=1, title="Add / Edit Connections", help_text="select the people you are connected with and how you are related in the theatre world") ProductionsInline = itf_inlineformset_factory(Person, PersonProduction, form=PersonProductionForm, extra=1, title="Productions you have worked in") GroupsInline = itf_inlineformset_factory(Person, PersonGroup, extra=1, form=PersonGroupForm, title="Theatre groups you are a part of or have worked with") +PersonOccupationsInline = itf_inlineformset_factory(Person, PersonOccupation, extra=1, form=PersonOccupationForm, title="Select your occupation / you can add as many as you like") #Actual person form definition @@ -105,7 +118,7 @@ class PersonForm(ItfForm): # occupations = forms.ModelMultipleChoiceField(Occupation.objects.all(), widget=forms.CheckboxSelectMultiple()) email = forms.EmailField(widget=forms.EmailInput(attrs={'placeholder': 'john@example.com'})) # inlines = [ConnectionsInline] - inlines = [ConnectionsInline, ProductionsInline, GroupsInline, BuzzItemsInline, AwardsInline, PadmaClipsInline] + inlines = [ConnectionsInline, ProductionsInline, GroupsInline, BuzzItemsInline, AwardsInline, PersonOccupationsInline, PadmaClipsInline] def __init__(self, *args, **kwargs): self.helper = FormHelper() @@ -132,11 +145,20 @@ class GroupPersonForm(ItfForm): class Meta: model = PersonGroup +class GroupOccupationForm(ItfForm): + + class Meta: + model = GroupGroupOccupation + + PersonsInline = 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") + + class TheatreGroupForm(ItfForm): - - inlines = [PersonsInline, BuzzItemsInline, AwardsInline, LocationsInline, AlbumsInline] + languages = forms.ModelMultipleChoiceField(Language.objects.all(), widget=forms.CheckboxSelectMultiple()) + inlines = [GroupOccupationsInline, PersonsInline, BuzzItemsInline, AwardsInline, LocationsInline] class Meta: model = TheatreGroup