Changeset 727 for WAeUP_SRP/trunk/skins/waeup_student
- Timestamp:
- 20 Oct 2006, 13:06:08 (18 years ago)
- Location:
- WAeUP_SRP/trunk/skins/waeup_student
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py
r725 r727 1 # #Script (Python) "cpsdocument_edit"1 # Script (Python) "cpsdocument_edit" 2 2 ##bind container=container 3 3 ##bind context=context … … 12 12 return Info about the Studylevel 13 13 """ 14 def findCourse(cid):15 ''' find the course'''16 res = context.portal_catalog({'meta_type': 'Course',17 'id': cid})18 if len(res) < 1:19 return None20 course = res[0].getObject().getContent()21 return course22 23 14 def calculateGPA(): 24 15 """calculate the gpa""" … … 76 67 rd = ro.getContent() 77 68 row['id'] = ro.getId() 78 course = findCourse(ro.getId()) 79 row['credits'] = 0 80 if course: 81 row['credits'] = course.credits 69 row['credits'] = rd.credits 82 70 if row['credits'] and rd.grade: 83 credits = int( course.credits)71 credits = int(rd.credits) 84 72 sum += credits * ['F','E','D','C','B','A'].index(rd.grade) 85 73 course_count += credits 86 74 row['sum'] = sum 87 75 row['count'] = course_count 88 row['title'] = rd. Title()76 row['title'] = rd.title 89 77 #row['core'] = rd.core_or_elective 90 78 row['semester'] = rd.semester -
WAeUP_SRP/trunk/skins/waeup_student/searchStudents.py
r680 r727 12 12 return Info about the current Student 13 13 """ 14 #from Products.ZCTextIndex.QueryParser import ParseError,QueryError 14 try: 15 from Products.AdvancedQuery import Eq, Between, Le 16 evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery 17 except: 18 evalAdvancedQuery = None 19 15 20 request = context.REQUEST 16 21 form = request.form … … 53 58 err = False 54 59 with_review = state != "all" 60 onlyreview = with_review and not term 61 with_level_results = state.startswith("category") and evalAdvancedQuery is not None 62 bools = "with_review = %s<br\> onlyreview = %s<br\> with_level_results = %s" % (with_review,onlyreview,with_level_results) 55 63 if not term and not with_review: 56 64 psm = "You must specify a search string when searching 'all states'." … … 66 74 is_manager = is_manager, 67 75 ) 68 with_review = state != "all"69 76 items = [] 70 77 res = [] 71 78 portal_type_query = {'query':['Student','StudentApplication','StudentPersonal']} 72 79 st_queries = ('jamb_reg_no','matric_no','name') 73 onlyreview = with_review and not term 74 if onlyreview: 75 res = catalog(portal_type='Student', 76 review_state=state) 80 query_step = 0 81 if onlyreview and not with_level_results: 82 query_step = 1 83 query = Eq('portal_type','Student') & Eq('review_state',state) 84 res = evalAdvancedQuery(query) 85 ## res = catalog(portal_type='Student', 86 ## review_state=state) 87 elif onlyreview and with_level_results: 88 query_step = 2 89 query = Eq('portal_type','StudentStudyLevel') & Eq('review_state',state) 90 res = evalAdvancedQuery(query) 77 91 elif what == "student_id": 78 92 if with_review: 93 query_step = 3 79 94 res = catalog(portal_type='Student', 80 95 id = term.strip(), 81 96 review_state=state) 82 97 else: 98 query_step = 4 83 99 res = catalog(portal_type='Student', 84 100 id = term.strip()) 85 elif what in st_queries :101 elif what in st_queries and not with_level_results: 86 102 if what == "jamb_reg_no": 103 query_step = 5 87 104 pt = 'StudentApplication' 88 105 st = "%s*" % term.strip().lower() 89 106 elif what == "matric_no": 107 query_step = 6 90 108 pt = 'StudentClearance' 91 109 st = "%s*" % term.strip().lower() 92 110 elif what == "name": 111 query_step = 7 93 112 pt = portal_type_query 94 113 st = "%s*" % term.strip() … … 102 121 is_manager = is_manager, 103 122 ) 123 elif what in st_queries and with_level_results and evalAdvancedQuery: 124 if what == "jamb_reg_no": 125 query_step = 8 126 pt = 'StudentApplication' 127 st = "%s*" % term.strip().lower() 128 elif what == "matric_no": 129 query_step = 9 130 pt = 'StudentClearance' 131 st = "%s*" % term.strip().lower() 132 elif what == "name": 133 query_step = 10 134 pt = portal_type_query 135 st = "%s*" % term.strip() 136 query = Eq('portal_type',pt) & Eq('SearchableText',"%s*" % term.strip().lower())\ 137 | Eq('portal_type','StudentStudyLevel') & Eq('review_state',state) 138 try: 139 res = evalAdvancedQuery(query) 140 except: 141 return context.students_manager_view(rendered = rend, 142 psm = 'Advanced Query failed' % term, 143 #psm = "%s, %s" % (psm,ds), 144 students = items, 145 is_manager = is_manager, 146 ) 104 147 students = [] 148 raw_res = len(res) 105 149 if res: 106 150 for r in res: 107 if r.portal_type in ("StudentApplication","StudentPersonal" ):151 if r.portal_type in ("StudentApplication","StudentPersonal",): 108 152 student = r.getObject().aq_parent 153 elif r.portal_type in ("StudentStudyLevel",): 154 student = r.getObject().aq_parent.aq_parent 109 155 ## pp = '/'.join(r.getPath().split('/')[:-1]) 110 156 ## student_cat = catalog(pathindex=pp,portal_type='Student')[0] … … 114 160 student = r.getObject() 115 161 student_rs = wf.getInfoFor(student,'review_state','keiner') 116 if (with_review and student_rs != state ) or student in items:162 if (with_review and student_rs != state and not with_level_results) or student in items: 117 163 continue 118 164 items.append(student) … … 126 172 ) 127 173 return context.students_manager_view(rendered = rend, 128 psm = """ Your search for "%s" in %s with state %s failed.""" % (st,what,state),174 psm = """Step: %s found: %s Your search for "%s" in %s with state %s failed.<br\>%s""" % (query_step,raw_res,st,what,state,bools), 129 175 students = students, 130 176 is_manager = is_manager,
Note: See TracChangeset for help on using the changeset viewer.