source: main/waeup.sirp/branches/ulif-fasttables/src/waeup/sirp/permissions.py @ 7825

Last change on this file since 7825 was 4789, checked in by uli, 15 years ago

Merge changes from ulif-layout back into trunk (finally).

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1import grok
2from zc.sourcefactory.basic import BasicSourceFactory
3
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   
25class FacultyRead(grok.Permission):
26    grok.name('waeup.facultyread')
27   
28class PortalUser(grok.Role):
29    grok.name('waeup.PortalUser')
30    grok.permissions('waeup.facultyread', 'waeup.View', 'waeup.Public')
31
32class PortalManager(grok.Role):
33    grok.name('waeup.PortalManager')
34    grok.permissions('waeup.manageUniversity', 'waeup.manageUsers',
35                     'waeup.View', 'waeup.Public')
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.