Changeset 5581
- Timestamp:
- 8 Nov 2010, 12:59:16 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/WAeUPTables.py
r5561 r5581 435 435 out = open(export_file,"a") 436 436 csv_writer = csv.DictWriter(out,fields,) 437 if include_unused is not None and str(member) not in ('admin' ,'joachim'):437 if include_unused is not None and str(member) not in ('admin'): 438 438 logger.info('%s tries to dump pintable with unused pins' % (member)) 439 439 return … … 765 765 WAeUPTable.__init__(self, name) 766 766 return 767 768 security.declareProtected(ModifyPortalContent,"exportMoodleData") ###( 769 def exportMoodleData(self): 770 "export a WAeUPTable" 771 member = self.portal_membership.getAuthenticatedMember() 772 logger = logging.getLogger('WAeUPTables.StudentsCatalog.exportMoodleData') 773 if str(member) not in ('admin'): 774 logger.info('%s tries to dump Moodle Data' % (member)) 775 return 776 fields = [field for field in self.schema()] 777 export_fields = ['username','firstname','lastname','email','current_session','reg_state','password'] 778 format = ','.join(['"%%(%s)s"' % fn for fn in export_fields]) 779 csv = [] 780 csv.append(','.join(['"%s"' % fn for fn in export_fields])) 781 #import pdb;pdb.set_trace() 782 for uid in self._catalog.uids: 783 records = self.searchResults({"%s" % self.key : uid}) 784 if len(records) > 1: 785 # Can not happen, but anyway... 786 raise ValueError("More than one record with uid %s" % uid) 787 if len(records) == 0: 788 raise KeyError("No record for uid %s" % uid) 789 rec = self.record2dict(fields,records[0],None) 790 rec['firstname'] = rec['firstname'] + rec['middlename'] 791 rec.update({'reg_state':rec['review_state']}) 792 rec['current_session'] = rec['session'] 793 rec['username'] = rec['id'] 794 rec['password'] = self.waeup_tool.getCredential(rec['id']) 795 csv.append(format % rec) 796 current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") 797 open("%s/export/moodle-%s.csv" % (i_home,current),"w+").write('\n'.join(csv)) 798 return 'ready' 767 799 768 800 def manage_catalogClear(self, REQUEST=None, RESPONSE=None, URL1=None):
Note: See TracChangeset for help on using the changeset viewer.