<s> """<STR_LIT>""" <EOL> from django import forms <EOL> from django . utils . translation import ugettext as _ <EOL> from . import settings <EOL> from . models import Tag <EOL> from . utils import parse_tag_input <EOL> class TagAdminForm ( forms . ModelForm ) : <EOL> class Meta : <EOL> model = Tag <EOL> fields = '<STR_LIT>' <EOL> def clean_name ( self ) : <EOL> value = self . cleaned_data [ '<STR_LIT:name>' ] <EOL> tag_names = parse_tag_input ( value ) <EOL> if len ( tag_names ) > <NUM_LIT:1> : <EOL> raise forms . ValidationError ( _ ( '<STR_LIT>' ) ) <EOL> elif len ( tag_names [ <NUM_LIT:0> ] ) > settings . MAX_TAG_LENGTH : <EOL> raise forms . ValidationError ( <EOL> _ ( '<STR_LIT>' ) % <EOL> settings . MAX_TAG_LENGTH ) <EOL> return value <EOL> class TagField ( forms . CharField ) : <EOL> """<STR_LIT>""" <EOL> def clean ( self , value ) : <EOL> value = super ( TagField , self ) . clean ( value ) <EOL> if value == '<STR_LIT>' : <EOL> return value <EOL> for tag_name in parse_tag_input ( value ) : <EOL> if len ( tag_name ) > settings . MAX_TAG_LENGTH : <EOL> raise forms . ValidationError ( <EOL> _ ( '<STR_LIT>' ) % <EOL> settings . MAX_TAG_LENGTH ) <EOL> return value </s>
