1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""Manufacturer
15
16 Manufacturer is a base class that represents a vendor of Products.
17
18 $Id: Manufacturer.py,v 1.11 2004/03/26 23:58:44 edahl Exp $"""
19
20 __version__ = "$Revision: 1.11 $"[11:-2]
21
22 import types
23
24 from Globals import DTMLFile, InitializeClass
25 from AccessControl import ClassSecurityInfo
26 from AccessControl import Permissions as permissions
27 from Products.ZenModel.ZenossSecurity import *
28 from Products.ZenWidgets import messaging
29
30 from Products.ZenRelations.RelSchema import *
31
32 from ZenModelRM import ZenModelRM
33 from ZenPackable import ZenPackable
34
35
45
46 addManufacturer = DTMLFile('dtml/addManufacturer',globals())
47
49 """Manufacturer object"""
50 portal_type = meta_type = 'Manufacturer'
51
52 url = ''
53 supportNumber = ''
54 address1 = ''
55 address2 = ''
56 city = ''
57 state = ''
58 zip = ''
59 country = ''
60
61 _properties = (
62 {'id':'url', 'type':'string', 'mode':'w'},
63 {'id':'supportNumber', 'type':'string', 'mode':'w'},
64 {'id':'address1', 'type':'string', 'mode':'w'},
65 {'id':'address2', 'type':'string', 'mode':'w'},
66 {'id':'city', 'type':'string', 'mode':'w'},
67 {'id':'state', 'type':'string', 'mode':'w'},
68 {'id':'zip', 'type':'string', 'mode':'w'},
69 {'id':'country', 'type':'string', 'mode':'w'},
70 )
71
72 _relations = ZenPackable._relations + (
73 ("products", ToManyCont(ToOne,"Products.ZenModel.ProductClass","manufacturer")),
74 )
75
76
77 factory_type_information = (
78 {
79 'id' : 'Manufacturer',
80 'meta_type' : 'Manufacturer',
81 'description' : """Arbitrary device grouping class""",
82 'icon' : 'Manufacturer_icon.gif',
83 'product' : 'ZenModel',
84 'factory' : 'manage_addManufacturer',
85 'immediate_view' : 'viewManufacturerOverview',
86 'actions' :
87 (
88 { 'id' : 'overview'
89 , 'name' : 'Overview'
90 , 'action' : 'viewManufacturerOverview'
91 , 'permissions' : (permissions.view, )
92 },
93 { 'id' : 'edit'
94 , 'name' : 'Edit'
95 , 'action' : 'editManufacturer'
96 , 'permissions' : ("Manage DMD", )
97 },
98 { 'id' : 'config'
99 , 'name' : 'zProperties'
100 , 'action' : 'zPropertyEdit'
101 , 'permissions' : ("Manage DMD",)
102 },
103 { 'id' : 'viewHistory'
104 , 'name' : 'Modifications'
105 , 'action' : 'viewHistory'
106 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,)
107 },
108 )
109 },
110 )
111
112 security = ClassSecurityInfo()
113
114
116 """Return the number of products for this manufacturer.
117 """
118 return self.products.countObjects()
119
120
128
129
138
139
140 - def moveProducts(self, moveTarget=None, ids=None, REQUEST=None):
152
153
155 """Add a product to this manufacturer based on its factory type.
156 """
157 prod = self._getOb(prodName, None)
158 if not prod:
159 prod = factory(prodName)
160 self.products._setObject(prod.id, prod)
161 prod = self.products._getOb(prod.id)
162 return prod
163
164
171
172
174 """return a list of all products this Manufacturer makes"""
175 prods = [""]
176 prods.extend(map(lambda x: x.getId(),
177 Manufacturer.products.objectValuesAll()))
178 prods.sort()
179 return prods
180
181
182 security.declareProtected('Manage DMD', 'manage_editManufacturer')
183 - def manage_editManufacturer(self, id='',
184 url = '', supportNumber = '',
185 address1 = '', address2 = '',
186 city = '', state = '', zip = '', country = '', REQUEST=None):
206
207
208 InitializeClass(Manufacturer)
209