From ea023e40d38a64934503a293922cca9524eef8bf Mon Sep 17 00:00:00 2001 From: Sanjay B Date: Sun, 3 Feb 2013 03:20:03 +0530 Subject: [PATCH] date widgets, events inline for productions --- itf/events/forms.py | 6 ++++++ itf/events/models.py | 2 +- itf/itfprofiles/forms.py | 20 ++++++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/itf/events/forms.py b/itf/events/forms.py index e2eda16..995df56 100644 --- a/itf/events/forms.py +++ b/itf/events/forms.py @@ -30,3 +30,9 @@ class EventForm(ItfForm): class Meta: model = Event exclude = ('people', 'groups',) + widgets = { + 'start_date': forms.DateInput, + 'end_date': forms.DateInput, + 'start_time': forms.TimeInput, + 'end_time': forms.TimeInput + } diff --git a/itf/events/models.py b/itf/events/models.py index c3687c3..fbba30c 100644 --- a/itf/events/models.py +++ b/itf/events/models.py @@ -25,7 +25,7 @@ class Event(ItfModel): fts_fields = ['title', 'oneliner', 'description'] added_by = models.ForeignKey(User, editable=False, null=True, blank=True) title = models.CharField(max_length=1024) - event_type = models.CharField(choices=EVENT_TYPE_CHOICES, max_length=64) + event_type = models.CharField(choices=EVENT_TYPE_CHOICES, max_length=64, blank=True) oneliner = models.CharField(max_length=1024,help_text="Event slogan/one liner", blank=True) description = models.TextField(blank=True, null=True) parent_event = models.ForeignKey("Event", related_name='child_events', help_text='If this event is part of another event', blank=True, null=True) diff --git a/itf/itfprofiles/forms.py b/itf/itfprofiles/forms.py index eaeedb3..785e84f 100644 --- a/itf/itfprofiles/forms.py +++ b/itf/itfprofiles/forms.py @@ -13,7 +13,7 @@ from imagestore.forms import AlbumForm, ImageForm from itfprofiles.models import * from scriptbank.models import Script #Forms and Inlines for Generic Classes - +from events.models import Event #class AlbumInlineForm(ItfForm, AlbumForm): # pass @@ -68,6 +68,22 @@ class PadmaClipForm(ItfForm): PadmaClipsInline = itf_inlineformset_factory(PadmaClip, extra=1, is_generic=True, form=PadmaClipForm, title="Videos") + +class EventsInlineForm(ItfForm): + parent_event = forms.ModelChoiceField(Event.objects.all(), widget=AutocompleteAddWidget(model_class=Event)) + + class Meta: + model = Event + exclude = ('people', 'groups', 'event_type',) + widgets = { + 'start_date': forms.DateInput, + 'end_date': forms.DateInput, + 'start_time': forms.TimeInput, + 'end_time': forms.TimeInput + } + +EventsInline = itf_inlineformset_factory(Production, Event, extra=2, form=EventsInlineForm, title="Performances", is_generic=False) + #AlbumsInline = itf_inlineformset_factory(Album, extra=1, is_generic=True, form=AlbumInlineForm, title="Photo Albums") @@ -226,7 +242,7 @@ class PersonProductionForm(ItfForm): PersonProductionInline = itf_inlineformset_factory(Production, PersonProduction, form=PersonProductionForm, title="People associated with the production") class ProductionForm(ItfForm): - inlines = [PersonProductionInline, AwardsInline] + inlines = [PersonProductionInline, AwardsInline, EventsInline] script = forms.ModelChoiceField(Script.objects.all(), widget=AutocompleteAddWidget(model_class=Script)) languages = forms.ModelMultipleChoiceField(Language.objects.all(), widget=forms.CheckboxSelectMultiple()) director = forms.ModelChoiceField(Person.objects.all(), widget=AutocompleteAddWidget(model_class=Person))