def handle(self, *args, **options):
        logger=fec_logger()
        
        filings_to_process = new_filing.objects.filter(previous_amendments_processed=True,header_is_processed=True, data_is_processed=True, body_rows_superceded=False).order_by('filing_number')
                
        for this_filing in filings_to_process:
            print "processing %s " % (this_filing.filing_number)
            
            
            # Create summary data for some forms that don't have it in the header. This script only runs after all the body rows of these filings have been entered; most other summary data is entered earlier in the process. 
            if this_filing.form_type.upper() in ['F24', 'F24A', 'F24N']:
                summarize_f24(this_filing)
            elif this_filing.form_type.upper() in ['F6', 'F6A', 'F6N']:
                summarize_f6(this_filing)
            

            elif this_filing.form_type.startswith('F5') and not this_filing.is_f5_quarterly:
                summarize_nonquarterly_f5(this_filing)
                
            elif this_filing.form_type.startswith('F5') and this_filing.is_f5_quarterly:
                mark_superceded_F57s(this_filing)
            
            # if it's got sked E's and it's an F3X, overwrite 24 hr report
            elif this_filing.form_type.startswith('F3'):                
                try:
                    this_filing.lines_present['E']
                    mark_superceded_F24s(this_filing)
                except KeyError:
                    pass


                try:
                    this_filing.lines_present['A']
                    mark_superceded_F65s(this_filing)
                except KeyError:
                    pass
            
            # By now we should have dates for all filings, including the ones that don't start with a coverage from date
            # that we added by finding the first transaction date, so we can safely set the cycle. 
            if not this_filing.cycle:
                # we're about to save it, so don't hit the db twice.
                this_filing.set_cycle(save_now=False)
            
            this_filing.body_rows_superceded = True
            this_filing.save()
dataset/ETHPy150Open sunlightlabs/read_FEC/fecreader/formdata/management/commands/mark_superceded_body_rows.py/Command.handle/original