Changeset 3066 for WAeUP_SRP/base/skins
- Timestamp:
- 30 Jan 2008, 14:59:03 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/skins/waeup_student/search_students.py
r3024 r3066 58 58 co_view = False 59 59 ca_view = False 60 faculties = fget('faculties') 61 departments = fget('departments') 62 certificate_levels = fget('certificate_levels') 63 dep_str = fac_str = certificate_levels_str = '' 64 60 session_data = request.SESSION 61 faculties = session_data.get('faculties',None) 62 departments = session_data.get('departments',None) 63 certificate_levels = session_data.get('certificate_levels',None) 65 64 # determine local roles 66 67 65 if "ClearanceOfficers" in member.getGroups(): 68 66 default_state = "clearance_requested" 69 67 co_view = True 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',)) &\ 68 if faculties is None or departments is None: 69 logger.info('ClearanceOfficer %s initiated student_search' % member) 70 query = In('portal_type',('Faculty','Department')) &\ 80 71 In('localUsersWithRoles', ("user:%s" % member,)) 81 72 res = aq_portal(query) 82 logger.info('ClearanceOfficer %s initiated student_search' % member) 83 faculties = [] 84 if res: 85 faculties = [f.getId for f in res] 86 user_info['faculties'] = faculties 87 fac_str = " ".join(faculties) 88 query = In('portal_type',('Department',)) &\ 89 In('localUsersWithRoles', ("user:%s" % member,)) 90 res = aq_portal(query) 91 departments = [] 92 if res: 93 departments = [f.getId for f in res] 94 user_info['departments'] = departments 95 dep_str = " ".join(departments) 73 faculties = [f.getId for f in res if f.portal_type == 'Faculty'] 74 departments = [f.getId for f in res if f.portal_type == 'Department'] 75 user_info['faculties'] = session_data['faculties'] = faculties 76 user_info['departments'] = session_data['departments'] = departments 96 77 elif "CourseAdvisers" in member.getGroups(): 97 78 default_state = "courses_registered" 98 79 ca_view = True 99 if certificate_levels: 100 certificate_levels_str = certificate_levels 101 certificate_levels = certificate_levels.split() 102 else: 80 if certificate_levels is None: 81 logger.info('CourseAdviser %s initiated student_search' % member) 103 82 query = In('portal_type',('StudyLevel',)) &\ 104 83 In('localUsersWithRoles', ("user:%s" % member,)) 105 84 res = aq_portal(query) 106 logger.info('CourseAdviser %s initiated student_search' % member) 107 certificate_levels = [] 108 if res: 109 certificate_levels = ['/'.join(f.getPath().split('/')[-2:]) for f in res] 110 cert_ids = [] 111 level_ids = [] 112 for cl in certificate_levels: 113 c,l = cl.split('/') 114 level_ids += l, 115 if c not in cert_ids: 116 cert_ids += c, 117 cert_brains = aq_portal(In("id",cert_ids)) 118 end_levels = {} 119 for cert_brain in cert_brains: 120 end_levels[cert_brain.getId] = cert_brain.getObject().getContent().end_level 121 for cl in certificate_levels[:]: 122 c,l = cl.split('/') 123 for prob in (10,20): 124 certificate_levels += "%s/%s" % (c,int(l) + prob), 125 if l == end_levels[c]: 126 certificate_levels += "%s/%s" % (c,int(l) + 100), 127 user_info['certificate_levels'] = certificate_levels 128 certificate_levels_str = " ".join(certificate_levels) 85 certificate_levels = ['/'.join(f.getPath().split('/')[-2:]) for f in res] 86 cert_ids = [] 87 level_ids = [] 88 for cl in certificate_levels: 89 c,l = cl.split('/') 90 level_ids += l, 91 if c not in cert_ids: 92 cert_ids += c, 93 cert_brains = aq_portal(In("id",cert_ids)) 94 end_levels = {} 95 for cert_brain in cert_brains: 96 end_levels[cert_brain.getId] = cert_brain.getObject().getContent().end_level 97 for cl in certificate_levels[:]: 98 c,l = cl.split('/') 99 for prob in (10,20): 100 certificate_levels += "%s/%s" % (c,int(l) + prob), 101 if l == end_levels[c]: 102 certificate_levels += "%s/%s" % (c,int(l) + 100), 103 user_info['certificate_levels'] = session_data['certificate_levels'] = certificate_levels 129 104 130 105 default = {'search_mode': 'student_id', … … 139 114 layout_mode='edit', 140 115 formaction="search_students", 141 faculties = fac_str,142 departments = dep_str,143 certificate_levels = certificate_levels_str,144 116 commit = False, 145 117 )
Note: See TracChangeset for help on using the changeset viewer.