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

# Source Code for Module Products.ZenModel.AdministrativeRole

     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  from Products.ZenRelations.RelSchema import *
    15  from ZenModelRM import ZenModelRM
    16  from ZenossSecurity import *
    17
    18
    19 -class AdministrativeRole(ZenModelRM):
    20
    21      meta_type = "AdministrativeRole"
    22
    23      _relations = (
    24          ("userSetting", ToOne(ToMany, "Products.ZenModel.UserSettings", "adminRoles")),
    25          ("managedObject", ToOne(ToManyCont, "Products.ZenModel.AdministrativeRoleable", "adminRoles")),
    26      )
    27
    28      level = 1
    29      role = ZEN_USER_ROLE
    30
    31 -    def __init__(self, userSettings, managedObject):
    32          userid = userSettings.getId()
    33          ZenModelRM.__init__(self, userid)
    34          self.role = userSettings.defaultAdminRole
    35          self.level = userSettings.defaultAdminLevel
    36          self.id = userid
    37          managedObject = managedObject.primaryAq()
    38          managedObject.adminRoles._setObject(userid, self)
    39          self.userSetting.addRelation(userSettings)
    40          managedObject.manage_setLocalRoles(userid, (self.role,),)
    41          managedObject.index_object()
    42
    43
    44 -    def update(self, role, level):
    45          self.role = role
    46          self.level = level
    47          managedObject = self.managedObject().primaryAq()
    48          managedObject.manage_setLocalRoles(self.getId(), (self.role,))
    49          managedObject.index_object()
    50
    51
    52 -    def delete(self):
    53          managedObject = self.managedObject().primaryAq()
    54          managedObject.manage_delLocalRoles((self.getId(),))
    55          managedObject.index_object()
    56          self.userSetting.removeRelation()
    57          self.managedObject.removeRelation()
    58
    59
    60 -    def email(self):
    61          return self.userSetting().email
    62
    63
    64 -    def pager(self):
    65          return self.userSetting().pager
    66
    67
    68 -    def userLink(self):
    69          return self.userSetting().getPrimaryUrlPath()
    70
    71 -    def managedObjectName(self):
    72          mo = self.managedObject()
    73          if mo.meta_type == 'Device':
    74              return mo.id
    75          return mo.getOrganizerName()
    76
    77 -    def getEventSummary(self):
    78          return self.managedObject().getEventSummary()
    79
    80 -    def managedObjectType(self):
    81          return self.managedObject().meta_type
    82
    83  DeviceAdministrativeRole = AdministrativeRole
    84  DevOrgAdministrativeRole = AdministrativeRole
    85