Package Products :: Package ZenModel :: Module AdministrativeRole |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenModel.AdministrativeRole

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     7  #
     8  ##############################################################################
     9
    10
    11  from Products.ZenRelations.RelSchema import *
    12  from ZenModelRM import ZenModelRM
    13  from ZenossSecurity import *
    14
    15
    16 -class AdministrativeRole(ZenModelRM):
    17
    18      meta_type = "AdministrativeRole"
    19
    20      _relations = (
    21          ("userSetting", ToOne(ToMany, "Products.ZenModel.UserSettings", "adminRoles")),
    22          ("managedObject", ToOne(ToManyCont, "Products.ZenModel.AdministrativeRoleable", "adminRoles")),
    23      )
    24
    25      role = ZEN_USER_ROLE
    26
    27 -    def __init__(self, userSettings, managedObject):
    28          userid = userSettings.getId()
    29          ZenModelRM.__init__(self, userid)
    30          self.role = userSettings.defaultAdminRole
    31          self.id = userid
    32          managedObject = managedObject.primaryAq()
    33          managedObject.adminRoles._setObject(userid, self)
    34          self.userSetting.addRelation(userSettings)
    35          managedObject.manage_setLocalRoles(userid, (self.role,),)
    36          managedObject.index_object()
    37
    38
    39 -    def update(self, role):
    40          self.role = role
    41          managedObject = self.managedObject().primaryAq()
    42          managedObject.manage_setLocalRoles(self.getId(), (self.role,))
    43          managedObject.index_object()
    44
    45
    46 -    def delete(self):
    47          managedObject = self.managedObject().primaryAq()
    48          managedObject.manage_delLocalRoles((self.getId(),))
    49          managedObject.index_object()
    50          self.userSetting.removeRelation()
    51          self.managedObject.removeRelation()
    52
    53
    54 -    def email(self):
    55          return self.userSetting().email
    56
    57
    58 -    def pager(self):
    59          return self.userSetting().pager
    60
    61
    62 -    def userLink(self):
    63          return self.userSetting().getPrimaryUrlPath()
    64
    65 -    def managedObjectName(self):
    66          from Device import Device
    67          mo = self.managedObject()
    68          if isinstance(mo, Device) or mo.meta_type == 'Device':
    69              return mo.id
    70          return mo.getOrganizerName()
    71
    72 -    def getEventSummary(self):
    73          return self.managedObject().getEventSummary()
    74
    75 -    def managedObjectType(self):
    76          return self.managedObject().meta_type
    77
    78  DeviceAdministrativeRole = AdministrativeRole
    79  DevOrgAdministrativeRole = AdministrativeRole
    80