def randomize_last_command_orders(): ''' update order for each commands ''' command = Command.last().empty_orders() employees = Employee.query.all() orders = [] foods = command.shop.foods.filter_by(extra=False).all() foods_extra = command.shop.foods.filter_by(extra=True).all() extra_count = random.randint( 0, (math.floor(Employee.query.count() * RATE_EXTRA_ORDER) + 1)) for employee in employees: employee_count = random.randint(RATE_EMPLOYEE_COMMANDED_MIN, RATE_EMPLOYEE_COMMANDED_MAX) orders += [ Order(food=random.choice(foods), command=command, employee=employee) for _ in range(employee_count) ] for food_extra in foods_extra: extra_count = random.randint(RATE_EXTRA_COMMANDED_MIN, RATE_EXTRA_COMMANDED_MAX) orders += [ Order(food=food_extra, command=command) for _ in range(extra_count) ] db.session.add_all(orders) db.session.commit()
def make_shell_context(): return dict( app=app, current_user=current_user, auth=auth, fx=fx, fk=fx.fk, db=db, User=User, Employee=Employee, Shop=Shop, Food=Food, Order=Order, Command=Command, l=Command.last(), datetime=datetime, date=date, timedelta=timedelta, )
def command_never_delivered(): '''Set the current command status to not delivered''' Command.last().delivered()
def command_wait(): '''Set the current command status to wait''' Command.last().wait()