Changeset 7176 for main/waeup.sirp/trunk/src
- Timestamp:
- 23 Nov 2011, 07:21:03 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/layout.py
r7162 r7176 170 170 return 'waeup.Student' in roles 171 171 172 def getLocalRoles(self, account):173 """Return HTML tagged string with all local roles of a user account.174 """175 local_roles = account.getLocalRoles()176 local_roles_string = ''177 site_url = self.url(grok.getSite())178 for local_role in local_roles.keys():179 role_title = dict(getRoles())[local_role].title180 objects_string = ''181 for object in local_roles[local_role]:182 objects_string += '<a href="%s">%s</a>, ' %(self.url(object),183 self.url(object).replace(site_url,''))184 local_roles_string += '%s: <br />%s <br />' %(role_title,185 objects_string.rstrip(', '))186 return local_roles_string187 188 def getGlobalRoles(self, account):189 """Return HTML tagged string with all global roles of a user account.190 """191 global_roles = account.roles192 global_roles_string = ''193 for global_role in global_roles:194 role_title = dict(getRoles())[global_role].title195 global_roles_string += '%s <br />' % role_title196 return global_roles_string197 198 172 def update(self): 199 173 """Include the resources required by the chosen skin/theme. -
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r7172 r7176 37 37 ISessionConfiguration, ISessionConfigurationAdd, academic_sessions_vocab, 38 38 IPasswordValidator) 39 from waeup.sirp.permissions import get_users_with_local_roles 39 from waeup.sirp.permissions import ( 40 get_users_with_local_roles, 41 getGlobalRolesForAccount, getLocalRolesForAccount) 40 42 from waeup.sirp.university.catalog import search 41 43 from waeup.sirp.university.vocabularies import course_levels … … 259 261 self.context.delUser(userid) 260 262 self.flash('User %s successfully deleted.' % userid) 263 264 def getLocalRoles(self, account): 265 return getLocalRolesForAccount(self, account) 266 267 def getGlobalRoles(self, account): 268 return getGlobalRolesForAccount(account) 261 269 262 270 class AddUserFormPage(WAeUPAddFormPage): -
main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/userscontainerpage.pt
r7172 r7176 21 21 <td tal:content="account/title">Title</td> 22 22 <td tal:content="account/description">Description</td> 23 <td tal:content="structure python: layout.getGlobalRoles(account)">Global Roles</td>24 <td tal:content="structure python: layout.getLocalRoles(account)">Local Roles</td>23 <td tal:content="structure python:view.getGlobalRoles(account)">Global Roles</td> 24 <td tal:content="structure python:view.getLocalRoles(account)">Local Roles</td> 25 25 <td class="text-right"> 26 26 <form method="post"> -
main/waeup.sirp/trunk/src/waeup/sirp/permissions.py
r7168 r7176 4 4 from zope.securitypolicy.interfaces import IRole, IPrincipalRoleMap 5 5 from waeup.sirp.interfaces import ILocalRolesAssignable 6 from waeup.sirp.utils.helpers import get_user_account 6 7 7 8 class Public(grok.Permission): … … 118 119 """ 119 120 return sorted([x.id for x in getWAeUPRoles()]) 121 122 def getLocalRolesForAccount(view, account): 123 """Return HTML tagged string with all local roles of a user account. 124 """ 125 local_roles = account.getLocalRoles() 126 local_roles_string = '' 127 site_url = view.url(grok.getSite()) 128 for local_role in local_roles.keys(): 129 role_title = dict(getRoles())[local_role].title 130 objects_string = '' 131 for object in local_roles[local_role]: 132 objects_string += '<a href="%s">%s</a>, ' %(view.url(object), 133 view.url(object).replace(site_url,'')) 134 local_roles_string += '%s: <br />%s <br />' %(role_title, 135 objects_string.rstrip(', ')) 136 return local_roles_string 137 138 def getGlobalRolesForAccount(account): 139 """Return HTML tagged string with all global roles of a user account. 140 """ 141 global_roles = account.roles 142 global_roles_string = '' 143 for global_role in global_roles: 144 role_title = dict(getRoles())[global_role].title 145 global_roles_string += '%s <br />' % role_title 146 return global_roles_string 147 148 def getMyRoles(view): 149 account = get_user_account(view.request) 150 if account: 151 global_roles = getGlobalRoles(account) 152 local_roles = getLocalRoles(account) 153 return [global_roles,local_roles] 154 return 120 155 121 156
Note: See TracChangeset for help on using the changeset viewer.