- Timestamp:
- 29 Sep 2006, 12:45:10 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Academics.py
r583 r592 47 47 return "Academic Section" 48 48 49 def importLocalRoles(self,portal_type): ###( 50 name = '%sLocalRoles' % portal_type 51 logger = logging.getLogger('%s_import' % name) 52 current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") 53 logger.info('Start exporting %(name)s to %(name)s_%(current)s.csv' % vars()) 54 export = [] 55 export.append('"code","users"') 56 pm = self.portal_membership 57 #import pdb;pdb.set_trace() 58 try: 59 imp_roles = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) 60 except: 61 logger.error('Error reading %s.csv' % name) 62 return 63 odict = {} 64 for f in self.portal_catalog({'meta_type': portal_type}): 65 odict[f.getId] = f.getObject() 66 for role in imp_roles: 67 obj_id = role['code'] 68 if obj_id in odict.keys(): 69 roles_dict = eval(role['users']) 70 for r in roles_dict.keys(): 71 if r.startswith('user'): 72 member_id = r.split(':')[1] 73 odict[obj_id].manage_setLocalRoles(member_id, roles_dict[r]) 74 logger.info('importing role for %s %s %s' % (obj_id, member_id,roles_dict[r])) 75 76 ###) 77 49 78 security.declareProtected(ModifyPortalContent,"loadFacultiesFromCSV")###( 50 79 def loadFacultiesFromCSV(self): 51 80 """install Universityspecific Faculies from CSV values""" 52 81 #return 82 if self.REQUEST.get('localroles'): 83 self.importLocalRoles('Faculty') 84 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 53 85 name = 'Faculties' 54 86 no_import = False … … 95 127 """install Universityspecific Faculies from CSV values""" 96 128 #return 129 if self.REQUEST.get('localroles'): 130 self.importLocalRoles('Department') 131 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 97 132 name = 'Departments' 98 133 no_import = False … … 755 790 ###) 756 791 792 def exportLocalRoles(self,portal_type): ###( 793 name = 'FacultiesLocalRoles' 794 logger = logging.getLogger('%s_export' % name) 795 current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") 796 logger.info('Start exporting %(name)s to %(name)s_%(current)s.csv' % vars()) 797 objects = [f.getObject() for f in self.portal_catalog({'meta_type': 'Faculty'})] 798 export = [] 799 export.append('"code","users"') 800 pm = self.portal_membership 801 import pdb;pdb.set_trace() 802 for obj in objects: 803 lr = pm.getMergedLocalRoles(obj) 804 logger.info('exporting %s %s ' % (obj.id, lr)) 805 export.append('"%s","%s"' % (obj.getId(),lr)) 806 open("%s/import/%s-%s.csv" % (i_home,name,current),"w+").write('\n'.join(export)) 807 808 ###) 809 757 810 security.declareProtected(ModifyPortalContent,"exportFacultiesToCSV")###( 758 811 def exportFacultiesToCSV(self): 759 812 """export Faculies to CSV""" 760 813 #return 814 if self.REQUEST.get('localroles'): 815 self.exportLocalRoles('Faculty') 816 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 761 817 name = 'Faculties' 762 818 no_import = False … … 789 845 """export Faculies to CSV""" 790 846 #return 791 import copy 847 if self.REQUEST.get('localroles'): 848 self.exportLocalRoles('Department') 849 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 792 850 name = 'Departments' 793 851 no_import = False
Note: See TracChangeset for help on using the changeset viewer.