def add_order_empty(user: str, source: str) -> str: order = Order(user=user, address=None, source=source, products=[], ready=False) db.add_order(order) logger.info('Client requested a new order') return 'Введите продукты в данном формате:\nНазвание Количество Название Количество'
def others_menu(message): for p in product.get_others_titles(): if message.text == p: bot.send_chat_action(message.chat.id, 'upload_photo') img_url = product.get_others_by_title(message.text)['picture'] try: urllib2.urlretrieve(img_url, 'cache/other.jpg') img = open('cache/other.jpg', 'rb') except: urllib2.urlretrieve(img_url, 'cache/other_two.jpg') img = open('cache/other_two.jpg', 'rb') product_ = product.get_others_by_title(message.text) bot.send_message(message.chat.id, 'Ваш продукт: ', reply_markup=keyboards.back_keyboard()) bot.send_photo(message.chat.id, img, messages.product_data(product_), parse_mode='HTML', reply_markup=keyboards.add_to_basket()) img.close() db.add_order(message.chat.id, message.text, product_['comp'], product_['price'], product_['picture']) db.set_cache(message.chat.id, message.text) if message.text == '⬅ Назад': bot.send_message(message.chat.id, 'Выберите раздел, чтобы вывести список блюд 👇🏻', reply_markup=keyboards.categories()) db.delete_empty_orders(message.chat.id) states.set_state(message.chat.id, States.S_MENU.value) elif message.text == '🏠 Начало': bot.send_message(message.chat.id, '🏠 Главное меню', reply_markup=keyboards.main_menu()) states.set_state(message.chat.id, States.S_MAIN_MENU.value) db.delete_empty_orders(message.chat.id) elif message.text == '📥 Корзина': bot.send_message(message.chat.id, messages.basket(message.chat.id), parse_mode='HTML', reply_markup=keyboards.basket()) elif not product.get_others_by_title(message.text)['title']: bot.send_message( message.chat.id, 'Неизвесное название продукта попробуйте другое!\n' 'Или попробуйте /start или /help')
def coffee_purchase(msg): # msg_text = msg.text.split(' (')[0] keyboard = telebot.types.ReplyKeyboardMarkup() add = telebot.types.KeyboardButton('+') delete = telebot.types.KeyboardButton('-') main = telebot.types.KeyboardButton('Главное Меню') basket = telebot.types.KeyboardButton('Корзина') keyboard.add(main, basket, delete, add) # Access the name and price of the good in the DB name, price = db.access_price_list(name=msg.text) bot.send_message(msg.chat.id, name, reply_markup=keyboard) # bot.send_message(msg.chat.id, 'Вы выбрали кофе {}.'.format(name), reply_markup=keyboard) bot.send_message(msg.chat.id, 'Вы можете изменить количество с помощью кнопок <b>+<b> и <b>-<b>.', parse_mode='html') # Add order to the database db.add_order(user_id=msg.chat.id, name=name, quantity=1, price=price) # Add quantity controls
def add_order(): pizza = db.get_products() created = datetime.datetime.now() render_template('add_order.html', pizza=pizza) if request.method == 'POST': order_content = request.form.getlist('pizza_id') for i in range(len(order_content)): db.add_order( created = created, pizza_id =order_content[i], client = request.form['client'], phone = request.form['phone'], address = request.form['address'], status = 'Новый' ) flash('Ваш заказ добавлен') return redirect(url_for('index')) else: return render_template('add_order.html', pizza=pizza)
def order(): if request.method == 'POST': order = { 'client': { 'name': request.form['name'], 'surname': request.form['surname'], 'adress': request.form['adress'], 'phone': request.form['phone'] }, 'pizza': {}, 'status': { 'Поступил': datetime.now() } } global order_ok assorts = [ 'Додо', 'Итальянская', 'Мексиканская', 'Пеперони', 'Супермясная' ] for assort in assorts: value = request.form[assort] if int(value) > 0: order['pizza'].update({assort: value}) order_ok = True if order_ok: global num num = num + 1 last_client_id = db.add_client(request.form['name'], request.form['surname'], request.form['adress'], request.form['phone']) last_order_id = db.add_order(last_client_id, "Поступил") for pizza_name, pizza_value in order['pizza'].items(): db.add_pizza(last_order_id, pizza_name, pizza_value) flash('{}, Ваш заказ принят. Менеджер перезвонит на номер {}.'. format(order['client']['name'], order['client']['phone'])) order_ok = False return redirect(url_for('index')) else: flash('Необходимо указать количество выбранной пиццы для заказа.') return render_template('make_order.html', products=products) else: return render_template('make_order.html', products=products)
def new_order(email, customer_name, phone, package_id, order_name, description): customer = get_customer(email, customer_name, phone) db.add_order(customer, package_id, order_name, description)