<s> from django . db import models <EOL> from calaccess_campaign_browser import managers <EOL> from django . utils . datastructures import SortedDict <EOL> from calaccess_campaign_browser . utils . models import BaseModel <EOL> class Contribution ( BaseModel ) : <EOL> """<STR_LIT>""" <EOL> cycle = models . ForeignKey ( '<STR_LIT>' ) <EOL> committee = models . ForeignKey ( <EOL> '<STR_LIT>' , <EOL> related_name = "<STR_LIT>" <EOL> ) <EOL> filing = models . ForeignKey ( '<STR_LIT>' ) <EOL> filing_id_raw = models . IntegerField ( db_index = True ) <EOL> transaction_id = models . CharField ( <EOL> '<STR_LIT>' , <EOL> max_length = <NUM_LIT:20> , <EOL> db_index = True <EOL> ) <EOL> amend_id = models . IntegerField ( '<STR_LIT>' , db_index = True ) <EOL> backreference_transaction_id = models . CharField ( <EOL> '<STR_LIT>' , <EOL> max_length = <NUM_LIT:20> , <EOL> blank = True , <EOL> default = '<STR_LIT>' , <EOL> db_index = True <EOL> ) <EOL> is_crossreference = models . CharField ( max_length = <NUM_LIT:1> , blank = True ) <EOL> crossreference_schedule = models . CharField ( max_length = <NUM_LIT:2> , blank = True ) <EOL> is_duplicate = models . BooleanField ( default = False ) <EOL> transaction_type = models . CharField ( max_length = <NUM_LIT:1> , blank = True ) <EOL> date_received = models . DateField ( null = True ) <EOL> contribution_description = models . CharField ( max_length = <NUM_LIT> , blank = True ) <EOL> amount = models . DecimalField ( decimal_places = <NUM_LIT:2> , max_digits = <NUM_LIT> ) <EOL> contributor_full_name = models . CharField ( max_length = <NUM_LIT:255> ) <EOL> contributor_is_person = models . BooleanField ( default = False ) <EOL> contributor_committee = models . ForeignKey ( <EOL> '<STR_LIT>' , <EOL> null = True , <EOL> related_name = "<STR_LIT>" <EOL> ) <EOL> contributor_prefix = models . CharField ( max_length = <NUM_LIT:10> , blank = True ) <EOL> contributor_first_name = models . CharField ( max_length = <NUM_LIT:255> , blank = True ) <EOL> contributor_last_name = models . CharField ( max_length = <NUM_LIT:200> , blank = True ) <EOL> contributor_suffix = models . CharField ( max_length = <NUM_LIT:10> , blank = True ) <EOL> contributor_address_1 = models . CharField ( max_length = <NUM_LIT> , blank = True ) <EOL> contributor_address_2 = models . CharField ( max_length = <NUM_LIT> , blank = True ) <EOL> contributor_city = models . CharField ( max_length = <NUM_LIT:30> , blank = True ) <EOL> contributor_state = models . CharField ( max_length = <NUM_LIT:2> , blank = True ) <EOL> contributor_zipcode = models . CharField ( max_length = <NUM_LIT:10> , blank = True ) <EOL> contributor_occupation = models . CharField ( max_length = <NUM_LIT> , blank = True ) <EOL> contributor_employer = models . CharField ( max_length = <NUM_LIT:200> , blank = True ) <EOL> contributor_selfemployed = models . CharField ( max_length = <NUM_LIT:1> , blank = True ) <EOL> ENTITY_CODE_CHOICES = ( <EOL> ( "<STR_LIT>" , "<STR_LIT:None>" ) , <EOL> ( "<STR_LIT:0>" , "<STR_LIT:0>" ) , <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> contributor_entity_type = models . CharField ( <EOL> max_length = <NUM_LIT:3> , <EOL> blank = True , <EOL> help_text = "<STR_LIT>" , <EOL> choices = ENTITY_CODE_CHOICES <EOL> ) <EOL> intermediary_prefix = models . CharField ( max_length = <NUM_LIT:10> , blank = True ) <EOL> intermediary_first_name = models . CharField ( max_length = <NUM_LIT:255> , blank = True ) <EOL> intermediary_last_name = models . CharField ( max_length = <NUM_LIT:200> , blank = True ) <EOL> intermediary_suffix = models . CharField ( max_length = <NUM_LIT:10> , blank = True ) <EOL> intermediary_address_1 = models . CharField ( max_length = <NUM_LIT> , blank = True ) <EOL> intermediary_address_2 = models . CharField ( max_length = <NUM_LIT> , blank = True ) <EOL> intermediary_city = models . CharField ( max_length = <NUM_LIT:30> , blank = True ) <EOL> intermediary_state = models . CharField ( max_length = <NUM_LIT:2> , blank = True ) <EOL> intermediary_zipcode = models . CharField ( max_length = <NUM_LIT:10> , blank = True ) <EOL> intermediary_occupation = models . CharField ( max_length = <NUM_LIT> , blank = True ) <EOL> intermediary_employer = models . CharField ( max_length = <NUM_LIT:200> , blank = True ) <EOL> intermediary_selfemployed = models . CharField ( max_length = <NUM_LIT:1> , blank = True ) <EOL> intermediary_committee_id = models . CharField ( max_length = <NUM_LIT:9> , blank = True ) <EOL> objects = models . Manager ( ) <EOL> real = managers . RealContributionManager ( ) <EOL> class Meta : <EOL> app_label = '<STR_LIT>' <EOL> @ models . permalink <EOL> def get_absolute_url ( self ) : <EOL> return ( '<STR_LIT>' , [ str ( self . pk ) ] ) <EOL> @ property <EOL> def raw ( self ) : <EOL> from calaccess_raw . models import RcptCd <EOL> return RcptCd . objects . get ( <EOL> amend_id = self . amend_id , <EOL> filing_id = self . filing . filing_id_raw , <EOL> tran_id = self . transaction_id , <EOL> bakref_tid = self . backreference_transaction_id <EOL> ) <EOL> @ property <EOL> def contributor_dict ( self ) : <EOL> d = SortedDict ( { } ) <EOL> for k , v in self . to_dict ( ) . items ( ) : <EOL> if k . startswith ( "<STR_LIT>" ) : <EOL> d [ k . replace ( "<STR_LIT>" , "<STR_LIT>" ) ] = v <EOL> return d <EOL> @ property <EOL> def intermediary_dict ( self ) : <EOL> d = SortedDict ( { } ) <EOL> for k , v in self . to_dict ( ) . items ( ) : <EOL> if k . startswith ( "<STR_LIT>" ) : <EOL> d [ k . replace ( "<STR_LIT>" , "<STR_LIT>" ) ] = v <EOL> return d </s>
