form widgets / inlines
This commit is contained in:
parent
254c6924a6
commit
40f401b547
|
@ -9,11 +9,17 @@ from crispy_forms.helper import FormHelper
|
||||||
from crispy_forms.layout import Submit
|
from crispy_forms.layout import Submit
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from app.forms import *
|
from app.forms import *
|
||||||
from imagestore.forms import AlbumForm
|
from imagestore.forms import AlbumForm, ImageForm
|
||||||
|
|
||||||
|
|
||||||
#Forms and Inlines for Generic Classes
|
#Forms and Inlines for Generic Classes
|
||||||
|
|
||||||
|
#class AlbumInlineForm(ItfForm, AlbumForm):
|
||||||
|
# pass
|
||||||
|
|
||||||
|
#class ImageInlineForm(ItfForm, ImageForm):
|
||||||
|
# pass
|
||||||
|
|
||||||
class LocationForm(ItfForm):
|
class LocationForm(ItfForm):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -47,7 +53,8 @@ class PadmaClipForm(ItfForm):
|
||||||
|
|
||||||
PadmaClipsInline = itf_inlineformset_factory(PadmaClip, extra=1, is_generic=True, form=PadmaClipForm, title="Videos")
|
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:
|
#Popup Form Classes:
|
||||||
class PopupPersonForm(PopupForm):
|
class PopupPersonForm(PopupForm):
|
||||||
|
@ -73,6 +80,11 @@ class PopupProductionForm(PopupForm):
|
||||||
|
|
||||||
|
|
||||||
#Inline form definitions and inlines for Person form
|
#Inline form definitions and inlines for Person form
|
||||||
|
class PersonOccupationForm(ItfForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = PersonOccupation
|
||||||
|
|
||||||
class ConnectionsForm(ItfForm):
|
class ConnectionsForm(ItfForm):
|
||||||
#ctype = ContentType.objects.get_for_model(Person)
|
#ctype = ContentType.objects.get_for_model(Person)
|
||||||
person2 = forms.ModelChoiceField(Person.objects.all(), widget=AutocompleteAddWidget(model_class=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")
|
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")
|
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")
|
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
|
#Actual person form definition
|
||||||
|
@ -105,7 +118,7 @@ class PersonForm(ItfForm):
|
||||||
# occupations = forms.ModelMultipleChoiceField(Occupation.objects.all(), widget=forms.CheckboxSelectMultiple())
|
# occupations = forms.ModelMultipleChoiceField(Occupation.objects.all(), widget=forms.CheckboxSelectMultiple())
|
||||||
email = forms.EmailField(widget=forms.EmailInput(attrs={'placeholder': 'john@example.com'}))
|
email = forms.EmailField(widget=forms.EmailInput(attrs={'placeholder': 'john@example.com'}))
|
||||||
# inlines = [ConnectionsInline]
|
# inlines = [ConnectionsInline]
|
||||||
inlines = [ConnectionsInline, ProductionsInline, GroupsInline, BuzzItemsInline, AwardsInline, PadmaClipsInline]
|
inlines = [ConnectionsInline, ProductionsInline, GroupsInline, BuzzItemsInline, AwardsInline, PersonOccupationsInline, PadmaClipsInline]
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.helper = FormHelper()
|
self.helper = FormHelper()
|
||||||
|
@ -132,11 +145,20 @@ class GroupPersonForm(ItfForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PersonGroup
|
model = PersonGroup
|
||||||
|
|
||||||
|
class GroupOccupationForm(ItfForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = GroupGroupOccupation
|
||||||
|
|
||||||
|
|
||||||
PersonsInline = itf_inlineformset_factory(TheatreGroup, PersonGroup, form=GroupPersonForm, title="People in the Group")
|
PersonsInline = itf_inlineformset_factory(TheatreGroup, PersonGroup, form=GroupPersonForm, title="People in the Group")
|
||||||
|
|
||||||
class TheatreGroupForm(ItfForm):
|
GroupOccupationsInline = itf_inlineformset_factory(TheatreGroup, GroupGroupOccupation, form=GroupOccupationForm, title="Nature of work for the group")
|
||||||
|
|
||||||
inlines = [PersonsInline, BuzzItemsInline, AwardsInline, LocationsInline, AlbumsInline]
|
|
||||||
|
class TheatreGroupForm(ItfForm):
|
||||||
|
languages = forms.ModelMultipleChoiceField(Language.objects.all(), widget=forms.CheckboxSelectMultiple())
|
||||||
|
inlines = [GroupOccupationsInline, PersonsInline, BuzzItemsInline, AwardsInline, LocationsInline]
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TheatreGroup
|
model = TheatreGroup
|
||||||
|
|
Loading…
Reference in New Issue
Block a user