<s> from decimal import Decimal <EOL> from django import forms <EOL> from . . models import TransitApp <EOL> from . . utils . slug import slugify <EOL> from . . utils . misc import uniquify <EOL> from . . formfields import AppEngineImageField , LocationListField , AgencyListField <EOL> class EditAppGeneralInfoForm ( forms . Form ) : <EOL> original_slug = forms . CharField ( required = True , widget = forms . widgets . HiddenInput ) <EOL> title = forms . CharField ( max_length = <NUM_LIT:64> , min_length = <NUM_LIT:2> , label = u"<STR_LIT>" ) <EOL> is_featured = forms . BooleanField ( required = False ) <EOL> is_hidden = forms . BooleanField ( required = False ) <EOL> description = forms . CharField ( max_length = <NUM_LIT> , min_length = <NUM_LIT:2> , label = u"<STR_LIT>" ) <EOL> url = forms . URLField ( verify_exists = False , min_length = <NUM_LIT:2> , label = u"<STR_LIT>" ) <EOL> price = forms . DecimalField ( decimal_places = <NUM_LIT:2> , max_digits = <NUM_LIT:6> , min_value = Decimal ( "<STR_LIT>" ) , initial = Decimal ( "<STR_LIT>" ) , label = u"<STR_LIT>" ) <EOL> author_name = forms . CharField ( max_length = <NUM_LIT> , min_length = <NUM_LIT:2> , label = u"<STR_LIT>" ) <EOL> author_email = forms . EmailField ( label = u"<STR_LIT>" ) <EOL> long_description = forms . CharField ( min_length = <NUM_LIT:0> , max_length = <NUM_LIT> , widget = forms . widgets . Textarea ( attrs = { '<STR_LIT>' : <NUM_LIT:6> , '<STR_LIT>' : <NUM_LIT:32> } ) , label = u"<STR_LIT>" ) <EOL> platforms = forms . MultipleChoiceField ( choices = TransitApp . platform_choices ( ) , widget = forms . widgets . CheckboxSelectMultiple ( ) , label = u"<STR_LIT>" ) <EOL> categories = forms . MultipleChoiceField ( choices = TransitApp . category_choices ( ) , widget = forms . widgets . CheckboxSelectMultiple ( ) , initial = [ u"<STR_LIT>" ] , label = u"<STR_LIT>" ) <EOL> tags = forms . CharField ( required = False , max_length = <NUM_LIT> , min_length = <NUM_LIT:0> , label = u"<STR_LIT>" ) <EOL> def clean_title ( self ) : <EOL> if not self . is_unique_slug : <EOL> if self . transit_app_slug != self . cleaned_data [ "<STR_LIT>" ] : <EOL> raise forms . ValidationError ( "<STR_LIT>" ) <EOL> if ( self . transit_app_slug == "<STR_LIT>" ) or ( self . transit_app_slug == "<STR_LIT>" ) : <EOL> raise forms . ValidationError ( "<STR_LIT>" ) <EOL> return self . cleaned_data [ '<STR_LIT:title>' ] <EOL> @ property <EOL> def transit_app_slug ( self ) : <EOL> return slugify ( self . cleaned_data [ '<STR_LIT:title>' ] ) <EOL> @ property <EOL> def is_unique_slug ( self ) : <EOL> return not TransitApp . has_transit_app_for_slug ( self . transit_app_slug ) <EOL> @ property <EOL> def tag_list ( self ) : <EOL> return uniquify ( [ tag . strip ( ) for tag in self . cleaned_data [ '<STR_LIT>' ] . split ( '<STR_LIT:U+002C>' ) ] + self . platform_list + self . category_list ) <EOL> @ property <EOL> def platform_list ( self ) : <EOL> return uniquify ( [ TransitApp . PLATFORMS [ platform_choice ] for platform_choice in self . cleaned_data [ '<STR_LIT>' ] ] ) <EOL> @ property <EOL> def category_list ( self ) : <EOL> return uniquify ( [ TransitApp . CATEGORIES [ category_choice ] for category_choice in self . cleaned_data [ '<STR_LIT>' ] ] ) <EOL> class EditAppAgencyForm ( forms . Form ) : <EOL> gtfs_choice = forms . ChoiceField ( choices = TransitApp . gtfs_choices ( ) , widget = forms . widgets . RadioSelect ( ) , label = u"<STR_LIT>" , initial = "<STR_LIT>" ) <EOL> agency_list = AgencyListField ( required = False , widget = forms . widgets . HiddenInput ) <EOL> class EditAppLocationForm ( forms . Form ) : <EOL> location_list = LocationListField ( required = False , widget = forms . widgets . HiddenInput ) <EOL> available_globally = forms . BooleanField ( required = False , label = u"<STR_LIT>" , widget = forms . widgets . CheckboxInput ( attrs = { '<STR_LIT:id>' : '<STR_LIT>' } ) ) <EOL> class EditAppImagesForm ( forms . Form ) : <EOL> SCREEN_SHOT_COUNT = <NUM_LIT:5> <EOL> SCREEN_SHOT_FIELDS = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> new_shot_1 = AppEngineImageField ( required = False , label = u"<STR_LIT>" ) <EOL> new_shot_2 = AppEngineImageField ( required = False , label = u"<STR_LIT>" ) <EOL> new_shot_3 = AppEngineImageField ( required = False , label = u"<STR_LIT>" ) <EOL> new_shot_4 = AppEngineImageField ( required = False , label = u"<STR_LIT>" ) <EOL> new_shot_5 = AppEngineImageField ( required = False , label = u"<STR_LIT>" ) <EOL> remove_list = forms . CharField ( required = False , widget = forms . widgets . HiddenInput ) <EOL> def clean_remove_list ( self ) : <EOL> remove_list = self . cleaned_data [ "<STR_LIT>" ] <EOL> return [ family . strip ( ) for family in remove_list . split ( '<STR_LIT:|>' ) ] </s>
