Changeset 2666 for WAeUP_SRP


Ignore:
Timestamp:
15 Nov 2007, 15:06:02 (17 years ago)
Author:
joachim
Message:

forgot

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/WAeUPTool.py

    r2656 r2666  
    299299    def dumpSchoolfeePayments(self):
    300300        "dump paid schoolfees"
     301        mtool = self.portal_membership
     302        member = mtool.getAuthenticatedMember()
    301303        logger = logging.getLogger('WAeUPTool.dumpSchoolfees')
    302304        aq_student = self.students_catalog.evalAdvancedQuery
     
    306308                                   ))
    307309        res = aq_student(query)
    308         import pdb;pdb.set_trace()
     310        #import pdb;pdb.set_trace()
    309311        l = []
    310312        logger.info("start for %d" % len(res))
     
    319321            d = {}
    320322            d['student_id'] = student.id
    321             d['amount'] = fee_dict.get('new')
     323            d['name'] = student.name
     324            d['amount'] = fee_dict.get(new_returning)
    322325            l += d,
    323         import pdb;pdb.set_trace()
     326        csv_name = self.dumpListToCSV(l,'payments')
     327        logger.info('%s dumped payments to %s' % (member,export_file))
     328    ###)
     329
     330    security.declarePublic('dumpListToCSV') ###(
     331    def dumpListToCSV(self,l,filename,fields=None):
     332        """dump a list of dicts to a CSV file"""
     333        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
     334        export_file = "%s/export/%s_%s.csv" % (i_home,filename,current,)
     335        if fields is None:
     336            fields = l[0].keys()
     337        headline = ','.join(fields)
     338        out = open(export_file,"wb")
     339        out.write(headline +'\n')
     340        out.close()
     341        out = open(export_file,"a")
     342        csv_writer = csv.DictWriter(out,fields,)
     343        csv_writer.writerows(l)
     344        return export_file
    324345    ###)
    325346
Note: See TracChangeset for help on using the changeset viewer.