itf/itf/events/forms.py
2012-08-07 19:59:35 +05:30

31 lines
1.1 KiB
Python

import floppyforms as forms
from models import *
from app.forms import *
from itfprofiles.models import Person, TheatreGroup
class PersonEventForm(ItfForm):
person = forms.ModelChoiceField(Person.objects.all(), widget=AutocompleteAddWidget(model_class=Person))
class Meta:
model = PersonEvent
class GroupEventForm(ItfForm):
group = forms.ModelChoiceField(TheatreGroup.objects.all(), widget=AutocompleteAddWidget(model_class=TheatreGroup))
class Meta:
model = GroupEvent
PersonEventInline = itf_inlineformset_factory(Event, PersonEvent, form=PersonEventForm, extra=1, title="Add / Edit people associated with this event", help_text="select the people that are connected to this event")
GroupEventInline = itf_inlineformset_factory(Event, GroupEvent, form=GroupEventForm, extra=1, title="Add / Edit groups associated with this event", help_text="select the groups that are connected to this event")
class EventForm(ItfForm):
inlines = [PersonEventInline, GroupEventInline]
class Meta:
model = Event
exclude = ('people', 'groups',)