Package ZenModel :: Module AdministrativeRoleable
[hide private]
[frames] | no frames]

Source Code for Module ZenModel.AdministrativeRoleable

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, Zenoss Inc. 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify it 
 7  # under the terms of the GNU General Public License version 2 as published by 
 8  # the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
11  # 
12  ########################################################################### 
13  """ 
14  AdministrativeRoleable.py 
15   
16  Created by Marc Irlandez on 2007-04-05. 
17  """ 
18   
19  import types 
20  from AccessControl import ClassSecurityInfo 
21  from Products.ZenModel.AdministrativeRole import AdministrativeRole 
22  from Globals import InitializeClass 
23  from ZenossSecurity import * 
24   
25 -class AdministrativeRoleable:
26 27 security = ClassSecurityInfo() 28 29 security.declareProtected(ZEN_ADMINISTRATORS_VIEW, 30 'getAdministrativeRoles')
31 - def getAdministrativeRoles(self):
32 "Get the Admin Roles on this device" 33 return self.adminRoles.objectValuesAll()
34 35 security.declareProtected(ZEN_ADMINISTRATORS_EDIT, 36 'manage_addAdministrativeRole')
37 - def manage_addAdministrativeRole(self, newId=None, REQUEST=None):
38 "Add a Admin Role to this device" 39 us = self.ZenUsers.getUserSettings(newId) 40 AdministrativeRole(us, self) 41 self.setAdminLocalRoles() 42 if REQUEST: 43 if us: 44 REQUEST['message'] = "Administrative Role Added" 45 return self.callZenScreen(REQUEST)
46 47 security.declareProtected(ZEN_ADMINISTRATORS_EDIT, 48 'manage_editAdministrativeRoles')
49 - def manage_editAdministrativeRoles(self, ids=(), role=(), 50 level=(), REQUEST=None):
51 """Edit list of admin roles. 52 """ 53 if type(ids) in types.StringTypes: 54 ids = [ids] 55 role = [role] 56 level = [level] 57 for i, id in enumerate(ids): 58 ar = self.adminRoles._getOb(id) 59 ar.update(role[i], level[i]) 60 self.setAdminLocalRoles() 61 if REQUEST: 62 REQUEST['message'] = "Administrative Roles Updated" 63 return self.callZenScreen(REQUEST)
64 65 66 security.declareProtected(ZEN_ADMINISTRATORS_EDIT, 67 'manage_deleteAdministrativeRole')
68 - def manage_deleteAdministrativeRole(self, delids=(), REQUEST=None):
69 "Delete a admin role to this device" 70 if type(delids) in types.StringTypes: 71 delids = [delids] 72 for userid in delids: 73 ar = self.adminRoles._getOb(userid, None) 74 if ar is not None: ar.delete() 75 self.manage_delLocalRoles((userid,)) 76 self.setAdminLocalRoles() 77 if REQUEST: 78 if delids: 79 REQUEST['message'] = "Administrative Roles Deleted" 80 return self.callZenScreen(REQUEST)
81
83 """List the user and their roles on an object""" 84 return [ (ar.id, (ar.role,)) for ar in self.adminRoles() ]
85 86
87 - def setAdminLocalRoles(self):
88 """Hook for setting permissions""" 89 pass
90 91 92 InitializeClass(AdministrativeRoleable) 93