<s> import datetime <EOL> from django import forms <EOL> from django . contrib . sites . models import Site <EOL> from django . utils . translation import ugettext as _ <EOL> from . models import Story <EOL> WIDGET_ATTRS = { '<STR_LIT:size>' : '<STR_LIT>' } <EOL> class StoryForm ( forms . ModelForm ) : <EOL> headline = forms . CharField ( <EOL> widget = forms . TextInput ( attrs = WIDGET_ATTRS ) , <EOL> max_length = <NUM_LIT:100> ) <EOL> subhead = forms . CharField ( <EOL> widget = forms . TextInput ( attrs = WIDGET_ATTRS ) , <EOL> max_length = <NUM_LIT:200> , <EOL> required = False ) <EOL> tease_headline = forms . CharField ( <EOL> widget = forms . TextInput ( attrs = WIDGET_ATTRS ) , <EOL> max_length = <NUM_LIT:100> , required = False ) <EOL> kicker = forms . CharField ( <EOL> widget = forms . TextInput ( attrs = WIDGET_ATTRS ) , <EOL> max_length = <NUM_LIT:50> , required = False ) <EOL> non_staff_author = forms . CharField ( <EOL> widget = forms . TextInput ( attrs = WIDGET_ATTRS ) , <EOL> help_text = _ ( '<STR_LIT>' ) , <EOL> max_length = <NUM_LIT:200> , <EOL> required = False ) <EOL> class Meta : <EOL> model = Story <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> initial = kwargs . get ( '<STR_LIT>' , { } ) <EOL> instance = kwargs . get ( '<STR_LIT>' , None ) <EOL> if not instance and not '<STR_LIT>' in initial : <EOL> initial [ '<STR_LIT>' ] = datetime . datetime . now ( ) . date ( ) <EOL> if not instance and not '<STR_LIT>' in initial : <EOL> initial [ '<STR_LIT>' ] = datetime . datetime . now ( ) . time ( ) . strftime ( '<STR_LIT>' ) <EOL> if not instance and not '<STR_LIT>' in initial : <EOL> initial [ '<STR_LIT>' ] = Site . objects . get_current ( ) . id <EOL> kwargs . update ( { '<STR_LIT>' : initial } ) <EOL> super ( StoryForm , self ) . __init__ ( * args , ** kwargs ) <EOL> def clean_slug ( self ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in self . cleaned_data : <EOL> publish_date = self . cleaned_data [ '<STR_LIT>' ] <EOL> try : <EOL> Story . objects . get ( <EOL> slug = self . cleaned_data [ '<STR_LIT>' ] , <EOL> publish_date__year = publish_date . year , <EOL> publish_date__month = publish_date . month , <EOL> publish_date__day = publish_date . day ) <EOL> raise forms . ValidationError ( <EOL> '<STR_LIT>' '<STR_LIT>' . format ( <EOL> publish_date . strftime ( "<STR_LIT>" ) ) ) <EOL> except Story . DoesNotExist : <EOL> pass <EOL> return self . cleaned_data [ '<STR_LIT>' ] </s>
