Beispiel #1
0
def products():
    print('/products')
    try:
        rows = get_products()
    except Exception as err:
        sentry_sdk.capture_exception(err)
        raise (err)
    return rows
Beispiel #2
0
def checkPrices(schedule):
    users = db.get_users()
    for user in users:
        products = db.get_products(user[2])
        for product in products:
            prices = db.get_prices(product[0])
            price = scraper.getPrice(product[2])
            db.add_price(product[0], price)
            try:
                if (float(price) != float(prices[-1][2])):
                    bot.send_message(
                        user[2],
                        "***Price Change***\nName: {} is now \nOld-Price:€{} \nPrice: €{}\nUrl: {}"
                        .format(product[1], prices[-1][2], price, product[2]))
            except (IndexError, TypeError):
                continue
    schedule.enter(sleep, 1, checkPrices, (schedule, ))
Beispiel #3
0
def main():
    products = db.get_products()

    cart = Cart()
    while True:
        command = input("Command: ")
        if command == "cart":
            show_cart(cart)
        elif command == "add":
            add_item(cart, products)
        elif command == "del":
            remove_item(cart)
        elif command == "exit":
            print("Bye!")
            break
        else:
            print("Not a valid command. Please try again.\n")
Beispiel #4
0
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)
Beispiel #5
0
def command_products(message: telegram.Message, subcommand):
    chat_id = message.chat_id
    user = db.get_user(chat_id)
    if user == None:
        message.reply_text(
            "You're Not Subscribed \n Use /subscribe to subscribe")
        return

    if subcommand == []:
        products = db.get_products(message.chat_id)
        if (len(products) > 0):
            for i in products:
                price = db.get_prices(i[0])[-1][2] or 0
                message.reply_text("ID: {} \nName: {}\nPrice: €{}".format(
                    i[0], i[1], price))
        else:
            message.reply_text(
                "No Products Found\nAdd one with /products add <url>")
    elif subcommand[0] == "add":
        if len(subcommand) != 2:
            message.reply_text("Usage: /products add <url>")
        else:
            url = subcommand[1]
            name = scraper.getname(url)
            if name == None:
                message.reply_text('Not a correct url')
            else:
                db.add_product(message.chat_id, name, url)
                message.reply_text('{} Added'.format(name))
    elif subcommand[0] == "del":
        if len(subcommand) != 2:
            message.reply_text("Usage: /products del <id>")
        else:
            product_id = subcommand[1]
            db.del_product(product_id)
            message.reply_text('Deleted!')
    elif subcommand[0] == "help":
        message.reply_text(
            "/products add <url>   Add Product\n/products del <id>    Delete a product"
        )
Beispiel #6
0
def main():
    show_title()
    show_menu()

    # get a list of Product objects and display them
    products = db.get_products()
    show_products(products)

    # create a Cart object to store LineItem objects
    cart = Cart()
    while True:        
        command = input("Command: ")
        if command == "cart":
            show_cart(cart)
        elif command == "add":
            add_item(cart, products)
        elif command == "del":
            remove_item(cart)
        elif command == "exit":
            print("Bye!")
            break
        else:
            print("Not a valid command. Please try again.\n")
Beispiel #7
0
def main():
    show_title()
    show_menu()

    # get a list of Product objects and display them
    products = db.get_products()
    show_products(products)

    # create a Cart object to store LineItem objects
    cart = Cart()
    while True:        
        command = input("Command: ")
        if command == "cart":
            show_cart(cart)
        elif command == "add":
            add_item(cart, products)
        elif command == "del":
            remove_item(cart)
        elif command == "exit":
            print("Bye!")
            break
        else:
            print("Not a valid command. Please try again.\n")
Beispiel #8
0
def index():
    pizza = db.get_products()
    return render_template('products.html', pizza=pizza)
Beispiel #9
0
import db
from business import Product, LineItem, Cart

products = db.get_products()
product = products[1]
lineItem = LineItem(product, 2)
cart = Cart()
cart.addItem(lineItem)
print("Product:  ", product.name)
print("Price:    ", product.getDiscountPrice())
print("Quantity: ", lineItem.quantity)
print("Total:    ", cart.getTotal())
Beispiel #10
0
def get_all_products():
    """Return list of products."""
    return jsonify(db.get_products())
Beispiel #11
0
import db
from business import Product, LineItem, Cart

products = db.get_products()
product = products[1]
lineItem = LineItem(product, 2)
cart = Cart()
cart.addItem(lineItem)
print("Product:  ", product.name)
print("Price:    ", product.getDiscountPrice())
print("Quantity: ", lineItem.quantity)
print("Total:    ", cart.getTotal())
Beispiel #12
0
def get_products(email):
  result = db.get_products(email)
  return jsonify(result)
Beispiel #13
0
def get_products(cid=None, bid=None):
    data = db.exec_queries([db.get_products(cid, bid)])
    return jsonify(data)