<s> import re <EOL> from django . contrib import admin <EOL> from django import forms <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from comments_spamfighter . models import Keyword <EOL> class KeywordAdminForm ( forms . ModelForm ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( KeywordAdminForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . initial [ '<STR_LIT>' ] = self . instance . fields . split ( '<STR_LIT:U+002C>' ) <EOL> keyword = forms . CharField ( widget = forms . Textarea ( attrs = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:class>' : '<STR_LIT>' } ) ) <EOL> fields = forms . MultipleChoiceField ( label = _ ( '<STR_LIT>' ) , choices = Keyword . FIELD_CHOICES ) <EOL> def clean_fields ( self ) : <EOL> return '<STR_LIT:U+002C>' . join ( self . cleaned_data [ '<STR_LIT>' ] ) <EOL> def clean ( self ) : <EOL> if self . cleaned_data [ '<STR_LIT>' ] : <EOL> try : <EOL> re . match ( self . cleaned_data [ '<STR_LIT>' ] , '<STR_LIT>' , re . MULTILINE ) <EOL> except Exception , e : <EOL> raise forms . ValidationError ( _ ( '<STR_LIT>' % e ) ) <EOL> return self . cleaned_data <EOL> class Meta : <EOL> model = Keyword <EOL> class KeywordAdmin ( admin . ModelAdmin ) : <EOL> form = KeywordAdminForm <EOL> list_display = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> list_display_links = ( '<STR_LIT>' , ) <EOL> list_filter = ( '<STR_LIT>' , ) <EOL> fieldsets = ( <EOL> ( None , { <EOL> '<STR_LIT>' : ( <EOL> '<STR_LIT>' , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' , <EOL> ) <EOL> } , ) , <EOL> ) <EOL> admin . site . register ( Keyword , KeywordAdmin ) </s>
