1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""Location
15
16 $Id: Location.py,v 1.12 2004/04/22 19:08:47 edahl Exp $"""
17
18 __version__ = "$Revision: 1.12 $"[11:-2]
19
20 from Globals import InitializeClass
21 from Globals import DTMLFile
22
23 from AccessControl import ClassSecurityInfo
24
25 from AccessControl import Permissions as permissions
26
27 from Products.ZenRelations.RelSchema import *
28
29 from DeviceOrganizer import DeviceOrganizer
30 from ZenPackable import ZenPackable
31
32 from Products.ZenUtils.json import json
33
43
44
45 addLocation = DTMLFile('dtml/addLocation',globals())
46
47
48 -class Location(DeviceOrganizer, ZenPackable):
49 """
50 Location is a DeviceGroup Organizer that manages physical device Locations.
51 """
52
53
54 dmdRootName = "Locations"
55
56 address = ''
57
58 portal_type = meta_type = event_key = 'Location'
59
60 _properties = DeviceOrganizer._properties + (
61 {'id':'address','type':'string','mode':'w'},
62 )
63
64 _relations = DeviceOrganizer._relations + ZenPackable._relations + (
65 ("devices", ToMany(ToOne,"Products.ZenModel.Device","location")),
66 ("networks", ToMany(ToOne,"Products.ZenModel.IpNetwork","location")),
67 )
68
69
70 factory_type_information = (
71 {
72 'immediate_view' : 'deviceOrganizerStatus',
73 'actions' :
74 (
75 { 'id' : 'status'
76 , 'name' : 'Status'
77 , 'action' : 'deviceOrganizerStatus'
78 , 'permissions' : (permissions.view,)
79 },
80 { 'id' : 'events'
81 , 'name' : 'Events'
82 , 'action' : 'viewEvents'
83 , 'permissions' : (permissions.view,)
84 },
85
86
87
88
89
90 { 'id' : 'manage'
91 , 'name' : 'Administration'
92 , 'action' : 'deviceOrganizerManage'
93 , 'permissions' : ('Manage DMD',)
94 },
95 { 'id' : 'geomap'
96 , 'name' : 'Map'
97 , 'action' : 'locationGeoMap'
98 , 'permissions' : (permissions.view,)
99 },
100 )
101 },
102 )
103
104 security = ClassSecurityInfo()
105
107 """Sets the mailing address for this location"""
108 self.address = address
109
111 """ Returns child link data ready for GMaps """
112 return self.dmd.ZenLinkManager.getChildLinks(self)
113
119
121 """
122 Gather data for Google Maps. This is not a JSON method; it must be put
123 into a data structure appropriate for JS consumption by another method
124 (specifically, getChildGeomapData, below).
125 """
126 address = self.address
127 psthresh = self.dmd.prodStateDashboardThresh
128 summary = self.getEventSummary(prodState=psthresh)
129 colors = 'red orange yellow green green'.split()
130 color = 'green'
131 for i in range(5):
132 if summary[i][1]+summary[i][2]>0:
133 color = colors[i]
134 break
135 link = self.absolute_url_path()
136 linkToMap = self.numMappableChildren()
137 if linkToMap:
138 link+='/locationGeoMap'
139 summarytext = self.mapTooltip()
140 return [address, color, link, summarytext]
141
142 @json
154
156 """ Returns geomap info on cousin nodes that should be
157 included in the view due to outside linking.
158 """
159 data = []
160
161 return data
162
163 InitializeClass(Location)
164