Changeset 7162 for main/waeup.sirp/trunk/src/waeup/sirp/browser
- Timestamp:
- 22 Nov 2011, 07:25:31 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/browser
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt
r7149 r7162 135 135 We can edit user bob: 136 136 137 >>> browser.getControl(" edit", index=0).click()137 >>> browser.getControl("manage", index=0).click() 138 138 >>> browser.getControl("Save", index=0).click() 139 139 >>> browser.getControl("Cancel", index=0).click() -
main/waeup.sirp/trunk/src/waeup/sirp/browser/layout.py
r7137 r7162 16 16 from waeup.sirp.students.interfaces import IStudentNavigation 17 17 from waeup.sirp.authentication import get_principal_role_manager 18 from waeup.sirp.permissions import getRoles 18 19 19 20 grok.templatedir('templates') … … 165 166 def isStudent(self): 166 167 prm = get_principal_role_manager() 167 roles = [x[0] for x in prm.getRolesForPrincipal(self.request.principal.id)] 168 roles = [x[0] for x in 169 prm.getRolesForPrincipal(self.request.principal.id)] 168 170 return 'waeup.Student' in roles 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].title 180 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_string 187 188 def getGlobalRoles(self, account): 189 """Return HTML tagged string with all global roles of a user account. 190 """ 191 global_roles = account.roles 192 global_roles_string = '' 193 for global_role in global_roles: 194 role_title = dict(getRoles())[global_role].title 195 global_roles_string += '%s <br />' % role_title 196 return global_roles_string 169 197 170 198 def update(self): -
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r7149 r7162 37 37 ISessionConfiguration, ISessionConfigurationAdd, academic_sessions_vocab, 38 38 IPasswordValidator) 39 from waeup.sirp.permissions import get_users_with_local_roles , getRoles39 from waeup.sirp.permissions import get_users_with_local_roles 40 40 from waeup.sirp.university.catalog import search 41 41 from waeup.sirp.university.vocabularies import course_levels … … 253 253 title = 'Portal Users' 254 254 255 def update(self, userid=None, adduser=None, edit=None, delete=None):256 if editis not None and userid is not None:257 self.redirect(self.url(userid) )255 def update(self, userid=None, adduser=None, manage=None, delete=None): 256 if manage is not None and userid is not None: 257 self.redirect(self.url(userid) + '/@@manage') 258 258 if delete is not None and userid is not None: 259 259 self.context.delUser(userid) 260 260 self.flash('User %s successfully deleted.' % userid) 261 262 def getLocalRoles(self,account):263 local_roles = account.getLocalRoles()264 local_roles_string = ''265 site_url = self.url(grok.getSite())266 for local_role in local_roles.keys():267 role_title = dict(getRoles())[local_role].title268 objects_string = ''269 for object in local_roles[local_role]:270 objects_string += '<a href="%s">%s</a>, ' %(self.url(object),271 self.url(object).replace(site_url,''))272 local_roles_string += '%s: %s <br />' %(role_title,273 objects_string.rstrip(', '))274 return local_roles_string275 276 def getGlobalRoles(self,account):277 global_roles = account.roles278 global_roles_string = ''279 for global_role in global_roles:280 role_title = dict(getRoles())[global_role].title281 global_roles_string += '%s <br />' % role_title282 return global_roles_string283 261 284 262 class AddUserFormPage(WAeUPAddFormPage): … … 316 294 self.redirect(self.url(self.context)) 317 295 318 class User EditFormPage(WAeUPEditFormPage):319 """ Edita user account.296 class UserManageFormPage(WAeUPEditFormPage): 297 """Manage a user account. 320 298 """ 321 299 grok.context(IUserAccount) 322 grok.name('index') 323 324 form_fields = grok.AutoFields(IUserAccount) 300 grok.name('manage') 301 grok.template('usereditformpage') 302 303 form_fields = grok.AutoFields(IUserAccount).omit('name') 325 304 grok.require('waeup.manageUsers') 326 305 327 title = "Edit user" 306 title = "Portal Users" 307 308 def label(self): 309 return "Edit user %s" % self.context.__name__ 328 310 329 311 @grok.action('Save') -
main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/usercontainerpage.pt
r6511 r7162 21 21 <td tal:content="account/title">Title</td> 22 22 <td tal:content="account/description">Description</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>23 <td tal:content="structure python:layout.getGlobalRoles(account)">Global Roles</td> 24 <td tal:content="structure python:layout.getLocalRoles(account)">Local Roles</td> 25 25 <td class="text-right"> 26 26 <form method="post"> 27 27 <input type="hidden" name="userid" 28 28 tal:attributes="value account/name"/> 29 <input type="submit" name=" edit" value="edit" />29 <input type="submit" name="manage" value="manage" /> 30 30 <input type="submit" name="delete" value="delete" /> 31 31 </form> -
main/waeup.sirp/trunk/src/waeup/sirp/browser/tests/test_permissions.py
r6686 r7162 43 43 # The pages that should only be accessible by manager... 44 44 '/@@manage', '/@@administration', '/faculties/@@search', 45 '/users/@@index', '/users/@@add', '/users/alice/@@ index',45 '/users/@@index', '/users/@@add', '/users/alice/@@manage', 46 46 '/datacenter/@@index', '/datacenter/@@upload', '/datacenter/@@import1', 47 47 '/datacenter/@@import2', '/datacenter/@@import3', '/datacenter/@@import4',
Note: See TracChangeset for help on using the changeset viewer.