Changeset 881
- Timestamp:
- 16 Nov 2006, 22:42:08 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 4 edited
- 1 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/PatchCPSUserFolderUserFolder.py
r880 r881 8 8 security.declarePublic('getRolesInContext') 9 9 def getRolesInContext(self, object): 10 """Return the list of roles assigned to the user, 11 including local roles assigned in context of 12 the passed in object.""" 10 """Get the list of roles assigned to the user. 11 This includes local roles assigned in the context of 12 the passed in object. 13 Knows about local roles blocking (roles starting with '-'). 14 """ 13 15 name = self.getUserName() 14 16 roles = self.getRoles() 15 groups = self.getGroups() + ('role:Anonymous',)16 if 'Authenticated' in roles:17 groups = groups + ('role:Authenticated',)17 # deal with groups 18 groups = self.getComputedGroups() 19 # end groups 18 20 local = {} 19 21 stop_loop = 0 22 real_object = object 20 23 object = aq_inner(object) 21 24 while 1: … … 55 58 if stop_loop: 56 59 break 57 inner = getattr(object, 'aq_inner', object) 58 parent = getattr(inner, 'aq_parent', None) 59 if parent is not None: 60 object = parent 60 if hasattr(object, 'aq_parent'): 61 object = aq_inner(object.aq_parent) 61 62 continue 62 63 if hasattr(object, 'im_self'): 63 object = object.im_self 64 object = getattr(object, 'aq_inner', object) 64 object = aq_inner(object.im_self) 65 65 continue 66 66 break … … 70 70 roles.append(r) 71 71 ## patch to assign dynamic roles for WAeUP 72 info = self.getStudentInfo()73 72 while 1: 74 if info is None:73 if not hasattr(real_object,'portal_type'): 75 74 break 76 if info['course'] is None:75 if real_object.portal_type != "Student": 77 76 break 78 res = self.portal_catalog(portal_type="Department",id=info['course_doc'].department) 77 #import pdb;pdb.set_trace() 78 dep_id = real_object.study_course.getContent().department 79 res = self.portal_catalog(portal_type="Department",id=dep_id) 79 80 if len(res) != 1: 80 81 break … … 86 87 return roles 87 88 88 security.declarePublic('allowed') 89 def allowed(self, object, object_roles=None): 90 """Check whether the user has access to object. The user must 91 have one of the roles in object_roles to allow access.""" 92 93 if object_roles is _what_not_even_god_should_do: 94 return 0 95 96 # Short-circuit the common case of anonymous access. 97 if object_roles is None or 'Anonymous' in object_roles: 98 return 1 99 100 # Provide short-cut access if object is protected by 'Authenticated' 101 # role and user is not nobody 102 if 'Authenticated' in object_roles and ( 103 self.getUserName() != 'Anonymous User'): 104 return 1 105 106 # Check for a role match with the normal roles given to 107 # the user, then with local roles only if necessary. We 108 # want to avoid as much overhead as possible. 109 user_roles = self.getRoles() 110 for role in object_roles: 111 if role in user_roles: 112 if self._check_context(object): 113 return 1 114 return None 115 116 # Check local roles, calling getRolesInContext to avoid too much 117 # complexity, at the expense of speed. 118 for role in self.getRolesInContext(object): 119 if role in object_roles: 120 return 1 121 122 return None 123 124 from Products.CPSUserFolder import UserFolderWithGroups 125 UserFolderWithGroups.getRolesInContext = getRolesInContext 126 UserFolderWithGroups.allowed = allowed 89 from Products.CPSUserFolder.CPSUserFolder import CPSUser 90 CPSUser.getRolesInContext = getRolesInContext -
WAeUP_SRP/trunk/PatchCPSUserFolderUserFolderWithGroups.py
r880 r881 19 19 stop_loop = 0 20 20 object = aq_inner(object) 21 import pdb; pdb.set_trace() 21 22 while 1: 22 23 # Collect all roles info -
WAeUP_SRP/trunk/__init__.py
r880 r881 14 14 import PatchCatalogToolXMLAdapter 15 15 import PatchCPSSchemasAttributeStorageAdapter 16 import PatchCPSUserFolderUserFolderWithGroups 17 import PatchCPSUserFolderUserFolder 16 18 import PatchBasicWidgetsCPSStringWidget 17 import PatchCPSUserFolderUserFolderWithGroups18 19 # Only for CPS 3.4.1. In 3.4.2 and later this should be fixed. 19 20 import PatchCPSDefaultImportExport -
WAeUP_SRP/trunk/exportimport.py
r502 r881 74 74 site = context.getSite() 75 75 pm = site.portal_membership 76 pm.setLocalGroupRoles(site,['role:Authenticated',],'SectionReader')76 #pm.setLocalGroupRoles(site,['group:ClearanceOfficers',],'SectionReader') 77 77 78 78 importWAeUPTable(site.portal_accommodation, '', context,'accommodation') -
WAeUP_SRP/trunk/skins/waeup_student/co_searchStudents.py
r875 r881 1 ## Script (Python) "co_search "1 ## Script (Python) "co_searchStudents" 2 2 ##bind container=container 3 3 ##bind context=context … … 62 62 ob=default, 63 63 layout_mode='edit', 64 formaction="co_search "64 formaction="co_searchStudents" 65 65 ) 66 66 if psm == '': … … 160 160 if items: 161 161 for item in items: 162 info = context.getStudentInfo(item) 163 if context.isClearanceOfficer(info): 162 #if context.isClearanceOfficer(info): 163 droles = member.getRolesInContext(item) 164 if "ClearanceOfficer" in droles: 165 info = context.getStudentInfo(item) 164 166 students.append(info) 165 return context.co_search_ form(rendered = rend,167 return context.co_search_view(rendered = rend, 166 168 psm = "%d,%d matching Students found QS = %s" %\ 167 169 (len(review_set),len(search_set),query_step), … … 170 172 is_manager = is_manager, 171 173 ) 172 return context.co_search_ form(rendered = rend,174 return context.co_search_view(rendered = rend, 173 175 psm = """Step: %s found: %s Your search for "%s" in %s with state %s failed.<br\>%s""" % (query_step,len(items),st,what,state,bools), 174 176 students = students, -
WAeUP_SRP/trunk/skins/waeup_student/students_index.py
r874 r881 24 24 25 25 if "ClearanceOfficers" in member.getGroups(): 26 return redirect("%s/co_search " % students_url)26 return redirect("%s/co_searchStudents" % students_url) 27 27 if context.isManager(): 28 28 return redirect("%s/searchStudents" % students_url)
Note: See TracChangeset for help on using the changeset viewer.