- Timestamp:
- 15 Dec 2006, 13:42:56 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Students.py
r1005 r1065 545 545 ###) 546 546 547 security.declareProtected(ModifyPortalContent,"updateStudyCourse")###( 548 def updateStudyCourse(self): 549 """update StudyCourse from CSV values""" 550 import transaction 551 import random 552 from pdb import set_trace 553 wftool = self.portal_workflow 554 students_folder = self.portal_catalog({'meta_type': 'StudentsFolder'})[-1].getObject() 555 csv_d = {'jamb_reg_no': "RegNumber", 556 'jamb_lastname': "Name", 557 'session': "Session", 558 'pume_tot_score': "PUME SCORE", 559 'jamb_score': "JambScore", 560 'jamb_sex': "Sex", 561 'jamb_state': "State", 562 ## 'jamb_first_cos': "AdminCourse", 563 'faculty': "AdminFaculty", 564 'course_code': "AdmitCoscode", 565 'stud_status':"AdmitStatus", 566 'department': "AdmitDept", 567 'jamb_lga': "LGA", 568 'app_email': "email", 569 'app_mobile': "PhoneNumbers", 570 } 571 csv_fields = [f[1] for f in csv_d.items()] 572 tr_count = 0 573 total = 0 574 #name = 'pume_results' 575 name = 'StudyCourseChange' 576 no_import = [] 577 s = ','.join(['"(%s)"' % fn for fn in csv_fields]) 578 no_import.append('"Error",%s' % s) 579 format = '"%(Error)s",' + ','.join(['"%%(%s)s"' % fn for fn in csv_fields]) 580 no_certificate = "no certificate %s" % format 581 open("%s/import/%s_not_imported.csv" % (i_home,name),"w").write( 582 '\n'.join(no_import)) 583 logger = logging.getLogger('%s_import' % name) 584 logger.info('Start loading from %s.csv' % name) 585 l = self.portal_catalog({'meta_type': "Certificate"}) 586 try: 587 result = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) 588 except: 589 logger.error('Error reading %s.csv' % name) 590 return 591 for jamb in result: 592 jamb['Error'] = "Processing " 593 logger.info(format % jamb) 594 jamb_reg_no = jamb.get(csv_d['jamb_reg_no']) 595 res = self.portal_catalog({'portal_type': "StudentApplication", 596 'SearchableText': jamb_reg_no }) 597 if not res: 598 em = 'Student with RegNo %s does not exists\n' % jamb_reg_no 599 logger.info(em) 600 jamb['Error'] = "Student not exists" 601 no_import.append(format % jamb) 602 continue 603 sid = res[0].getPath().split('/')[-2] 604 cert_id = makeCertificateCode(jamb.get(csv_d['course_code'])) 605 res = self.portal_catalog(portal_type = "Certificate", id = cert_id) 606 if not res: 607 em = 'No Certificate with ID %s \n' % cert_id 608 logger.info(em) 609 jamb['Error'] = "No Certificate %s" % cert_id 610 no_import.append( format % jamb) 611 continue 612 cert_brain = res[0] 613 catalog_entry = {} 614 student = getattr(self,sid) 615 # 616 # Study Course 617 # 618 study_course = student.study_course 619 dsc = {} 620 cert_pl = cert_brain.getPath().split('/') 621 catalog_entry['id'] = sid 622 catalog_entry['faculty'] = cert_pl[-4] 623 catalog_entry['department'] = cert_pl[-3] 624 catalog_entry['course'] = cert_id 625 dsc['study_course'] = cert_id 626 study_course.getContent().edit(mapping=dsc) 627 self.students_catalog.modifyRecord(**catalog_entry) 628 if tr_count > 10: 629 if len(no_import) > 1: 630 open("%s/import/%s_not_imported.csv" % (i_home,name),"w+").write( 631 '\n'.join(no_import)) 632 no_import = [] 633 em = '%d transactions commited\n' % tr_count 634 transaction.commit() 635 logger.info(em) 636 total += tr_count 637 tr_count = 0 638 tr_count += 1 639 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 640 ###) 641 547 642 security.declareProtected(ModifyPortalContent,"OLDloadPumeResultsFromCSV")###( 548 643 def OLDloadPumeResultsFromCSV(self): -
WAeUP_SRP/trunk/__init__.py
r933 r1065 18 18 import PatchCPSStackingDirectoryStorageAdapter 19 19 import PatchBasicWidgetsCPSStringWidget 20 import PatchBasicWidgetsUnprepare 20 21 # Only for CPS 3.4.1. In 3.4.2 and later this should be fixed. 21 22 import PatchCPSDefaultImportExport -
WAeUP_SRP/trunk/skins/waeup_student/search_students.py
r1056 r1065 15 15 form = request.form 16 16 fget = form.get 17 wftool = context.portal_workflow17 #wftool = context.portal_workflow 18 18 mtool = context.portal_membership 19 19 member = mtool.getAuthenticatedMember() 20 roles = member.getRolesInContext(context) 21 students_folder = context.portal_url.getPortalObject().campus.students 20 #roles = member.getRolesInContext(context) 21 lt = context.portal_layouts 22 #pr = context.portal_registration 23 path_info = request.get('PATH_INFO').split('/') 22 24 try: 23 25 from Products.AdvancedQuery import Eq, Between, Le,In 24 26 evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery 27 aq_students = context.students_catalog.evalAdvancedQuery 25 28 except: 26 29 evalAdvancedQuery = None … … 37 40 "StudentStudyLevel",) 38 41 39 student_objects = student_subobjects + ("Student",) 40 41 info = {} 42 #student_objects = student_subobjects + ("Student",) 43 student_objects = ("Student",) 44 45 user_info = {} 42 46 items = [] 43 wf = context.portal_workflow44 #student_wf_states = wf.waeup_student_wf.states.keys()45 #info['wf_states'] = student_wf_states46 #info['wf_states'][0] = " ----- "47 lt = context.portal_layouts48 pr = context.portal_registration49 path_info = request.get('PATH_INFO').split('/')50 47 validate = request.has_key("cpsdocument_edit_button") 51 48 52 49 state = "all" 50 user_info['member'] = str(member) 51 user_info['departments'] = [] 52 user_info['faculties'] = [] 53 #from Products.zdb import set_trace 54 #set_trace() 55 co_view = False 53 56 if "ClearanceOfficers" in member.getGroups(): 54 57 state = "clearance_requested" 58 only_review = False 59 co_view = True 60 query = In('portal_type',('Faculty',)) &\ 61 In('localUsersWithRoles', ("user:%s" % member,)) 62 res = evalAdvancedQuery(query) 63 faculties = [] 64 if res: 65 faculties = [f.getId for f in res] 66 user_info['faculties'] = faculties 67 query = In('portal_type',('Department',)) &\ 68 In('localUsersWithRoles', ("user:%s" % member,)) 69 res = evalAdvancedQuery(query) 70 departments = [] 71 if res: 72 departments = [f.getId for f in res] 73 user_info['departments'] = departments 55 74 default = {'search_mode': 'name', 56 75 'review_state': state, … … 70 89 psm = psm, 71 90 #psm = "%s, %s" % (psm,ds), 91 info = user_info, 72 92 students = [], 73 93 allowed = True, … … 90 110 psm = psm, 91 111 #psm = "%s, %s" % (psm,ds), 112 info = user_info, 92 113 students = items, 93 114 allowed = True, … … 104 125 if len(term) > 0: 105 126 if what == "student_id": 127 students_folder = context.portal_url.getPortalObject().campus.students 106 128 query_step = 1 107 129 if hasattr(students_folder,term.strip()): … … 135 157 pl = r.getPath().split('/') 136 158 search_set.append(pl[pl.index('students') + 1]) 159 elif co_view: 160 #from Products.zdb import set_trace 161 #set_trace() 162 only_review = False 163 query = In('faculty',faculties) | In('department',departments) 164 res = aq_students(query) 165 search_set = [r.id for r in res] 166 ## res = context.students_catalog(faculty=faculties[0],) 167 ## res = context.students_catalog(faculty=faculties,department=departments) 168 #set_trace() 137 169 if with_review: 138 170 query_step += 10 139 review_res = evalAdvancedQuery(In('portal_type',student_objects) & Eq('review_state',state)) 171 #review_res = evalAdvancedQuery(('portal_type',student_objects) & Eq('review_state',state)) 172 review_res = evalAdvancedQuery(Eq('review_state',state)) 140 173 review_set = [] 141 174 if review_res: 142 175 for r in review_res: 143 pl = r.getPath().split('/') 144 review_set.append(pl[pl.index('students') + 1]) 176 #pl = r.getPath().split('/') 177 #review_set.append(pl[pl.index('students') + 1]) 178 review_set.append(r.getId) 145 179 all = [] 180 #set_trace() 146 181 if only_review: 147 182 all = review_set … … 152 187 else: 153 188 all = search_set 154 for a in all[:500]: 155 if a in items: 156 continue 157 items.append(a) 189 ##for a in all[:50]: 190 ## if a in items: 191 ## continue 192 ## items.append(a) 193 items = all[:500] 158 194 students = [] 159 items.sort()160 co_view = False 195 #items.sort() 196 161 197 if items: 162 198 for item in items: … … 166 202 for field in stcat.schema() + stcat.indexes(): 167 203 info[field] = getattr(record, field) 168 if "ClearanceOfficers" in member.getGroups():169 co_view = True170 res = context.portal_catalog(portal_type='Student', id = item)171 if len(res) != 1:172 continue173 droles = member.getRolesInContext(res[0].getObject())174 info['review_state'] = res[0].review_state175 if "ClearanceOfficer" in droles:176 students.append(info)204 ## if "ClearanceOfficers" in member.getGroups(): 205 ## co_view = True 206 ## res = context.portal_catalog(portal_type='Student', id = item) 207 ## if len(res) != 1: 208 ## continue 209 ## droles = member.getRolesInContext(res[0].getObject()) 210 ## info['review_state'] = res[0].review_state 211 ## if "ClearanceOfficer" in droles: 212 ## students.append(info) 177 213 else: 178 214 students.append(info) … … 180 216 return context.search_students_form(rendered = rend, 181 217 psm = "", 218 info = user_info, 182 219 students = students, 183 220 allowed = True, … … 186 223 return context.search_students_form(rendered = rend, 187 224 psm = "No student found!", 225 info = user_info, 188 226 students = students, 189 227 allowed = True, -
WAeUP_SRP/trunk/skins/waeup_student/search_students_form.pt
r1030 r1065 2 2 portal_status_message options/psm; 3 3 students options/students; 4 info options/info|nothing; 4 5 allowed options/allowed|nothing" 5 6 > … … 16 17 <metal:block use-macro="here/error_not_found/macros/not_found" /> 17 18 </span> 18 <span tal:condition="allowed" 19 <span tal:condition="allowed" tal:omit-tag=""> 20 <h3> Search Student Section</h3><br /> 21 <h4><span tal:replace="info/member|nothing" /> 22 <span tal:condition="info/faculties|nothing" tal:omit-tag=""> 23 is ClearanceOfficer for Faculty 24 <span tal:repeat="faculty info/faculties" tal:content="faculty" /> 25 </span> 26 <span tal:condition="info/departments|nothing" tal:omit-tag=""> 27 and <span tal:repeat="department info/departments|nothing" tal:content="department"/> 28 </span> 29 <span tal:replace="structure rendered" /> 30 </h4><br /><br /> 31 32 <span tal:condition="students" 19 33 tal:define="items students; 20 34 columns python:3; … … 29 43 tal:omit-tag="" 30 44 > 31 32 <h3> Search Student Section</h3>33 34 <br />35 36 <span tal:replace="structure rendered" />37 45 <tal:block tal:condition="python: items and batch_info and batch_info['nb_pages'] > 1"> 38 46 <div class="batchLayout"> … … 67 75 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')" 68 76 >[change state]</a></td> 69 <td tal:condition="options/co_view|nothing"><span tal:replace="student/review_state " /></td>77 <td tal:condition="options/co_view|nothing"><span tal:replace="student/review_state|nothing" /></td> 70 78 </tr> 71 79 </span> … … 110 118 </tal:block> 111 119 </span> 120 </span> 112 121 </metal:main> 113 122 </metal:body>
Note: See TracChangeset for help on using the changeset viewer.