Changeset 3022 for WAeUP_SRP/base
- Timestamp:
- 14 Jan 2008, 17:58:33 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/skins/waeup_student/search_students.py
r3013 r3022 41 41 except: 42 42 aq_portal = context.portal_catalog_real.evalAdvancedQuery 43 students_catalog = context.students_catalog 43 44 aq_students = context.students_catalog.evalAdvancedQuery 44 45 … … 189 190 review_set = [] 190 191 search_set = [] 192 query = None 191 193 if len(term) > 0: 192 194 if what == "student_id": … … 201 203 ) 202 204 elif what == "department": 203 res = context.students_catalog(department=term.strip())205 query = Eq('department', term.strip()) 204 206 logger.info('%s searches for student in department %s' % (member,term)) 205 search_set = [r.id for r in res] 207 # res = context.students_catalog(department=term.strip()) 208 # logger.info('%s searches for student in department %s' % (member,term)) 209 # search_set = [r.id for r in res] 206 210 elif what == "matric_no": 207 res = context.students_catalog(matric_no=term.strip())211 query = Eq('matric_no', term.strip()) 208 212 logger.info('%s searches for student with matric_no %s' % (member,term)) 209 search_set = [r.id for r in res] 213 # res = context.students_catalog(matric_no=term.strip()) 214 # logger.info('%s searches for student with matric_no %s' % (member,term)) 215 # search_set = [r.id for r in res] 210 216 elif what == "jamb_reg_no": 211 217 st_l = "%s" % term.strip().lower() 212 218 st_u = "%s" % term.strip().upper() 213 res = aq_students(In('jamb_reg_no',(st_l,st_u)))219 query = In('jamb_reg_no',(st_l,st_u)) 214 220 logger.info('%s searches for student with jamb_reg_no %s' % (member,term)) 215 search_set = [r.id for r in res] 221 # res = aq_students(In('jamb_reg_no',(st_l,st_u))) 222 # logger.info('%s searches for student with jamb_reg_no %s' % (member,term)) 223 # search_set = [r.id for r in res] 216 224 elif what == "name": 217 225 if len(term) < 4: … … 221 229 allowed = allowed, 222 230 ) 223 pt = ('StudentPersonal') 224 query = In('portal_type',pt) & Eq('SearchableText',"%s*" % term.strip()) 231 # pt = ('StudentPersonal') 232 # query = In('portal_type',pt) & Eq('SearchableText',"%s*" % term.strip()) 233 # logger.info('%s searches for student with name %s' % (member,term)) 234 # res = aq_portal(query) 235 # if res: 236 # for r in res: 237 # pl = r.getPath().split('/') 238 # search_set.append(pl[pl.index('students') + 1]) 239 query = Eq('name',"%s*" % term.strip()) 225 240 logger.info('%s searches for student with name %s' % (member,term)) 226 res = aq_portal(query) 227 if res: 228 for r in res: 229 pl = r.getPath().split('/') 230 search_set.append(pl[pl.index('students') + 1]) 241 # res = aq_students(query) 242 # if res: 243 # for r in res: 244 # search_set += r.id, 231 245 232 246 if only_review or with_review or co_view: … … 234 248 #review_res = aq_portal(query) 235 249 #review_res = context.portal_catalog(review_state = state) 236 237 query = Eq('review_state',state) 238 review_res = aq_students(query) 250 if query is not None: 251 query = Eq('review_state',state) & query 252 else: 253 query = Eq('review_state',state) 254 #review_res = aq_students(query) 239 255 logger.info('%s searches for students in review_state %s' % (member,state)) 240 256 … … 242 258 only_review = False 243 259 with_review = True 244 query = In('faculty',faculties) | In('department',departments) 245 res = aq_students(query) 246 search_set = [r.id for r in res] 260 if query is not None: 261 query = query & In('faculty',faculties) | In('department',departments) 262 else: 263 query = In('faculty',faculties) | In('department',departments) 264 # res = aq_students(query) 265 # search_set.extend([r.id for r in res]) 247 266 elif ca_view: 248 267 only_review = False … … 250 269 courses = [cl.split('/')[0] for cl in certificate_levels] 251 270 levels = [cl.split('/')[1] for cl in certificate_levels] 252 query = In('course',courses) & In('level',levels) 253 res = aq_students(query) 254 search_set = [r.id for r in res] 255 if review_res: 256 review_set = [r.id for r in review_res] 257 258 #from Products.zdb import set_trace;set_trace() 259 260 if only_review: 261 all = review_set 262 elif with_review: 263 all = [] 264 for i in search_set: 265 if i in review_set: 266 all.append(i) 267 else: 268 all = search_set 269 270 items = all[:500] 271 if query is not None: 272 query = query & In('course',courses) & In('level',levels) 273 # res = aq_students(query) 274 # search_set.extend([r.id for r in res]) 275 276 # if review_res: 277 # review_set = [r.id for r in review_res] 278 279 # if only_review: 280 # all = review_set 281 # elif with_review: 282 # all = [] 283 # for i in search_set: 284 # if i in review_set: 285 # all.append(i) 286 # else: 287 # all = search_set 288 289 # res = aq_students(query) 290 # all = [r.id for r in res] 291 292 # items = all[:500] 293 # students = [] 294 # if items: 295 # for item in items: 296 # students_catalog = context.students_catalog 297 # record = students_catalog(id = item) 298 # if record: 299 # record = record[0] 300 # else: 301 # return item+' not found in students_catalog' 302 # info = {} 303 # for field in students_catalog.schema() + students_catalog.indexes(): 304 # info[field] = getattr(record, field) 305 # else: 306 # students.append(info) 307 # return context.search_students_form(rendered = rend, 308 # psm = "", 309 # info = user_info, 310 # students = students, 311 # allowed = allowed, 312 # co_view = co_view, 313 # ca_view = ca_view 314 # ) 315 student_records = aq_students(query) 271 316 students = [] 272 if items: 273 for item in items: 274 stcat = context.students_catalog 275 record = stcat(id = item) 276 if record: 277 record = record[0] 278 else: 279 return item+' not found in students_catalog' 317 if student_records: 318 for student_record in student_records: 280 319 info = {} 281 for field in st cat.schema() + stcat.indexes():282 info[field] = getattr( record, field)320 for field in students_catalog.schema() + students_catalog.indexes(): 321 info[field] = getattr(student_record, field) 283 322 else: 284 323 students.append(info)
Note: See TracChangeset for help on using the changeset viewer.