Package Products :: Package Zuul :: Package routers :: Module manufacturers
[hide private]
[frames] | no frames]

Source Code for Module Products.Zuul.routers.manufacturers

  1  ############################################################################## 
  2  # 
  3  # Copyright (C) Zenoss, Inc. 2013, 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  import logging 
 11  log = logging.getLogger("zen.Manufacturers") 
 12  from pprint import pprint 
 13  from Products.ZenUtils.Ext import DirectResponse 
 14  from Products import Zuul 
 15  from Products.Zuul.decorators import require, serviceConnectionError 
 16  from Products.Zuul.routers import TreeRouter 
 17  from Products.ZenMessaging.audit import audit 
18 19 20 -class ManufacturersRouter(TreeRouter):
21 """ 22 Manufacturers and their products, and the instances of those products 23 """ 24
25 - def _getFacade(self):
26 return Zuul.getFacade('manufacturers', self.context)
27 28 @serviceConnectionError
29 - def addNewProduct(self, params=None):
30 """ 31 Add new product for the current manufacturer context 32 """ 33 facade = self._getFacade() 34 facade.addNewProduct(params) 35 audit('UI.Manufacturers.AddNewProduct', params['uid'], data_=params) 36 return DirectResponse.succeed()
37 38 @require('Manage DMD')
39 - def removeProducts(self, products):
40 """ 41 remove product(s) from a manufacturer 42 """ 43 facade = self._getFacade() 44 facade.removeProducts(products) 45 audit('UI.Manufacturers.RemoveProducts', products=products) 46 return DirectResponse.succeed()
47 48 @serviceConnectionError 49 @require('Manage DMD')
50 - def editProduct(self, params=None):
51 """ 52 Edit a product 53 """ 54 facade = self._getFacade() 55 oldData = facade.getProductData(params['uid'], params['oldname'])[0] 56 facade.editProduct(params) 57 58 audit('UI.Manufacturers.editProduct', params['uid'], 59 data_=params, oldData_=oldData) 60 61 return DirectResponse.succeed()
62 63 @serviceConnectionError
64 - def getProductsByManufacturer(self, uid, params={}):
65 """ 66 Returns products for the current context 67 """ 68 facade = self._getFacade() 69 data = facade.getProductsByManufacturer(uid, params) 70 71 return DirectResponse( data=Zuul.marshal(data) )
72 73 @serviceConnectionError
74 - def getProductData(self, uid, prodname):
75 """ 76 return all extra data for product id 77 """ 78 facade = self._getFacade() 79 data = facade.getProductData(uid, prodname) 80 return DirectResponse(data=Zuul.marshal(data) )
81 82 @serviceConnectionError
83 - def getProductInstances(self, uid, id, params={}):
84 """ 85 return all instances of this product 86 """ 87 facade = self._getFacade() 88 data = facade.getProductInstances(uid, id, params) 89 return DirectResponse(data=Zuul.marshal(data) )
90 91 @serviceConnectionError
92 - def getManufacturerData(self, uid):
93 """ 94 return all extra data for manufacturer id 95 """ 96 facade = self._getFacade() 97 data = facade.getManufacturerData(uid) 98 return DirectResponse(data=Zuul.marshal(data) )
99 100 @serviceConnectionError
101 - def getManufacturers(self):
102 """ 103 return all manufacturers 104 """ 105 facade = self._getFacade() 106 data = facade.getManufacturers() 107 return DirectResponse(data=Zuul.marshal(data))
108 109 @require('Manage DMD')
110 - def addManufacturer(self, id):
111 """ 112 add a manufacturer 113 """ 114 facade = self._getFacade() 115 facade.addManufacturer(id) 116 audit('UI.Manufacturers.addManufacturers', Manufacturer=id) 117 return DirectResponse.succeed()
118 119 @require('Manage DMD')
120 - def editManufacturer(self, params):
121 """ 122 edit a manufacturer 123 """ 124 facade = self._getFacade() 125 facade.editManufacturer(params) 126 audit('UI.Manufacturers.EditManufacturer', Manufacturer=params['name']) 127 return DirectResponse.succeed()
128 129 @require('Manage DMD')
130 - def deleteManufacturer(self, uid, params=None):
131 """ 132 remove a manufacturer 133 """ 134 facade = self._getFacade() 135 facade.deleteNode(uid) 136 audit('UI.Manufacturers.DeleteManufacturer', deletedManufacturer=uid) 137 return DirectResponse.succeed()
138 139 @require('Manage DMD')
140 - def moveProduct(self, moveFrom, moveTarget, ids):
141 """ 142 move products to a different organizer 143 """ 144 facade = self._getFacade() 145 facade.moveProduct(moveFrom, moveTarget, ids) 146 audit('UI.Manufacturers.MoveProduct', movedProducts=ids, target=moveTarget) 147 return DirectResponse.succeed()
148
149 - def returnTree(self, id):
150 """ 151 return a usable tree 152 """ 153 facade = self._getFacade() 154 data = facade.returnTree(id) 155 return data
156