<s> from django import forms <EOL> from corpus . models import EvidenceLabel <EOL> DEFAULT_LABEL = EvidenceLabel . _meta . get_field ( '<STR_LIT:label>' ) . default <EOL> class EvidenceForm ( forms . ModelForm ) : <EOL> class Meta : <EOL> model = EvidenceLabel <EOL> fields = [ "<STR_LIT:label>" ] <EOL> widgets = { <EOL> '<STR_LIT:label>' : forms . RadioSelect <EOL> } <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> instance = kwargs . get ( '<STR_LIT>' , None ) <EOL> restore_None = False <EOL> if instance and instance . label is None : <EOL> instance . label = DEFAULT_LABEL <EOL> restore_None = True <EOL> super ( ) . __init__ ( * args , ** kwargs ) <EOL> if restore_None : <EOL> self . instance . label = None <EOL> self . fields [ '<STR_LIT:label>' ] . label = '<STR_LIT>' <EOL> def has_changed ( self , * args , ** kwargs ) : <EOL> changed = super ( ) . has_changed ( * args , ** kwargs ) <EOL> if not changed and self . instance . label == DEFAULT_LABEL : <EOL> if EvidenceLabel . objects . get ( pk = self . instance . pk ) . label is None : <EOL> changed = True <EOL> return changed <EOL> class EvidenceOnDocumentForm ( EvidenceForm ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( ) . __init__ ( * args , ** kwargs ) <EOL> f_lbl = self . fields [ '<STR_LIT:label>' ] <EOL> f_lbl . widget = forms . HiddenInput ( ) <EOL> f_lbl . widget . attrs [ '<STR_LIT>' ] = '<STR_LIT>' % self . prefix <EOL> f_lbl . required = False <EOL> class EvidenceToolboxForm ( EvidenceForm ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( ) . __init__ ( * args , ** kwargs ) <EOL> f_lbl = self . fields [ '<STR_LIT:label>' ] <EOL> prev_widget = f_lbl <EOL> f_lbl . widget = forms . RadioSelect ( choices = prev_widget . choices ) <EOL> f_lbl . widget . attrs [ '<STR_LIT>' ] = '<STR_LIT>' </s>
