Ejemplo n.º 1
0
 def add_county(**lookup):            
     #Sometimes, CFFR records come through with old county codes
     #that aren't in the official ANSI county list. Rather than skip
     #these records, add the missing county record.  
     
     #get the county name from the CFFR raw record
     cffr_county = CffrRaw.objects.filter(state_code = lookup['state'].state_ansi,county_code = lookup['county_ansi'])
     if cffr_county.count() > 0:
         county_name = cffr_county[0].county_name
     else:
         county_name = 'Unknown'
     record = County(state_id=lookup['state'].id, county_ansi=lookup['county_ansi'], county_name=county_name)
     record.save()
     return record
Ejemplo n.º 2
0
    def handle_noargs(self, **options):
        abbr = ''
        for c in AnsiCountyState.objects.order_by('state'):
            if c.state != abbr:
                state_ref_current = State.objects.get(state_abbr=c.state)
                abbr = c.state
                #for each state, add 1) a county-level record to be used for
                #tracking CFFR state undistributed funds 2) an "unknown" county
                #record
                county_ref_row = County(state=state_ref_current,
                                        county_ansi='999',
                                        county_name='State Undistributed')
                county_ref_row.save()
                county_ref_row = County(state=state_ref_current,
                                        county_ansi='000',
                                        county_name='Unknown County')
                county_ref_row.save()
                db.reset_queries()
            county_ref_row = County(state=state_ref_current,
                                    county_ansi=c.code,
                                    county_name=c.county)
            county_ref_row.save()

            db.reset_queries()

        #add county row to correspond to US Undistributed state record
        state_ref_current = State.objects.get(state_ansi='99')
        county_ref_row = County(state=state_ref_current,
                                county_ansi='999',
                                county_name='U.S. Undistributed')
        county_ref_row.save()
        db.reset_queries()