def requestMap(self, request): if variable.isEmpty(request): return "Error" name = str(request.get('name')) if variable.isEmpty(name): raise MissingParamaters("Missing parameter") self.setName(name)
def get_price_for_quantity_food(): bar = str(request.args.get('bar')) food = str(request.args.get('food')) quantity = str(request.args.get('quantity')) if variable.isEmpty(bar) or variable.isEmpty(food) or variable.isEmpty( quantity): raise MissingParamaters("Missing parameter") return sellsFoodService.get_price_for_quantity(bar, food, quantity)
def get_price_for_quantity(): bar = str(request.args.get('bar')) beer = str(request.args.get('beer')) quantity = str(request.args.get('quantity')) if variable.isEmpty(bar) or variable.isEmpty(beer) or variable.isEmpty( quantity): raise MissingParamaters("Missing parameter") return sellsBeerService.get_price_for_quantity(bar, beer, quantity)
def updateSellsFood(): sellsFood = SellsFood() req = request.get_json() sellsFood.requestMap(req) oldBar = str(req.get('old_bar')) oldFood = str(req.get('old_food')) if variable.isEmpty(oldBar) or variable.isEmpty(oldFood): raise MissingParamaters("Missing parameter") return sellsFoodService.updateSellsFood(sellsFood, oldFood, oldBar)
def updateSellsBeer(): sellsBeer = SellsBeer() req = request.get_json() sellsBeer.requestMap(req) oldBar = str(req.get('old_bar')) oldBeer = str(req.get('old_beer')) if variable.isEmpty(oldBar) or variable.isEmpty(oldBeer): raise MissingParamaters("Missing parameter") return sellsBeerService.updateSellsBeer(sellsBeer, oldBeer, oldBar)
def updateLikes(): likes = Likes() req = request.get_json() likes.requestMap(req) oldDrinker = str(req.get('old_drinker')) oldBeer = str(req.get('old_beer')) if variable.isEmpty(oldDrinker) or variable.isEmpty(oldBeer): raise MissingParamaters("Missing parameter") return likesService.updateLikes(likes, oldDrinker, oldBeer)
def updateFrequents(): frequents = Frequents() req = request.get_json() frequents.requestMap(req) oldDrinker = str(req.get('old_drinker')) oldBar = str(req.get('old_bar')) if variable.isEmpty(oldDrinker) or variable.isEmpty(oldBar): raise MissingParamaters("Missing parameter") return frequentsService.updateFrequents(frequents, oldDrinker, oldBar)
def updateOperates(): operates = Operates() req = request.get_json() operates.requestMap(req) oldBar = str(req.get('old_bar')) oldDate = str(req.get('old_date')) if variable.isEmpty(oldBar) or variable.isEmpty(oldDate): raise MissingParamaters("Missing parameter") return operatesService.updateOperates(operates, oldDate, oldBar)
def requestMap(self,request): if variable.isEmpty(request): return "Error" bar = str(request.get('bar')) drinker = str(request.get('drinker')) if variable.isEmpty(bar) or variable.isEmpty(drinker): raise MissingParamaters("Missing parameter") self.setBar(bar) self.setDrinker(drinker)
def updateTransactions(): transactions = Transactions() req = request.get_json() transactions.requestMap(req) oldBillId = str(req.get('old_bill_id')) oldItem = str(req.get('item')) if variable.isEmpty(oldBillId) or variable.isEmpty(oldItem): raise MissingParamaters("Missing parameter") return transactionsService.updateTransactions(transactions, oldBillId, oldItem)
def rankByNumberOfBeersSold(): startTime = str(request.args.get('startTime')) endTime = str(request.args.get('endTime')) day = str(request.args.get('day')) bar = str(request.args.get('bar')) if variable.isEmpty(startTime) or variable.isEmpty( endTime) or variable.isEmpty(day) or variable.isEmpty(bar): raise InvalidInfo("startTime, endTime, day, or bar not provided") return bartenderService.rankByNumberOfBeersSold(startTime, endTime, day, bar)
def updateShifts(): shifts = Shifts() req = request.get_json() shifts.requestMap(req) oldBar = str(req.get('old_bar')) oldBartender = str(req.get('old_bartender')) oldDate = str(req.get('old_date')) if variable.isEmpty(oldBar) or variable.isEmpty( oldBartender) or variable.isEmpty(oldDate): raise MissingParamaters("Missing parameter") return shiftsService.updateShifts(shifts, oldBar, oldBartender, oldDate)
def requestMap(self, request): if variable.isEmpty(request): return "Error" foodname = str(request.get('foodname')) barname = str(request.get('barname')) price = str(request.get('price')) if variable.isEmpty(foodname) or variable.isEmpty( barname) or variable.isEmpty(price): raise MissingParamaters("Missing parameter") self.setFoodname(foodname) self.setBarname(barname) self.setPrice(price)
def requestMap(self, request): if variable.isEmpty(request): return "Error" name = str(request.get('name')) phone = str(request.get('phone')) state = str(request.get('state')) if variable.isEmpty(name) or variable.isEmpty( phone) or variable.isEmpty(state): raise MissingParamaters("Missing parameter") self.setName(name) self.setPhone(phone) self.setState(state)
def updateInventory(): inventory = Inventory() req = request.get_json() inventory.requestMap(req) oldBar = str(req.get('old_bar')) oldDate = str(req.get('old_date')) oldBeer = str(req.get('old_beer')) if variable.isEmpty(oldBar) or variable.isEmpty( oldDate) or variable.isEmpty(oldBeer): raise MissingParamaters("Missing parameter") return inventoryService.updateInventory(inventory, oldDate, oldBar, oldBeer)
def updateShifts(shifts, oldBar, oldBartender, oldDate): bartenderRepo = BartenderRepo.BartenderRepo() bartenderArray = bartenderRepo.getBartender(shifts.getBartender()) if variable.isEmptyArray(bartenderArray): raise Error("Bartender does not exist") #pattern 5 shiftsRepo = ShiftsRepo.ShiftsRepo() items = shiftsRepo.getShifts(shifts.getBartender(), shifts.getDate()) if len(items) != 0 and (not (shifts.getBartender() == oldBartender) or not (shifts.getBar() == oldBar) or not (shifts.getDate() == oldDate)): raise Error("Bartender can only have one shift on a given date") barRepo = BarRepo.BarRepo() barArray = barRepo.getBar(shifts.getBar()) if variable.isEmptyArray(barArray): raise Error("Bar does not exist") datetime_object = datetime.strptime(shifts.getDate(), "%Y-%m-%d") if str(calendar.day_name[datetime_object.weekday()]) != str( shifts.getDay()): raise Error("Day does not match date") if shifts.getStart() >= shifts.getEnd(): raise Error("shifts hour error: start time cannot be before end time") operatesRepo = OperatesRepo.OperatesRepo() if not operatesRepo.shift_during_operating_hours( shifts.getStart(), shifts.getEnd(), shifts.getBar(), shifts.getDate()): raise Error("bar does not operate during that shift") if barArray[0].getState() != bartenderArray[0].getState(): raise Error("bartender cannot live in a different state than the bar") billsRepo = BillsRepo.BillsRepo() transcations = billsRepo.getBillsByBartenderAndDate( shifts.getBartender(), shifts.getDate()) for each in transcations: if not (shifts.getStart() <= each.getTime() and each.getTime() <= shifts.getEnd()): raise Error( "Bartender has transcations during the current shift that need to be deleted or updated before trying to update this shift" ) shiftsRepo = ShiftsRepo.ShiftsRepo() return shiftsRepo.updateShifts(shifts, oldBar, oldBartender, oldDate)
def requestMap(self,request): if variable.isEmpty(request): return "Error" bar = str(request.get('bar')) day = str(request.get('day')) start = str(request.get('start')) end = str(request.get('end')) date = str(request.get('date')) if variable.isEmpty(bar) or variable.isEmpty(day) or variable.isEmpty(start) or variable.isEmpty(end) or variable.isEmpty(date): raise MissingParamaters("Missing parameter") self.setBar(bar) self.setDay(day) self.setStart(start) self.setEnd(end) self.setDate(date)
def updateDay(): day = Day() req = request.get_json() day.requestMap(req) oldName = str(req.get('old_name')) if variable.isEmpty(oldName): raise MissingParamaters("Missing parameter") return dayService.updateDay(day, oldName)
def updateBarFood(): barFood = BarFood() req = request.get_json() barFood.requestMap(req) oldName = str(req.get('old_name')) if variable.isEmpty(oldName): raise MissingParamaters("Missing parameter") return barFoodService.updateBarFood(barFood, oldName)
def updateBeer(): beer = Beer() req = request.get_json() beer.requestMap(req) oldName = str(req.get('old_name')) if variable.isEmpty(oldName): raise MissingParamaters("Missing parameter") return beerService.updateBeer(beer, oldName)
def updateBills(): bills = Bills() req = request.get_json() bills.requestMap(req) oldBillId = str(req.get('old_bill_id')) if variable.isEmpty(oldBillId): raise MissingParamaters("Missing parameter") return billsService.updateBills(bills, oldBillId)
def deleteShifts(shifts): billsRepo = BillsRepo.BillsRepo() transcations = billsRepo.getBillsByBartenderAndDate( shifts.getBartender(), shifts.getDate()) if not variable.isEmptyArray(transcations): raise Error( "Bartender has transcations during the shift, please delete them before trying to delete shift" ) shiftsRepo = ShiftsRepo.ShiftsRepo() return shiftsRepo.deleteShifts(shifts)
def insertShifts(shifts): bartenderRepo = BartenderRepo.BartenderRepo() bartenderArray = bartenderRepo.getBartender(shifts.getBartender()) if variable.isEmptyArray(bartenderArray): raise Error("Bartender does not exist") shiftsRepo = ShiftsRepo.ShiftsRepo() items = shiftsRepo.getShifts(shifts.getBartender(), shifts.getDate()) if len(items) != 0: raise Error("Bartender can only have one shift on a given date") barRepo = BarRepo.BarRepo() barArray = barRepo.getBar(shifts.getBar()) if variable.isEmptyArray(barArray): raise Error("Bar does not exist") datetime_object = datetime.strptime(shifts.getDate(), "%Y-%m-%d") if str(calendar.day_name[datetime_object.weekday()]) != str( shifts.getDay()): raise Error("Day does not match date") if shifts.getStart() >= shifts.getEnd(): raise Error("shifts hour error: start time cannot be before end time") operatesRepo = OperatesRepo.OperatesRepo() if not operatesRepo.shift_during_operating_hours( shifts.getStart(), shifts.getEnd(), shifts.getBar(), shifts.getDate()): raise Error("bar does not operate during that shift") if barArray[0].getState() != bartenderArray[0].getState(): raise Error("bartender cannot live in a different state than the bar") shiftsRepo = ShiftsRepo.ShiftsRepo() return shiftsRepo.insertShifts(shifts)
def requestMap(self, request): if variable.isEmpty(request): return "Error" bill_id = str(request.get('bill_id')) quantity = str(request.get('quantity')) item = str(request.get('item')) item_type = str(request.get('item_type')) price = str(request.get('price')) if variable.isEmpty(bill_id) or variable.isEmpty( quantity) or variable.isEmpty(item) or variable.isEmpty( item_type) or variable.isEmpty(price): raise MissingParamaters("Missing parameter") self.setBillId(bill_id) self.setQuantity(quantity) self.setItem(item) self.setType(item_type) self.setPrice(price)
def requestMap(self, request): if variable.isEmpty(request): return "Error" beer = str(request.get('beer')) bar = str(request.get('bar')) date = str(request.get('date')) startquantity = str(request.get('startquantity')) endquantity = str(request.get('endquantity')) if variable.isEmpty(beer) or variable.isEmpty(bar) or variable.isEmpty( date) or variable.isEmpty(startquantity) or variable.isEmpty( endquantity): raise MissingParamaters("Missing parameter") self.setBeer(beer) self.setBar(bar) self.setDate(date) self.setStartQuantity(startquantity) self.setEndQuantity(endquantity)
def requestMap(self, request): if variable.isEmpty(request): return "Error" bill_id = str(request.get('bill_id')) bar = str(request.get('bar')) date = str(request.get('date')) drinker = str(request.get('drinker')) items_price = str(request.get('items_price')) tax_price = str(request.get('tax_price')) tip = str(request.get('tip')) total_price = str(request.get('total_price')) time = str(request.get('time')) bartender = str(request.get('bartender')) day = str(request.get('day')) if variable.isEmpty(bill_id) or variable.isEmpty( bar) or variable.isEmpty(date) or variable.isEmpty( drinker ) or variable.isEmpty(items_price) or variable.isEmpty( tax_price) or variable.isEmpty(tip) or variable.isEmpty( total_price) or variable.isEmpty( time) or variable.isEmpty( bartender) or variable.isEmpty(day): raise MissingParamaters("Missing parameter") self.setBillId(bill_id) self.setBar(bar) self.setDate(date) self.setDrinker(drinker) self.setItemsPrice(items_price) self.setTaxPrice(tax_price) self.setTip(tip) self.setTotalPrice(total_price) self.setTime(time) self.setBartender(bartender) self.setDay(day)
def getDrinkerSpendingByMonth(): drinker = str(request.args.get('drinker')) if variable.isEmpty(drinker): raise InvalidInfo("Drinker not provided") return drinkerService.getDrinkerSpendingByMonth(drinker)
def getTop10StatesWhereTheirBeerIsLikedTheMost(): manf = str(request.args.get('manf')) if variable.isEmpty(manf): raise InvalidInfo("manufacturer not provided") return manufacturerService.getTop10StatesWhereTheirBeerIsLikedTheMost(manf)
def getTop10StatesWithHighestSalesInTheLastWeek(): manf = str(request.args.get('manf')) if variable.isEmpty(manf): raise InvalidInfo("manufacturer not provided") return manufacturerService.getTop10StatesWithHighestSalesInTheLastWeek(manf)
def getAllBeersByManufacturer(): manf = str(request.args.get('manf')) if variable.isEmpty(manf): raise InvalidInfo("manufacturer not provided") return manufacturerService.getAllBeersByManufacturer(manf)