Changeset 1278 for WAeUP_SRP/trunk/skins/waeup_student
- Timestamp:
- 11 Jan 2007, 22:03:22 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/skins/waeup_student/search_students.py
r1192 r1278 12 12 list Students for ClearanceOfficers 13 13 """ 14 import logging 15 logger = logging.getLogger('Search.Timer') 16 from DateTime import DateTime 17 # 18 #with_timer = True 19 with_timer = False 20 # 14 21 request = REQUEST 15 22 form = request.form 16 23 fget = form.get 17 #wftool = context.portal_workflow18 24 mtool = context.portal_membership 19 25 member = mtool.getAuthenticatedMember() 20 26 is_anon = mtool.isAnonymousUser() 21 #roles = member.getRolesInContext(context)22 27 lt = context.portal_layouts 23 #pr = context.portal_registration24 28 path_info = request.get('PATH_INFO').split('/') 25 29 … … 27 31 if is_anon: 28 32 allowed = False 29 30 33 try: 31 34 from Products.AdvancedQuery import Eq, Between, Le,In … … 57 60 user_info['departments'] = [] 58 61 user_info['faculties'] = [] 59 #from Products.zdb import set_trace60 #set_trace()61 62 co_view = False 63 faculties = fget('faculties') 64 departments = fget('departments') 65 dep_str = fac_str = '' 62 66 if "ClearanceOfficers" in member.getGroups(): 63 67 state = "clearance_requested" 64 68 only_review = False 65 69 co_view = True 66 query = In('portal_type',('Faculty',)) &\ 67 In('localUsersWithRoles', ("user:%s" % member,)) 68 res = evalAdvancedQuery(query) 69 faculties = [] 70 if res: 71 faculties = [f.getId for f in res] 72 user_info['faculties'] = faculties 73 query = In('portal_type',('Department',)) &\ 74 In('localUsersWithRoles', ("user:%s" % member,)) 75 res = evalAdvancedQuery(query) 76 departments = [] 77 if res: 78 departments = [f.getId for f in res] 79 user_info['departments'] = departments 70 if faculties or departments: 71 #from Products.zdb import set_trace;set_trace() 72 if faculties: 73 fac_str = faculties 74 faculties = faculties.split() 75 if departments: 76 dep_str = departments 77 departments = departments.split() 78 else: 79 query = In('portal_type',('Faculty',)) &\ 80 In('localUsersWithRoles', ("user:%s" % member,)) 81 res = evalAdvancedQuery(query) 82 faculties = [] 83 if res: 84 faculties = [f.getId for f in res] 85 user_info['faculties'] = faculties 86 fac_str = " ".join(faculties) 87 query = In('portal_type',('Department',)) &\ 88 In('localUsersWithRoles', ("user:%s" % member,)) 89 res = evalAdvancedQuery(query) 90 departments = [] 91 if res: 92 departments = [f.getId for f in res] 93 user_info['departments'] = departments 94 dep_str = " ".join(departments) 80 95 default = {'search_mode': 'student_id', 81 96 'review_state': state, … … 89 104 layout_mode='edit', 90 105 formaction="search_students", 106 faculties = fac_str, 107 departments = dep_str, 91 108 commit = False, 92 109 ) … … 140 157 res = context.students_catalog(department=term.strip()) 141 158 search_set = [r.id for r in res] 159 elif what == "matric_no": 160 res = context.students_catalog(matric_no=term.strip()) 161 search_set = [r.id for r in res] 142 162 elif what in st_queries: 143 163 if what == "jamb_reg_no": 144 164 pt = ('StudentApplication',) 145 st = "%s" % term.strip().lower()146 elif what == "matric_no":147 pt = ('StudentClearance',)148 165 st = "%s" % term.strip().lower() 149 166 elif what == "name": … … 156 173 pl = r.getPath().split('/') 157 174 search_set.append(pl[pl.index('students') + 1]) 158 elif co_view: 159 #from Products.zdb import set_trace 160 #set_trace() 175 if only_review or with_review or co_view: 176 if with_timer: 177 start = DateTime().timeTime() 178 logger.info('"%s","start 100"' % member) 179 query = Eq('review_state',state) 180 review_res = evalAdvancedQuery(query) 181 if with_timer: 182 end = DateTime().timeTime() 183 logger.info('"%s","searchtime","%6.2f"' % (member,end-start)) 184 if co_view: 161 185 only_review = False 186 with_review = True 187 if with_timer: 188 start = DateTime().timeTime() 189 logger.info('"%s","start 200"' % member) 162 190 query = In('faculty',faculties) | In('department',departments) 163 191 res = aq_students(query) 192 if with_timer: 193 end = DateTime().timeTime() 194 logger.info('"%s","searchtime","%6.2f"' % (member,end-start)) 195 start = DateTime().timeTime() 164 196 search_set = [r.id for r in res] 165 if only_review or with_review: 166 query = Eq('review_state',state) 167 review_res = evalAdvancedQuery(query) 168 review_set = [] 197 if with_timer: 198 end = DateTime().timeTime() 199 logger.info('"%s","searchtime","%6.2f"' % (member,end-start)) 200 if with_timer: 201 logger.info('"%s","start 300"' % member) 202 start = DateTime().timeTime() 169 203 if review_res: 170 for r in review_res: 171 if r.portal_type == "StudentAccommodation": 172 start = r.getPath().find('/students/') + 10 173 review_set.append(r.getPath()[start:start+7]) 174 else: 175 review_set.append(r.getId) 176 #set_trace() 204 review_set = [r.getId for r in review_res] 205 if with_timer: 206 end = DateTime().timeTime() 207 logger.info('"%s","searchtime","%6.2f"' % (member,end-start)) 208 logger.info('"%s","start 400"' % member) 209 start = DateTime().timeTime() 177 210 if only_review: 178 211 all = review_set … … 184 217 else: 185 218 all = search_set 219 if with_timer: 220 end = DateTime().timeTime() 221 logger.info('"%s","searchtime","%6.2f"' % (member,end-start)) 186 222 items = all[:500] 187 223 students = [] 224 if with_timer: 225 logger.info('"%s","start 500"' % member) 226 start = DateTime().timeTime() 188 227 if items: 189 228 for item in items: … … 193 232 for field in stcat.schema() + stcat.indexes(): 194 233 info[field] = getattr(record, field) 195 ## if "ClearanceOfficers" in member.getGroups():196 ## co_view = True197 ## res = context.portal_catalog(portal_type='Student', id = item)198 ## if len(res) != 1:199 ## continue200 ## droles = member.getRolesInContext(res[0].getObject())201 ## info['review_state'] = res[0].review_state202 ## if "ClearanceOfficer" in droles:203 ## students.append(info)204 234 else: 205 235 students.append(info) 236 if with_timer: 237 end = DateTime().timeTime() 238 logger.info('"%s","searchtime","%6.2f"' % (member,end-start)) 206 239 207 240 return context.search_students_form(rendered = rend,
Note: See TracChangeset for help on using the changeset viewer.