def loadAllSpoolsByQuery(self, tableQuery): if (tableQuery == None): return SpoolModel.select().order_by(SpoolModel.created.desc()) offset = int(tableQuery["from"]) limit = int(tableQuery["to"]) sortColumn = tableQuery["sortColumn"] sortOrder = tableQuery["sortOrder"] # not needed at the moment filterName = tableQuery["filterName"] myQuery = SpoolModel.select().offset(offset).limit(limit) # if (filterName == "onlySuccess"): # myQuery = myQuery.where(PrintJobModel.printStatusResult == "success") # elif (filterName == "onlyFailed"): # myQuery = myQuery.where(PrintJobModel.printStatusResult != "success") if ("displayName" == sortColumn): if ("desc" == sortOrder): myQuery = myQuery.order_by(SpoolModel.displayName.desc()) else: myQuery = myQuery.order_by(SpoolModel.displayName) if ("lastUse" == sortColumn): if ("desc" == sortOrder): myQuery = myQuery.order_by(SpoolModel.lastUse.desc()) else: myQuery = myQuery.order_by(SpoolModel.lastUse) if ("firstUse" == sortColumn): if ("desc" == sortOrder): myQuery = myQuery.order_by(SpoolModel.firstUse.desc()) else: myQuery = myQuery.order_by(SpoolModel.firstUse) return myQuery
def loadCatalogMaterials(self, tableQuery): result = set() result.add("") myQuery = SpoolModel.select(SpoolModel.material).distinct() for spool in myQuery: value = spool.material if (value != None): result.add(value) return result
def loadCatalogVendors(self, tableQuery): result = set() result.add("") myQuery = SpoolModel.select(SpoolModel.vendor).distinct() for spool in myQuery: value = spool.vendor if (value != None): result.add(value) return result
def loadAllSpoolsByQuery(self, tableQuery): if (tableQuery == None): return SpoolModel.select().order_by(SpoolModel.created.desc()) offset = int(tableQuery["from"]) limit = int(tableQuery["to"]) sortColumn = tableQuery["sortColumn"] sortOrder = tableQuery["sortOrder"] filterName = tableQuery["filterName"] myQuery = SpoolModel.select().offset(offset).limit(limit) if (filterName == "hideEmptySpools"): myQuery = myQuery.where((SpoolModel.remainingWeight > 0) | (SpoolModel.remainingWeight == None)) # elif (filterName == "onlyFailed"): # myQuery = myQuery.where(PrintJobModel.printStatusResult != "success") if ("displayName" == sortColumn): if ("desc" == sortOrder): myQuery = myQuery.order_by(SpoolModel.displayName.desc()) else: myQuery = myQuery.order_by(SpoolModel.displayName) if ("lastUse" == sortColumn): if ("desc" == sortOrder): myQuery = myQuery.order_by(SpoolModel.lastUse.desc()) else: myQuery = myQuery.order_by(SpoolModel.lastUse) if ("firstUse" == sortColumn): if ("desc" == sortOrder): myQuery = myQuery.order_by(SpoolModel.firstUse.desc()) else: myQuery = myQuery.order_by(SpoolModel.firstUse) if ("remaining" == sortColumn): if ("desc" == sortOrder): myQuery = myQuery.order_by(SpoolModel.remainingWeight.desc()) else: myQuery = myQuery.order_by(SpoolModel.remainingWeight) if ("material" == sortColumn): if ("desc" == sortOrder): myQuery = myQuery.order_by(SpoolModel.material.desc()) else: myQuery = myQuery.order_by(SpoolModel.material) return myQuery
def countSpoolsByQuery(self, tableQuery): filterName = tableQuery["filterName"] myQuery = SpoolModel.select() # if (filterName == "onlySuccess"): # myQuery = myQuery.where(PrintJobModel.printStatusResult == "success") # elif (filterName == "onlyFailed"): # myQuery = myQuery.where(PrintJobModel.printStatusResult != "success") return myQuery.count()
def loadCatalogLabels(self, tableQuery): result = set() result.add("") myQuery = SpoolModel.select(SpoolModel.labels).distinct() for spool in myQuery: value = spool.labels if (value != None): spoolLabels = json.loads(value) for singleLabel in spoolLabels: result.add(singleLabel) return result
def loadSpoolTemplateSpool(self): return SpoolModel.select().where(SpoolModel.isTemplate == True)