def post(self): update = self.request.get('update') if update == 'Yes': iKey = self.request.get('itemKey') currentKey = ndb.Key(urlsafe=iKey) item = currentKey.get() item.Type = self.request.get('itemType') item.Name = self.request.get('itemName') item.Description = self.request.get('itemDesc') item.Price = self.request.get('itemPrice') item.Quantity = self.request.get('itemQty') item.Store = self.request.get('itemStorage') item.put() self.display_message('Item successfully updated\ <br /><form action="/admin/inventory" method="post">\ <input type="hidden" name="location" value="item">\ <input type="submit" value="Back">\ </form>') iKey = self.request.get('itemKey') currentKey = ndb.Key(urlsafe=iKey) currentItem = currentKey.get() warehouses_query = models.Warehouse.query( ancestor=models.warehouse_key('mainUser')).order( models.Warehouse.Name) warehouses = warehouses_query.fetch(60) params = { 'item': currentItem, 'itemKey': iKey, 'warehouses': warehouses } self.render_template('editItem.html', params)
def post(self): update = self.request.get('update') if update=='Yes': iKey = self.request.get('itemKey') currentKey = ndb.Key(urlsafe=iKey) item = currentKey.get() item.Type = self.request.get('itemType') item.Name = self.request.get('itemName') item.Description = self.request.get('itemDesc') item.Price = self.request.get('itemPrice') item.Quantity = self.request.get('itemQty') item.Store = self.request.get('itemStorage') item.put() self.display_message('Item successfully updated\ <br /><form action="/admin/inventory" method="post">\ <input type="hidden" name="location" value="item">\ <input type="submit" value="Back">\ </form>') iKey = self.request.get('itemKey') currentKey = ndb.Key(urlsafe=iKey) currentItem = currentKey.get() warehouses_query = models.Warehouse.query(ancestor=models.warehouse_key('mainUser')).order(models.Warehouse.Name) warehouses = warehouses_query.fetch(60) params = { 'item': currentItem, 'itemKey': iKey, 'warehouses': warehouses } self.render_template('editItem.html',params)
def post(self): processType = self.request.get('process') pageType = self.request.get('location') delete = self.request.get('delete') deleteitem = self.request.get('deleteitem') if deleteitem=='Yes': iKey = self.request.get('itemKey') currentKey = ndb.Key(urlsafe=iKey) currentKey.delete() if delete=='Yes': iKey = self.request.get('warehouseKey') currentKey = ndb.Key(urlsafe=iKey) currentKey.delete() if processType=='Add_Warehouse': #self.response.write('WAREHOUSE ADDED') warehouse = models.Warehouse(parent=models.warehouse_key('mainUser')) warehouse.Name = self.request.get('warehouseName') warehouse.Location = self.request.get('warehouseLocation') warehouse.put() elif processType=='Add_Item': #self.response.write('ITEM ADDED') item = models.Item(parent=models.item_key('warehouse01')) item.Type = self.request.get('itemType') item.Name = self.request.get('itemName') item.Description = self.request.get('itemDesc') item.Price = self.request.get('itemPrice') item.Quantity = self.request.get('itemQty') item.Store = self.request.get('itemStorage') item.put() items_query = models.Item.query(ancestor=models.item_key('warehouse01')).order(models.Item.Type) #items_query = Item.query(models.Item.Type=='Basic Air Con') #items_query = Item.query().order(models.Item.Type, models.Item.Store) items = items_query.fetch(60) itemKeys = items_query.fetch(60, keys_only=True) keyList = [] for i in itemKeys: keyList.append(i.urlsafe()) #linking key and object together mainItemList = zip(items, keyList) warehouses_query = models.Warehouse.query(ancestor=models.warehouse_key('mainUser')).order(models.Warehouse.Name) warehouses = warehouses_query.fetch(60) warehousesKeys = warehouses_query.fetch(60, keys_only=True) warehousesList = [] for i in warehousesKeys: warehousesList.append(i.urlsafe()) warehouseitemexist = [] for i in warehouses: exist = False for j in items: if i.Name == j.Store: exist = True warehouseitemexist.append(True) break if not exist: warehouseitemexist.append(False) mainWarehousesList = zip(warehouses, warehousesList, warehouseitemexist) params = { 'process': self.request.get('process'), 'items': items, 'itemKeys': itemKeys, 'mainItemList': mainItemList, 'warehouses': warehouses, 'warehousesKeys': warehousesKeys, 'mainWarehousesList': mainWarehousesList, } if pageType == 'warehouse': self.render_template('warehouse.html',params) if pageType == 'item' or location == 'item': self.render_template('inventory.html',params)
def post(self): processType = self.request.get('process') pageType = self.request.get('location') delete = self.request.get('delete') deleteitem = self.request.get('deleteitem') if deleteitem == 'Yes': iKey = self.request.get('itemKey') currentKey = ndb.Key(urlsafe=iKey) currentKey.delete() if delete == 'Yes': iKey = self.request.get('warehouseKey') currentKey = ndb.Key(urlsafe=iKey) currentKey.delete() if processType == 'Add_Warehouse': #self.response.write('WAREHOUSE ADDED') warehouse = models.Warehouse( parent=models.warehouse_key('mainUser')) warehouse.Name = self.request.get('warehouseName') warehouse.Location = self.request.get('warehouseLocation') warehouse.put() elif processType == 'Add_Item': #self.response.write('ITEM ADDED') item = models.Item(parent=models.item_key('warehouse01')) item.Type = self.request.get('itemType') item.Name = self.request.get('itemName') item.Description = self.request.get('itemDesc') item.Price = self.request.get('itemPrice') item.Quantity = self.request.get('itemQty') item.Store = self.request.get('itemStorage') item.put() items_query = models.Item.query( ancestor=models.item_key('warehouse01')).order(models.Item.Type) #items_query = Item.query(models.Item.Type=='Basic Air Con') #items_query = Item.query().order(models.Item.Type, models.Item.Store) items = items_query.fetch(60) itemKeys = items_query.fetch(60, keys_only=True) keyList = [] for i in itemKeys: keyList.append(i.urlsafe()) #linking key and object together mainItemList = zip(items, keyList) warehouses_query = models.Warehouse.query( ancestor=models.warehouse_key('mainUser')).order( models.Warehouse.Name) warehouses = warehouses_query.fetch(60) warehousesKeys = warehouses_query.fetch(60, keys_only=True) warehousesList = [] for i in warehousesKeys: warehousesList.append(i.urlsafe()) warehouseitemexist = [] for i in warehouses: exist = False for j in items: if i.Name == j.Store: exist = True warehouseitemexist.append(True) break if not exist: warehouseitemexist.append(False) mainWarehousesList = zip(warehouses, warehousesList, warehouseitemexist) params = { 'process': self.request.get('process'), 'items': items, 'itemKeys': itemKeys, 'mainItemList': mainItemList, 'warehouses': warehouses, 'warehousesKeys': warehousesKeys, 'mainWarehousesList': mainWarehousesList, } if pageType == 'warehouse': self.render_template('warehouse.html', params) if pageType == 'item' or location == 'item': self.render_template('inventory.html', params)