Changeset 966
- Timestamp:
- 29 Nov 2006, 14:26:31 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 1 added
- 11 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Students.py
r964 r966 22 22 i_home = Globals.INSTANCE_HOME 23 23 MAX_TRANS = 100 24 import DateTime 24 25 25 26 def makeCertificateCode(code): ###( … … 245 246 security.declareProtected(ModifyPortalContent,"loadPumeResultsFromCSV")###( 246 247 def loadPumeResultsFromCSV(self): 248 """load Fulltime Studentdata from CSV values into pumeresults catalog""" 249 import transaction 250 import random 251 from pdb import set_trace 252 csv_d = {'jamb_reg_no': "RegNumber", 253 'status': "Admission Status", 254 'name': "Name", 255 'score': "Score", 256 'sex': "Sex", 257 'faculty': "Faculty", 258 'department': "Dept", 259 'course': "Course", 260 'course_code_org': "Course Code", 261 } 262 csv_fields = [f[1] for f in csv_d.items()] 263 tr_count = 0 264 total = 0 265 #name = 'pume_results' 266 name = 'pup' 267 no_import = [] 268 s = ','.join(['"(%s)"' % fn for fn in csv_fields]) 269 no_import.append('%s' % s) 270 open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write( 271 '\n'.join(no_import)) 272 no_import = [] 273 logger = logging.getLogger('%s_import' % name) 274 starttime = DateTime.now() 275 logger.info('Start loading from %s.csv' % name) 276 try: 277 result = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) 278 except: 279 logger.error('Error reading %s.csv' % name) 280 return 281 pume = self.portal_pumeresults 282 format = ','.join(['"%%(%s)s"' % fn for fn in csv_fields]) 283 eduplicate = '"dupplicate",%s' % format 284 for jamb in result: 285 dict = {} 286 #set_trace() 287 for f,fn in csv_d.items(): 288 dict[f] = jamb.get(csv_d[f]) 289 try: 290 pume.addRecord(**dict) 291 except ValueError: 292 logger.info(eduplicate % jamb) 293 #em = 'Student with REG-NO %(jamb_reg_no)s already exists\n' % dict 294 #logger.info(em) 295 no_import.append(eduplicate % jamb) 296 logger.info('End loading from %s.csv' % name) 297 if len(no_import) > 1: 298 open("%s/import/%s_not_imported.csv" % (i_home,name),"w+").write( 299 '\n'.join(no_import)) 300 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 301 302 security.declareProtected(ModifyPortalContent,"createNewStudents")###( 303 def createNewStudents(self): 247 304 """load Fulltime Studentdata from CSV values""" 248 305 import transaction … … 263 320 #'batch': "Batch", 264 321 #'serial': "SerialNo", 265 #'jamb_score': "JambScore",322 'jamb_score': "Score", 266 323 #'omitted':"Omitted", 267 324 #'search_key': "SearchKey", … … 290 347 no_import = [] 291 348 s = ','.join(['"(%s)"' % fn for fn in csv_fields]) 292 no_import.append('%s\n' % s) 349 no_import.append('%s' % s) 350 open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write( 351 '\n'.join(no_import)) 352 no_import = [] 293 353 logger = logging.getLogger('%s_import' % name) 294 354 logger.info('Start loading from %s.csv' % name) … … 327 387 jamb_name = jamb.get(csv_d['jamb_lastname']) 328 388 jamb_name.replace('>','') 389 jamb_name.replace('<','') 329 390 names = jamb_name.split() 330 391 letter = names[-1][0].upper() … … 341 402 student = getattr(self,sid) 342 403 student.manage_setLocalRoles(sid, ['Owner',]) 343 student.invokeFactory('StudentClearance','clearance')344 #wftool.doActionFor(student.clearance,'open')345 dp = {'Title': 'Clearance/Eligibility Record'}346 student.clearance.manage_setLocalRoles(sid, ['Owner',])347 404 student.invokeFactory('StudentPume','pume') 348 405 dp = {'Title': 'Pume Data'} … … 353 410 'jamb_sex', 354 411 #'jamb_state', 355 #'jamb_score',412 'jamb_score', 356 413 'jamb_first_cos', 357 414 'jamb_sex', … … 376 433 #wftool.doActionFor(pume,'close') 377 434 pume.manage_setLocalRoles(sid, ['Owner',]) 378 student.getContent().createSubObjects() 435 #student.getContent().createSubObjects() 436 names = jamb_name.split() 437 dp = {} 438 if len(names) == 3: 439 dp['firstname'] = names[0].capitalize() 440 dp['middlename'] = names[1].capitalize() 441 dp['lastname'] = names[2].capitalize() 442 elif len(names) == 2: 443 dp['firstname'] = names[0].capitalize() 444 dp['lastname'] = names[1].capitalize() 445 else: 446 dp['lastname'] = jamb_name 447 dp['sex'] = jamb.get(csv_d['jamb_sex']) == 'F' 448 student.invokeFactory('StudentPersonal','personal') 449 per = student.personal 450 per_doc = per.getContent() 451 per_doc.edit(mapping = dp) 452 per.manage_setLocalRoles(sid, ['Owner',]) 379 453 if jamb.get(csv_d['stud_status']) == "Admitted": 380 454 wftool.doActionFor(student,'pume_pass') … … 384 458 wftool.doActionFor(student,'reject_admission') 385 459 continue 460 # 461 # Clearance 462 # 463 student.invokeFactory('StudentClearance','clearance') 464 #wftool.doActionFor(student.clearance,'open') 465 dp = {'Title': 'Clearance/Eligibility Record'} 466 student.clearance.manage_setLocalRoles(sid, ['Owner',]) 386 467 # 387 468 # Study Course … … 408 489 study_course.getContent().edit(mapping=dsc) 409 490 if tr_count > MAX_TRANS: 491 if len(no_import) > 1: 492 open("%s/import/%s_not_imported.csv" % (i_home,name),"w+").write( 493 '\n'.join(no_import)) 494 no_import = [] 410 495 em = '%d transactions commited\n' % tr_count 411 496 transaction.commit() … … 413 498 total += tr_count 414 499 tr_count = 0 415 if len(no_import) > 1:416 open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write(417 '\n'.join(no_import))418 500 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 419 501 ###) -
WAeUP_SRP/trunk/WAeUPTables.py
r952 r966 1 #-*- mode: python; mode: fold -*- 1 2 # (C) Copyright 2005 AixtraWare <http://aixtraware.de> 2 3 # Author: Joachim Schmitz <js@aixtraware.de> … … 166 167 InitializeClass(PinTable) 167 168 169 class PumeResultsTable(WAeUPTable): 170 171 meta_type = 'WAeUP PumeResults Tool' 172 name = "pumeresults" 173 key = "jamb_reg_no" 174 def __init__(self): 175 WAeUPTable.__init__(self, 'portal_pumeresults') 176 177 178 InitializeClass(PumeResultsTable) 179 168 180 # BBB: 169 181 AccomodationTable = AccommodationTable -
WAeUP_SRP/trunk/Widgets.py
r952 r966 288 288 letters = 2 289 289 letters_str = "L"*letters 290 291 290 def validate(self, datastructure, **kw): 292 291 """Validate datastructure and update datamodel.""" … … 294 293 valid = CPSStringWidget.validate(self, datastructure, **kw) 295 294 #import pdb;pdb.set_trace() 295 pumeresults = self.portal_pumeresults 296 296 if not valid: 297 297 return 0 … … 303 303 err = 'Invalid number, the expected format is: %s%s with N = Number, L = Letter' % (self.digits_str,self.letters_str) 304 304 else: 305 s = getStudentByRegNo(self,value) 306 if s is None: 305 #s = getStudentByRegNo(self,value) 306 pume = pumeresults(jamb_reg_no = value) 307 if pume is None: 307 308 err = 'No Student with JAMB-Reg-No %s' % (value) 308 309 else: 309 s_id = s.getId() 310 datastructure['s_id'] = s_id 310 datastructure['pume'] = pume[0] 311 311 if err: 312 312 datastructure.setError(widget_id, err) -
WAeUP_SRP/trunk/exportimport.py
r963 r966 99 99 importWAeUPTable(site.portal_accommodation, '', context,'accommodation') 100 100 importWAeUPTable(site.portal_pins, '', context,'pins') 101 importWAeUPTable(site.portal_pumeresults, '', context,'pumeresults') 101 102 102 103 from Products.CPSCore.exportimport.catalog import CatalogToolXMLAdapter -
WAeUP_SRP/trunk/profiles/default/toolset.xml
r828 r966 5 5 <required tool_id="portal_pins" 6 6 class="Products.WAeUP_SRP.WAeUPTables.PinTable"/> 7 <required tool_id="portal_pumeresults" 8 class="Products.WAeUP_SRP.WAeUPTables.PumeResultsTable"/> 7 9 <required tool_id="waeup_tool" 8 10 class="Products.WAeUP_SRP.WAeUPTool.WAeUPTool"/> -
WAeUP_SRP/trunk/skins/waeup_student/display_pume_result.py
r892 r966 44 44 ) 45 45 elif psm == 'valid': 46 url = "%s/campus/students/%s/pume/pume_anon_view" % (context.portal_url(),ds['s_id']) 47 return REQUEST.RESPONSE.redirect(url) 48 49 50 return 51 52 46 return context.pume_anon_view(pume=ds['pume']) 47 ## url = "%s/campus/students/%s/pume/pume_anon_view" % (context.portal_url(),ds['s_id']) 48 ## return REQUEST.RESPONSE.redirect(url) -
WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py
r913 r966 48 48 info['app'] = student.application 49 49 info['app_doc'] = student.application.getContent() 50 info['per'] = student.personal 51 info['per_doc'] = student.personal.getContent() 50 info['per'] = getattr(student,'personal',None) 51 info['sex'] = 'male' 52 if info['per'] is not None: 53 info['per_doc'] = student.personal.getContent() 54 if info['per_doc'].sex: 55 info['sex'] = 'female' 56 else: 57 if info['app_doc'].jamb_sex == "F": 58 info['sex'] = 'female' 52 59 course = getattr(student,'study_course',None) 53 #54 60 info['course'] = course 55 61 if course: 56 62 info['course_doc'] = student.study_course.getContent() 57 info['sex'] = 'male'58 if info['per_doc'].sex:59 info['sex'] = 'female'60 63 # 61 64 acco = getattr(student,'accommodation_2006',None) -
WAeUP_SRP/trunk/skins/waeup_student/pume_anon_slip.pt
r805 r966 1 <metal:html tal:define="app_doc python: context.aq_parent.application.getContent(); 2 pume_doc python: context.getContent()"> 1 <metal:html tal:define="pume python:context.portal_pumeresults(jamb_reg_no=request.get('nr'))[0]"> 3 2 <metal:body use-macro="here/main_template/macros/master"> 4 3 <metal:main fill-slot="main"> 5 <h3>PUME Results of <span tal:content="app_doc/jamb_firstname" /> 6 <span tal:content="app_doc/jamb_lastname" /></h3> 7 8 <br /> 9 <span tal:omit-tag="" 10 tal:content="structure python: app_doc.render(proxy=app_doc, 11 layout_mode='view_info', 12 layout_id='student_application_fe')" 13 /> 14 <span tal:condition="python:1" tal:omit-tag="" 15 tal:content="structure python: pume_doc.render(proxy=pume_doc, 16 layout_mode='view_slip', 17 layout_id='student_pume_fe')" 18 /> 4 <h3>PUME Results of <span tal:content="pume/name" /></h3> 5 6 <br /> 7 <table> 8 <tr> 9 <th>JAMB Registration Nr</th><td tal:content="pume/jamb_reg_no"></td> 10 </tr> 11 <tr> 12 <th>Name</th><td tal:content="pume/name"></td> 13 </tr> 14 <tr> 15 <th>Score</th><td tal:content="pume/score"></td> 16 </tr> 17 <tr> 18 <th>Status</th><td tal:content="pume/status"></td> 19 </tr> 20 <tr> 21 <th>Course Requested</th><td tal:content="pume/course"></td> 22 </tr> 23 </table> 19 24 </metal:main> 20 25 </metal:body> -
WAeUP_SRP/trunk/skins/waeup_student/pume_anon_view.pt
r826 r966 1 <metal:html tal:define="app_doc python: context.aq_parent.application.getContent(); 2 pume_doc python: context.getContent()"> 1 <metal:html tal:define="pume options/pume"> 3 2 <metal:body use-macro="here/main_template/macros/master"> 4 3 <metal:main fill-slot="main"> 5 6 7 4 <div style="text-align: right"> 8 <a href="" target="slip" tal:attributes="href string:pume_anon_slip "5 <a href="" target="slip" tal:attributes="href string:pume_anon_slip?nr=${pume/jamb_reg_no}" 9 6 onclick="javascript:window.open('','slip','width=600, height=700, directories=no, toolbar=no, location=no, menubar=yes, scrollbars=yes, status=no, resizable=no, dependent=no')"> 10 7 <img tal:attributes="src string:${here/portal_url}/actionicon_print.png" /> … … 13 10 </div> 14 11 15 <h3>PUME Results of <span tal:content="app_doc/jamb_firstname" /> 16 <span tal:content="app_doc/jamb_lastname" /></h3> 12 <h3>PUME Results of <span tal:content="pume/name" /></h3> 17 13 18 14 <br /> 19 20 <span tal:omit-tag="" 21 tal:content="structure python: app_doc.render(proxy=app_doc, 22 layout_mode='view_info', 23 layout_id='student_application_fe')" 24 /> 25 <span tal:omit-tag="" 26 tal:content="structure python: pume_doc.render(proxy=pume_doc, 27 layout_mode='view_slip', 28 layout_id='student_pume_fe')" 29 /> 30 15 <table> 16 <tr> 17 <th>JAMB Registration Nr</th><td tal:content="pume/jamb_reg_no"></td> 18 </tr> 19 <tr> 20 <th>Name</th><td tal:content="pume/name"></td> 21 </tr> 22 <tr> 23 <th>Score</th><td tal:content="pume/score"></td> 24 </tr> 25 <tr> 26 <th>Status</th><td tal:content="pume/status"></td> 27 </tr> 28 <tr> 29 <th>Course Requested</th><td tal:content="pume/course"></td> 30 </tr> 31 </table> 31 32 </metal:main> 32 33 </metal:body> -
WAeUP_SRP/trunk/skins/waeup_student/search_students.py
r920 r966 54 54 'search_string': '' 55 55 } 56 56 #from Products.zdb import set_trace 57 #set_trace() 57 58 rend,psm,ds = lt.renderLayout(layout_id= 'student_search', 58 59 schema_id= 'student_search', … … 70 71 allowed = True, 71 72 ) 73 #set_trace() 72 74 what = ds.get('search_mode') 73 75 state = ds.get('review_state') -
WAeUP_SRP/trunk/skins/waeup_student/search_students_form.pt
r920 r966 58 58 tal:content="student/id"></a></td> 59 59 <td> 60 <span tal:replace="python: student['per_doc'].firstname" /> 61 <span tal:replace="python: student['per_doc'].middlename" /> 62 <span tal:replace="python: student['per_doc'].lastname" /> 60 <span tal:replace="student/name" /> 63 61 </td> 64 62 <td><span tal:replace="python: student['app_doc'].jamb_reg_no" /></td> … … 69 67 onclick="javascript:window.open('','edit','width=600, height=700, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')" 70 68 >[change state]</a></td> 71 72 73 74 75 69 <td tal:condition="not: options/co_view|nothing"><span tal:replace="student/review_state" /></td> 76 70 </tr>
Note: See TracChangeset for help on using the changeset viewer.