<s> from django . db import models <EOL> from calaccess_campaign_browser . utils . models import BaseModel <EOL> class Election ( BaseModel ) : <EOL> """<STR_LIT>""" <EOL> ELECTION_TYPE_CHOICES = ( <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ) <EOL> election_type = models . CharField ( <EOL> choices = ELECTION_TYPE_CHOICES , <EOL> max_length = <NUM_LIT:50> <EOL> ) <EOL> year = models . IntegerField ( ) <EOL> date = models . DateField ( null = True , default = None ) <EOL> id_raw = models . IntegerField ( <EOL> verbose_name = "<STR_LIT>" , <EOL> help_text = "<STR_LIT>" <EOL> ) <EOL> sort_index = models . IntegerField ( <EOL> help_text = "<STR_LIT>" , <EOL> ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT>' , ) <EOL> app_label = '<STR_LIT>' <EOL> def __unicode__ ( self ) : <EOL> return self . name <EOL> @ property <EOL> def name ( self ) : <EOL> return u'<STR_LIT>' % ( <EOL> self . year , <EOL> self . get_election_type_display ( ) , <EOL> ) <EOL> @ property <EOL> def office_count ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . candidate_set . values ( "<STR_LIT>" ) . distinct ( ) . count ( ) <EOL> @ property <EOL> def candidate_count ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . candidate_set . count ( ) <EOL> class Office ( BaseModel ) : <EOL> """<STR_LIT>""" <EOL> OFFICE_CHOICES = ( <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ) <EOL> name = models . CharField ( <EOL> choices = OFFICE_CHOICES , <EOL> max_length = <NUM_LIT:50> <EOL> ) <EOL> seat = models . IntegerField ( null = True , default = None ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT:name>' , '<STR_LIT>' , ) <EOL> app_label = '<STR_LIT>' <EOL> def __unicode__ ( self ) : <EOL> s = u'<STR_LIT:%s>' % ( self . get_name_display ( ) , ) <EOL> if self . seat : <EOL> s = u'<STR_LIT>' % ( s , self . seat ) <EOL> return s <EOL> @ property <EOL> def election_count ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . candidate_set . values ( "<STR_LIT>" ) . distinct ( ) . count ( ) <EOL> @ property <EOL> def candidate_count ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . candidate_set . count ( ) <EOL> class Candidate ( BaseModel ) : <EOL> """<STR_LIT>""" <EOL> election = models . ForeignKey ( '<STR_LIT>' ) <EOL> office = models . ForeignKey ( '<STR_LIT>' ) <EOL> filer = models . ForeignKey ( '<STR_LIT>' ) <EOL> class Meta : <EOL> ordering = ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> app_label = '<STR_LIT>' <EOL> def __unicode__ ( self ) : <EOL> return u'<STR_LIT>' % ( self . filer , self . office , self . election ) <EOL> @ property <EOL> def election_year ( self ) : <EOL> return self . election . year <EOL> @ property <EOL> def election_type ( self ) : <EOL> return self . election . get_election_type_display ( ) <EOL> class Proposition ( BaseModel ) : <EOL> """<STR_LIT>""" <EOL> name = models . CharField ( max_length = <NUM_LIT:255> , null = True ) <EOL> description = models . TextField ( blank = True ) <EOL> id_raw = models . IntegerField ( db_index = True ) <EOL> election = models . ForeignKey ( '<STR_LIT>' , null = True , default = None ) <EOL> filers = models . ManyToManyField ( '<STR_LIT>' , through = '<STR_LIT>' ) <EOL> class Meta : <EOL> ordering = ( "<STR_LIT>" , "<STR_LIT:name>" ) <EOL> app_label = '<STR_LIT>' <EOL> def __unicode__ ( self ) : <EOL> return self . name <EOL> @ property <EOL> def short_description ( self , character_limit = <NUM_LIT> ) : <EOL> if len ( self . description ) > character_limit : <EOL> return self . description [ : character_limit ] + "<STR_LIT>" <EOL> return self . description <EOL> class PropositionFiler ( BaseModel ) : <EOL> """<STR_LIT>""" <EOL> POSITION_CHOICES = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> proposition = models . ForeignKey ( '<STR_LIT>' ) <EOL> filer = models . ForeignKey ( '<STR_LIT>' ) <EOL> position = models . CharField ( <EOL> choices = POSITION_CHOICES , <EOL> max_length = <NUM_LIT:50> <EOL> ) <EOL> class Meta : <EOL> app_label = '<STR_LIT>' <EOL> def __unicode__ ( self ) : <EOL> return '<STR_LIT>' % ( self . proposition , self . filer ) </s>
