Changeset 6163 for main/waeup.sirp/trunk/src
- Timestamp:
- 20 May 2011, 12:01:50 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r6161 r6163 36 36 IWAeUPXMLImporter, IWAeUPXMLExporter, IBatchProcessor, 37 37 ILocalRolesAssignable) 38 from waeup.sirp.permissions import get_users_with_local_roles 38 39 from waeup.sirp.university.catalog import search 39 40 from waeup.sirp.university.vocabularies import course_levels … … 51 52 view.redirect(view.url(view.context, u'@@manage')+'#tab-%s' % tab) 52 53 return 53 54 def get_users_with_local_roles(view):55 role_manager = IPrincipalRoleManager(view.context)56 role_map = IPrincipalRoleMap(view.context)57 for item in role_map.getPrincipalsAndRoles():58 local_role = item[0]59 user_name = item[1]60 setting = item[2]61 user = grok.getSite()['users'].get(user_name,None)62 roles_dict = view.context.local_roles63 local_role_title = roles_dict[local_role]64 if user:65 yield(dict(user_name=user_name, user_title=user.description,66 local_role=local_role, local_role_title=local_role_title,67 setting=setting))68 else:69 yield(dict(user_name=user_name, user_title=user_name,70 local_role=local_role, local_role_title=local_role_title,71 setting=setting))72 54 73 55 def del_local_roles(view, tab, **data): … … 1027 1009 1028 1010 def getUsersWithLocalRoles(self): 1029 return get_users_with_local_roles(self )1011 return get_users_with_local_roles(self.context) 1030 1012 1031 1013 # ToDo: Show warning message before deletion … … 1190 1172 super(DepartmentManageFormPage, self).update() 1191 1173 return 1192 1174 1193 1175 def getLocalRoles(self): 1194 1176 roles = ILocalRolesAssignable(self.context) … … 1201 1183 url = self.url(val) 1202 1184 yield(dict(url=url, name=key, val=val)) 1203 1185 1204 1186 def getUsersWithLocalRoles(self): 1205 return get_users_with_local_roles(self )1187 return get_users_with_local_roles(self.context) 1206 1188 1207 1189 @grok.action('Save') -
main/waeup.sirp/trunk/src/waeup/sirp/permissions.py
r6162 r6163 2 2 from zope.component import getUtilitiesFor 3 3 from zope.interface import Interface 4 from zope.securitypolicy.interfaces import IRole 4 from zope.securitypolicy.interfaces import IRole, IPrincipalRoleMap 5 5 from waeup.sirp.interfaces import ILocalRolesAssignable 6 6 … … 136 136 name=name, 137 137 title=role.title, 138 description 138 description=role.description) 139 139 for name, role in self._roles] 140 140 … … 143 143 """ 144 144 return [name for name, role in self._roles] 145 146 def get_users_with_local_roles(context): 147 """Get a list of dicts representing the local roles set for `context`. 148 149 Each dict returns `user_name`, `user_title`, `local_role`, 150 `local_role_title`, and `setting` for each entry in the local 151 roles map of the `context` object. 152 """ 153 role_map = IPrincipalRoleMap(context) 154 for local_role, user_name, setting in role_map.getPrincipalsAndRoles(): 155 user = grok.getSite()['users'].get(user_name,None) 156 user_title = getattr(user, 'description', user_name) 157 local_role_title = getRoles()[local_role].title 158 yield dict(user_name = user_name, 159 user_title = user_title, 160 local_role = local_role, 161 local_role_title = local_role_title, 162 setting = setting)
Note: See TracChangeset for help on using the changeset viewer.