Changeset 1065 for WAeUP_SRP/trunk/skins/waeup_student/search_students.py
- Timestamp:
- 15 Dec 2006, 13:42:56 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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,
Note: See TracChangeset for help on using the changeset viewer.