Changeset 1151
- Timestamp:
- 29 Dec 2006, 22:05:53 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 6 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Students.py
r1146 r1151 809 809 ###) 810 810 811 security.declareProtected(ModifyPortalContent,"importRe gisteredStudents")###(812 def importRe gisteredStudents(self):813 """load Re gisteredStudentdata from CSV values"""811 security.declareProtected(ModifyPortalContent,"importReturningStudents")###( 812 def importReturningStudents(self): 813 """load Returning Studentdata from CSV values""" 814 814 import transaction 815 815 import random … … 821 821 total = 0 822 822 #name = 'pume_results' 823 name = 'Re gistered'824 table = self.re gistered_import823 name = 'Returning' 824 table = self.returning_import 825 825 no_import = [] 826 826 imported = [] 827 827 logger = logging.getLogger('Import.%s' % name) 828 828 try: 829 re gistered= csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))829 returning = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) 830 830 except: 831 831 logger.error('Error reading %s.csv' % name) … … 841 841 if len(res) > 0: 842 842 regs = [s.matric_no for s in res] 843 for student in re gistered:843 for student in returning: 844 844 if start: 845 845 start = False … … 877 877 if len(no_import) > 0: 878 878 open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write( 879 '\n'.join(no_import) )879 '\n'.join(no_import) + '\n') 880 880 no_import = [] 881 imported = []882 881 open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write( 883 '\n'.join(no_import)) 882 '\n'.join(no_import) + "\n") 883 imported = [] 884 884 em = '%d transactions commited total %s\n' % (tr_count,total) 885 885 transaction.commit() … … 896 896 security.declareProtected(ModifyPortalContent,"importResults")###( 897 897 def importResults(self): 898 """load Re gistered Studentdata from CSV values"""898 """load Returning Students Results from CSV""" 899 899 import transaction 900 900 import random … … 967 967 if len(no_import) > 0: 968 968 open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write( 969 '\n'.join(no_import) )969 '\n'.join(no_import)+'\n') 970 970 no_import = [] 971 971 open("%s/import/%simported%s.csv" % (i_home,name,current),"a").write( 972 '\n'.join(imported) )972 '\n'.join(imported) + '\n') 973 973 imported = [] 974 974 if no_course_list: 975 975 open("%s/import/%sno_courses%s.csv" % (i_home,name,current),"a").write( 976 '\n'.join(no_course_list) )976 '\n'.join(no_course_list) + '\n') 977 977 no_course_list = [] 978 978 em = '%d transactions commited total %s\n courses not found %s' % (tr_count,total,course_count) … … 1720 1720 ###) 1721 1721 1722 1723 1722 class StudentPume(CPSDocument): ###( 1724 1723 """ -
WAeUP_SRP/trunk/WAeUPTables.py
r1146 r1151 232 232 233 233 InitializeClass(CoursesCatalog) 234 235 class RegisteredImport(WAeUPTable): ###( 236 237 meta_type = 'Registered Import Table' 238 name = "registered_import" 234 ###) 235 236 class ReturningImport(WAeUPTable): ###( 237 238 meta_type = 'Returning Import Table' 239 name = "returning_import" 239 240 key = "matric_no" 240 241 def __init__(self): 241 WAeUPTable.__init__(self, 'registered_import') 242 243 244 InitializeClass(RegisteredImport) 242 WAeUPTable.__init__(self, 'returning_import') 243 244 245 InitializeClass(ReturningImport) 246 ###) 245 247 246 248 class ResultsImport(WAeUPTable): ###( -
WAeUP_SRP/trunk/WAeUPTool.py
r828 r1151 35 35 from Products.CMFCore.permissions import ModifyPortalContent 36 36 from Products.CMFCore.utils import UniqueObject 37 from Students import makeCertificateCode 38 import logging 39 37 40 38 41 class WAeUPTool(UniqueObject, SimpleItem, ActionProviderBase): … … 50 53 ) 51 54 52 ## security.declarePublic('getHallTitle') 53 ## def getHallTitle(self,hall): 54 ## """get the Hall Title""" 55 ## res = ZCatalog.searchResults(self.portal_catalog,portal_type="AccoHall",id=hall) 56 ## if res and len(res) == 1: 57 ## return res[0].Title 58 ## return hall 59 60 security.declarePublic('getAccommodationInfo') 55 def generateStudentId(self,letter): ###( 56 import random 57 r = random 58 if letter not in ('ABCDEFGIHKLMNOPQRSTUVWXY'): 59 letter= r.choice('ABCDEFGHKLMNPQRSTUVWXY') 60 students = self.portal_url.getPortalObject().campus.students 61 sid = "%c%d" % (letter,r.randint(99999,1000000)) 62 while hasattr(students, sid): 63 sid = "%c%d" % (letter,r.randint(99999,1000000)) 64 return sid 65 ###) 66 67 security.declarePublic('getCertificateBrain') ###( 68 def getCertificateBrain(self,cert_id): 69 "do it" 70 res = ZCatalog.searchResults(self.portal_catalog, 71 {'portal_type':"Certificate", 72 'id': cert_id}) 73 if res: 74 return res[0] 75 return None 76 ###) 77 78 security.declarePublic('findStudentByMatricelNo') ###( 79 def findStudentByMatricelNo(self,matric_no): 80 "do it" 81 res = ZCatalog.searchResults(self.portal_catalog, 82 {'portal_type':"StudentClearance", 83 'SearchableText': matric_no}) 84 if res: 85 return res[0] 86 return None 87 ###) 88 89 security.declarePublic('makeStudentMember') ###( 90 def makeStudentMember(self,sid,password='uNsEt'): 91 """make the student a member""" 92 membership = self.portal_membership 93 membership.addMember(sid, 94 password , 95 roles=('Member', 96 'Student', 97 ), 98 domains='', 99 properties = {'memberareaCreationFlag': False, 100 'homeless': True},) 101 member = membership.getMemberById(sid) 102 self.portal_registration.afterAdd(member, sid, password, None) 103 self.manage_setLocalRoles(sid, ['Owner',]) 104 ###) 105 106 security.declarePublic('makeStudentData') ###( 107 def makeStudentData(self,student_id,email=None): 108 "create Datastructure for a returning Student" 109 #import pdb;pdb.set_trace() 110 logger = logging.getLogger('Student.CreateData') 111 students_folder = self.portal_url.getPortalObject().campus.students 112 res = self.students_catalog(id=student_id) 113 if res: 114 st = res[0] 115 res = self.returning_import(matric_no = st.matric_no) 116 if res: 117 student = res[0] 118 logger.info('"%s", "creating Datastructure"') 119 certcode_org = student.Coursemajorcode 120 certcode = makeCertificateCode(certcode_org) 121 certificate_brain = self.getCertificateBrain(certcode) 122 if not certificate_brain: 123 em = 'Certificate %s org-code %s not found\n' % (certcode, certcode_org) 124 logger.info(em) 125 level = student.Level 126 try: 127 int(level) 128 except: 129 em = '"%(matric_no)s","invalid Level","%(Level)s"' % student 130 logger.info(em) 131 matric_no = student.matric_no 132 sid = student_id 133 student_obj = getattr(students_folder,sid) 134 student_obj.invokeFactory('StudentApplication','application') 135 application = student_obj.application 136 self.portal_workflow.doActionFor(application,'open',dest_container=application) 137 da = {'Title': 'Application Data'} 138 student_obj.invokeFactory('StudentPersonal','personal') 139 da['jamb_reg_no'] = student.Entryregno 140 da['entry_mode'] = student.Mode_of_Entry 141 personal = student_obj.personal 142 self.portal_workflow.doActionFor(personal,'open',dest_container=personal) 143 dp = {'Title': 'Personal Data'} 144 student_obj.invokeFactory('StudentClearance','clearance') 145 clearance = student_obj.clearance 146 self.portal_workflow.doActionFor(clearance,'open',dest_container=clearance) 147 dc = {'Title': 'Clearance/Eligibility Record'} 148 dc['matric_no'] = matric_no 149 state = student.State 150 lga = student.LGA 151 if state and lga: 152 lga = state + ' / ' + lga 153 else: 154 lga = "None" 155 dc['lga'] = lga 156 dc['email'] = email 157 dp['firstname'] = student.Firstname 158 dp['middlename'] = student.Middlename 159 dp['lastname'] = student.Lastname 160 dp['sex'] = student.Sex == 'F' 161 dp['perm_address'] = student.Permanent_Address 162 application.getContent().edit(mapping=da) 163 personal.getContent().edit(mapping=dp) 164 clearance.getContent().edit(mapping=dc) 165 # 166 # Study Course 167 # 168 student_obj.invokeFactory('StudentStudyCourse','study_course') 169 studycourse = student_obj.study_course 170 self.portal_workflow.doActionFor(studycourse,'open',dest_container=studycourse) 171 dsc = {} 172 dsc['study_course'] = certcode 173 studycourse.getContent().edit(mapping=dsc) 174 # 175 # Level 176 # 177 ## l = getattr(studycourse,level,None) 178 ## if l is None: 179 ## studycourse.invokeFactory('StudentStudyLevel', level) 180 ## l = getattr(studycourse, level) 181 ## self.portal_workflow.doActionFor(l,'open',dest_container=l) 182 ## l.getContent().edit(mapping={'Title': "Level %s" % level}) 183 184 security.declarePublic('getAccommodationInfo') ###( 61 185 def getAccommodationInfo(self,bed): 62 186 """return Accommodation Info""" … … 82 206 info['maintenance_fee'] = batch_doc.cost 83 207 return info 208 ###) 209 210 security.declareProtected(ModifyPortalContent,'deleteAllCourses') ###( 211 def deleteAllCourses(self,department="All"): 212 ''' delete the courses''' 213 pm = self.portal_membership 214 member = pm.getAuthenticatedMember() 215 216 if str(member) not in ("henrik","joachim"): 217 return "not possible" 218 if department == "All": 219 res = self.portal_catalog({'meta_type': 'Department'}) 220 if len(res) < 1: 221 return "No Departments found" 222 223 deleted = [] 224 for dep in res: 225 cf = dep.getObject().courses 226 if cf: 227 cf.manage_delObjects(ids=cf.objectIds()) 228 deleted.append("deleted Courses in %s" % dep.getId) 229 return "\r".join(deleted) 230 ###) 231 84 232 85 233 InitializeClass(WAeUPTool) -
WAeUP_SRP/trunk/Widgets.py
r1146 r1151 326 326 valid = CPSStringWidget.validate(self, datastructure, **kw) 327 327 #import pdb;pdb.set_trace() 328 pumeresults = self.p ortal_pumeresults328 pumeresults = self.pumeresults 329 329 if not valid: 330 330 return 0 … … 361 361 valid = CPSStringWidget.validate(self, datastructure, **kw) 362 362 #import pdb;pdb.set_trace() 363 re gistered = self.registered_import363 returning = self.returning_import 364 364 results = self.results_import 365 365 err = 0 … … 371 371 #s = getStudentByRegNo(self,value) 372 372 while not err: 373 res = re gistered(matric_no = value)373 res = returning(matric_no = value) 374 374 if len(res) < 1: 375 375 err = 'No Student with MatricNo %s.' % (value) -
WAeUP_SRP/trunk/exportimport.py
r1146 r1151 102 102 importWAeUPTable(site.portal_pins, '', context,'pins') 103 103 importWAeUPTable(site.portal_pumeresults, '', context,'pumeresults') 104 importWAeUPTable(site.re gistered_import, '', context,'registered_import')104 importWAeUPTable(site.returning_import, '', context,'returning_import') 105 105 importWAeUPTable(site.results_import, '', context,'results_import') 106 106 importWAeUPTable(site.students_catalog, '', context,'students_catalog') -
WAeUP_SRP/trunk/profiles/default/layouts/student_session_results_search.xml
r1150 r1151 1 1 <?xml version="1.0"?> 2 <object name="student_session_result _search" meta_type="CPS Layout">2 <object name="student_session_results_search" meta_type="CPS Layout"> 3 3 <property name="layout_create_method"></property> 4 4 <property name="layout_edit_method"></property> … … 7 7 <property name="flexible_widgets"/> 8 8 <property name="validate_values_expr"></property> 9 <property name="label"></property> 10 <property name="label_edit"></property> 11 <property name="is_i18n">False</property> 12 <widget name="email" meta_type="Email Widget"> 13 <property name="title">Email</property> 14 <property name="fields"> 15 <element value="email"/> 16 </property> 17 <property name="label">Email</property> 18 <property name="label_edit">Email</property> 19 <property name="readonly_layout_modes"/> 20 <property name="hidden_layout_modes"> 21 <element value="create"/> 22 </property> 23 <property name="hidden_readonly_layout_modes"/> 24 </widget> 25 <widget name="jamb_reg_no" meta_type="String Widget"> 26 <property name="title">JAMP Registration Nr</property> 27 <property name="fields"> 28 <element value="jamb_reg_no"/> 29 </property> 30 <property name="label">JAMP Registration Nr</property> 31 <property name="label_edit">JAMP Registration Nr</property> 32 <property name="readonly_layout_modes"/> 33 <property name="hidden_layout_modes"> 34 <element value="create"/> 35 <element value="edit"/> 36 </property> 37 <property name="hidden_readonly_layout_modes"/> 38 <property name="display_width">10</property> 39 <property name="size_max">10</property> 40 </widget> 9 41 <widget name="matric_no" meta_type="MatricNo Widget"> 10 42 <property name="title">Matriculation Number</property> … … 22 54 <property name="size_max">10</property> 23 55 </widget> 56 <widget name="password" meta_type="Password Widget"> 57 <property name="title">Password</property> 58 <property name="fields"> 59 <element value="password"/> 60 </property> 61 <property name="is_required">True</property> 62 <property name="label">Choose a Password</property> 63 <property name="label_edit">Choose a Password</property> 64 <property name="check_digit">True</property> 65 <property name="password_widget"></property> 66 <property name="readonly_layout_modes"/> 67 <property name="hidden_layout_modes"> 68 <element value="create"/> 69 </property> 70 <property name="hidden_readonly_layout_modes"/> 71 </widget> 72 <widget name="repeat_password" meta_type="Password Widget"> 73 <property name="title">Password</property> 74 <property name="fields"> 75 <element value="repeat_password"/> 76 </property> 77 <property name="is_required">False</property> 78 <property name="label">Choose a Password</property> 79 <property name="label_edit">Repeat Password</property> 80 <property name="readonly_layout_modes"/> 81 <property name="password_widget">password</property> 82 <property name="hidden_layout_modes"> 83 <element value="create"/> 84 </property> 85 <property name="hidden_readonly_layout_modes"/> 86 <property name="size_min">0</property> 87 </widget> 24 88 <table> 25 89 <row> 26 <cell name="matric_no" ncols="3"/> 90 <cell name="matric_no" /> 91 </row> 92 <row> 93 <cell name="email" /> 94 </row> 95 <row> 96 <cell name="password" /> 97 </row> 98 <row> 99 <cell name="repeat_password" /> 27 100 </row> 28 101 </table> -
WAeUP_SRP/trunk/profiles/default/schemas.xml
r1146 r1151 20 20 <object name="student_personal" meta_type="CPS Schema"/> 21 21 <object name="student_pume" meta_type="CPS Schema"/> 22 <object name="student_returning" meta_type="CPS Schema"/> 22 23 <object name="student_search" meta_type="CPS Schema"/> 23 24 <object name="student_study_course" meta_type="CPS Schema"/> -
WAeUP_SRP/trunk/profiles/default/students_catalog.xml
r1146 r1151 2 2 <object name="portal_catalog" meta_type="WAeUP Table"> 3 3 <column value="id"/> 4 <column value="matric_no"/> 4 5 <column value="jamb_reg_no"/> 5 6 <column value="name"/> … … 17 18 <indexed_attr value="jamb_reg_no"/> 18 19 </index> 20 <index name="matric_no" meta_type="FieldIndex"> 21 <indexed_attr value="matric_no"/> 22 </index> 19 23 <index name="faculty" meta_type="KeywordIndex"> 20 24 <indexed_attr value="faculty"/> -
WAeUP_SRP/trunk/profiles/default/toolset.xml
r1146 r1151 11 11 <required tool_id="portal_pumeresults" 12 12 class="Products.WAeUP_SRP.WAeUPTables.PumeResultsTable"/> 13 <required tool_id="re gistered_import"14 class="Products.WAeUP_SRP.WAeUPTables.Re gisteredImport"/>13 <required tool_id="returning_import" 14 class="Products.WAeUP_SRP.WAeUPTables.ReturningImport"/> 15 15 <required tool_id="results_import" 16 16 class="Products.WAeUP_SRP.WAeUPTables.ResultsImport"/> -
WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py
r1096 r1151 37 37 students = context.portal_url.getPortalObject().campus.students 38 38 student = getattr(students,str(member)) 39 student_app = getattr(student,'application') 39 if request.has_key('email'): 40 context.waeup_tool.makeStudentData(str(member),email=request.get("email")) 41 student_app = getattr(student,'application',None) 42 if student_app is None: 43 context.waeup_tool.makeStudentData(str(member)) 44 student_app = getattr(student,'application',None) 40 45 student_pume = getattr(student,'pume',None) 41 46 s_review_state = wftool.getInfoFor(student,'review_state',None) -
WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py
r1060 r1151 71 71 sex = ds.get('sex'), 72 72 ) 73 elif context.portal_type == "Course": 74 context.courses_catalog.modifyRecord(**ds) 73 75 if cpsdocument_edit_and_view_button is not None: 74 76 action = '' -
WAeUP_SRP/trunk/skins/waeup_student/display_session_results.py
r1146 r1151 15 15 16 16 res,psm,ds = lt.renderLayout(layout_id= 'student_session_results_search', 17 schema_id= 'student_ clearance',17 schema_id= 'student_returning', 18 18 context=context, 19 19 mapping=validate and REQUEST, … … 40 40 ) 41 41 elif psm == 'valid': 42 ## context.waeup_tool.makeStudent(ds.get('student'), 43 ## results=ds.get('results')) 42 44 return context.session_results_anon_view(student=ds.get('student'), 43 45 results=ds.get('results')) -
WAeUP_SRP/trunk/skins/waeup_student/display_session_results_form.pt
r1146 r1151 1 1 <tal:block define="rendered_main options/rendered; 2 portal_status_message options/psm; 3 data_storage options/ds; 4 edition python:1;" 2 portal_status_message options/psm; 3 data_storage options/ds; 4 edition python:1;" 5 > 6 <metal:block define-macro="edit_form"> 7 <metal:block use-macro="here/content_lib_master/macros/master"> 8 <metal:block fill-slot="header" 9 tal:define="creation creation|nothing; 10 edition edition|nothing; 11 metadata metadata|nothing" 5 12 > 6 <metal:block define-macro="edit_form"> 7 <metal:block use-macro="here/content_lib_master/macros/master"> 8 <metal:block fill-slot="header" 9 tal:define="creation creation|nothing; 10 edition edition|nothing; 11 metadata metadata|nothing" 12 > 13 </metal:block> 13 </metal:block> 14 14 <metal:block fill-slot="main"> 15 15 <h3>Display Your 2005/2006 Session Results! </h3> -
WAeUP_SRP/trunk/skins/waeup_student/session_results_anon_view.pt
r1149 r1151 52 52 </span> 53 53 </table> 54 <a href="" tal:attributes="href string:${context/absolute_url}/set_access_data?matric_no=${student/matric_no}">Continue to Email-entry</a> 54 55 </metal:main> 55 56 </metal:body>
Note: See TracChangeset for help on using the changeset viewer.