<s> from django import forms <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from schedule . models import Event , Occurrence <EOL> from schedule . widgets import SpectrumColorPicker <EOL> class SpanForm ( forms . ModelForm ) : <EOL> start = forms . SplitDateTimeField ( label = _ ( "<STR_LIT:start>" ) ) <EOL> end = forms . SplitDateTimeField ( label = _ ( "<STR_LIT:end>" ) , <EOL> help_text = _ ( u"<STR_LIT>" ) ) <EOL> def clean ( self ) : <EOL> if '<STR_LIT:end>' in self . cleaned_data and '<STR_LIT:start>' in self . cleaned_data : <EOL> if self . cleaned_data [ '<STR_LIT:end>' ] <= self . cleaned_data [ '<STR_LIT:start>' ] : <EOL> raise forms . ValidationError ( _ ( u"<STR_LIT>" ) ) <EOL> return self . cleaned_data <EOL> class EventForm ( SpanForm ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( EventForm , self ) . __init__ ( * args , ** kwargs ) <EOL> end_recurring_period = forms . DateTimeField ( label = _ ( u"<STR_LIT>" ) , <EOL> help_text = _ ( u"<STR_LIT>" ) , <EOL> required = False ) <EOL> class Meta ( object ) : <EOL> model = Event <EOL> exclude = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class OccurrenceForm ( SpanForm ) : <EOL> class Meta ( object ) : <EOL> model = Occurrence <EOL> exclude = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> class EventAdminForm ( forms . ModelForm ) : <EOL> class Meta : <EOL> exclude = [ ] <EOL> model = Event <EOL> widgets = { <EOL> '<STR_LIT>' : SpectrumColorPicker , <EOL> } </s>
