source: main/waeup.sirp/trunk/src/waeup/sirp/permissions.py @ 5421

Last change on this file since 5421 was 5410, checked in by Henrik Bettermann, 14 years ago

Manager gets all permissions.

  • Property svn:eol-style set to native
File size: 1.9 KB
RevLine 
[3521]1import grok
[4789]2from zc.sourcefactory.basic import BasicSourceFactory
[3521]3
[4789]4class Public(grok.Permission):
5    """Everyone-can-do-this-permission.
6
7    This permission is meant to be applied to objects/views/pages
8    etc., that should be usable/readable by everyone.
9
10    We need this to be able to tune default permissions more
11    restrictive and open up some dedicated objects like the front
12    page.
13    """
14    grok.name('waeup.Public')
15
16class ViewPermission(grok.Permission):
17    grok.name('waeup.View')
18
19class ManageUniversity(grok.Permission):
20    grok.name('waeup.manageUniversity')
21
22class ManageUsers(grok.Permission):
23    grok.name('waeup.manageUsers')
24   
[3521]25class FacultyRead(grok.Permission):
26    grok.name('waeup.facultyread')
[4789]27   
28class PortalUser(grok.Role):
29    grok.name('waeup.PortalUser')
30    grok.permissions('waeup.facultyread', 'waeup.View', 'waeup.Public')
[3521]31
[4789]32class PortalManager(grok.Role):
33    grok.name('waeup.PortalManager')
34    grok.permissions('waeup.manageUniversity', 'waeup.manageUsers',
[5410]35                     'waeup.View', 'waeup.Public','waeup.manageACBatches')
[4789]36
37def getRoles():
38    app = grok.getSite()
39    app = None
40    manager = None
41    if app is not None:
42        from zope.securitypolicy.interfaces import IRolePermissionManager
43        manager = IRolePermissionManager(app, None)
44    else:
45        from zope.securitypolicy.rolepermission import (
46            rolePermissionManager as manager)
47    role_permission_map =  manager.getRolesAndPermissions()
48    result = dict()
49    for item in role_permission_map:
50        if not item[1].startswith('waeup.'):
51            # Ignore non-WAeUP roles...
52            continue
53        result[item[1]] = True
54    return sorted(result.keys())
55
56class RoleSource(BasicSourceFactory):
57    def getValues(self):
58        return getRoles()
59    def getTitle(self, value):
60        if isinstance(value, basestring):
61            return value.split('.', 2)[1]
Note: See TracBrowser for help on using the repository browser.