Changeset 457
- Timestamp:
- 31 Aug 2006, 13:23:15 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Students.py
r454 r457 273 273 ###) 274 274 275 security.declareProtected(ModifyPortalContent,"loadJAMBFromCSV")###( 276 def loadJAMBFromCSV(self): 277 """load JAMB data from CSV values""" 278 #return 279 students_folder = self.portal_catalog({'meta_type': 'StudentsFolder'})[-1].getObject() 280 import transaction 281 tr_count = 0 282 name = 'SampleJAMBDataII' 283 no_import = False 284 if not no_import: 285 no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") 286 no_import.write('REG-NO,NAME,SEX,STATE,LGA,ENG-SCORE,SUBJ1,SUBJ1-SCORE,SUBJ2,SUBJ2-SCORE,SUBJ3,SUBJ3-SCORE,AGGREGATE,UNIV1,FACULTY1,COURSE1,UNIV2,FACULTY2,COURSE2') 287 logger = logging.getLogger('%s_import' % name) 288 logger.info('Start loading from %s.csv' % name) 289 try: 290 result = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) 291 except: 292 logger.error('Error reading %s.csv' % name) 293 return 294 for jamb in result: 295 logger.info('processing %(REG-NO)s,%(NAME)s,%(SEX)s,%(STATE)s,%(LGA)s,%(ENG-SCORE)s,%(SUBJ1)s,%(SUBJ1-SCORE)s,%(SUBJ2)s,%(SUBJ2-SCORE)s,%(SUBJ3)s,%(SUBJ3-SCORE)s,%(AGGREGATE)s,%(UNIV1)s,%(FACULTY1)s,%(COURSE1)s,%(UNIV2)s,%(FACULTY2)s,%(COURSE2)s\n' % jamb) 296 jamb_reg_no = jamb.get('REG-NO') 297 res = self.portal_catalog({'meta_type': "StudentAdmission", 298 'jamb_reg_no': jamb_reg_no }) 299 if res: 300 em = 'Student with REG-NO %(REG-NO)s already exists\n' % jamb 301 logger.info(em) 302 no_import.write(em) 303 no_import.write('%(REG-NO)s,%(NAME)s,%(SEX)s,%(STATE)s,%(LGA)s,%(ENG-SCORE)s,%(SUBJ1)s,%(SUBJ1-SCORE)s,%(SUBJ2)s,%(SUBJ2-SCORE)s,%(SUBJ3)s,%(SUBJ3-SCORE)s,%(AGGREGATE)s,%(UNIV1)s,%(FACULTY1)s,%(COURSE1)s,%(UNIV2)s,%(FACULTY2)s,%(COURSE2)s\n' % jamb) 304 continue 305 sid = generateStudentId() 306 #self.log('Creating Faculty %(id)s = %(Title)s' % faculty) 307 not_created = True 308 while not_created: 309 try: 310 students_folder.invokeFactory('Student', sid) 311 not_created = False 312 except BadRequest: 313 sid = generateStudentId() 314 logger.info('%(tr_count)s: Creating Student with ID %(sid)s REG-NO %(jamb_reg_no)s ' % vars()) 315 s = getattr(self,sid) 316 s.invokeFactory('StudentAdmission','admission') 317 da = {'Title': 'Admission Data'} 318 s.invokeFactory('StudentPersonal','personal') 319 sp = s.personal 320 d = {'Title': 'Personal Data'} 321 s.invokeFactory('StudentClearance','clearance') 322 sc = s.clearance 323 dc = {'Title': 'Clearance Data'} 324 da["jamb_reg_no"] = jamb.get("REG-NO") 325 da["jamb_lastname"] = jamb.get("NAME") 326 d["lastname"] = jamb.get("NAME") 327 da["jamb_sex"] = jamb.get("SEX") 328 da["jamb_state"] = jamb.get("STATE") 329 da["jamb_lga"] = jamb.get("LGA") 330 da["jamb_score"] = jamb.get("AGGREGATE") 331 da["jamb_first_cos"] = jamb.get("COURSE1") 332 da["jamb_second_cos"] = jamb.get("COURSE2") 333 da["jamb_first_uni"] = jamb.get("UNIV1") 334 da["jamb_second_uni"] = jamb.get("UNIV2") 335 s.personal.getContent().edit(mapping=d) 336 s.admission.getContent().edit(mapping=da) 337 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 338 ###) 339 340 275 341 276 342 security.declareProtected(View,"Title") -
WAeUP_SRP/trunk/profiles/default/types/StudentsFolder.xml
r427 r457 71 71 <permission value="Modify portal content"/> 72 72 </action> 73 <action title="JAMB" 74 action_id="import_fulltime_students_results" category="import" 75 condition_expr="" 76 url_expr="string:${object_url}/loadJAMBFromCSV" 77 visible="True"> 78 <permission value="Modify portal content"/> 79 </action> 73 80 </object>
Note: See TracChangeset for help on using the changeset viewer.