Ejemplo n.º 1
0
 def update_list(self, filter_str: str = ''):
     self.clear_list()
     for p in database.get_products(filter_str):
         product = ProductWidget(p)
         product.clicked.connect(self.add2cart)
         self.sidebar.products_layout.insertWidget(
             self.sidebar.products_layout.count() - 1, product)
Ejemplo n.º 2
0
    def handle_json_protocol(self):  # still debug stuff here
        json_data = self.read_json()
        try:
            (request_type, obj) = json_protocol.parse_json_request(json_data)
            if request_type is json_protocol.RequestType.IDENTIFY:
                products = []
                img_datas = obj
                for img_data in img_datas:
                    possible_matches = self.image_processor.match_image(
                        img_data)
                    print(possible_matches)
                    if possible_matches:
                        best_metashop_id = possible_matches[0][0]
                        db_result = database.get_product(
                            best_metashop_id
                        )[:-2]  # Don't need pricing information
                        image_filename = config.IMAGES_DIR + '/' + image_util.get_full_filename(
                            config.IMAGES_DIR, str(best_metashop_id))
                        image = image_util.load_image_bytes(image_filename)
                        db_result.append(image)
                        temp = db_result[0]
                        db_result[0] = db_result[1]
                        db_result[1] = temp
                        products.append(db_result)
                    else:
                        products.append([
                            'INVALID PRODUCT', '-1', '-1', '-1', INVALID_IMAGE
                        ])

                response = json_protocol.build_json_response(
                    json_protocol.ResponseType.IDENTIFY, products)
                self.send_json(response)
            elif request_type is json_protocol.RequestType.PRICE_CHECK:
                metashop_ids = [int(metashop_id) for metashop_id in obj]
                products = database.get_products(metashop_ids)
                walmart_skus = []
                for product in products:
                    walmart_skus.append(product[2])
                walmart_prices = retailer_lookup.lookup_walmart_prices(
                    walmart_skus)
                prices = []
                for walmart_price in walmart_prices:
                    prices.append([walmart_price, -1.0])

                response = json_protocol.build_json_response(
                    json_protocol.ResponseType.PRICE_CHECK, prices)
                self.send_json(response)
        except binascii.Error as ex:
            self.send_json(
                json_protocol.build_json_response(
                    json_protocol.ResponseType.ERROR, str(ex)))
        except RuntimeError as ex:
            self.send_json(
                json_protocol.build_json_response(
                    json_protocol.ResponseType.ERROR, str(ex)))
Ejemplo n.º 3
0
def matched_interests():
    interest_list = db.get_interest()
    tag_list = db.get_tag()
    product_list = []

    if not interest_list:  #list is empty
        product_list = db.get_products()  #show all products
    else:
        product_list = db.match_iproducts(interest_list, tag_list)

    return render_template('foryou.html',
                           page="For You",
                           product_list=product_list)
def shipping_info():
    global _transaction_info
    _transaction_info = {
        'product_id': request.form['product'],
        'quantity': request.form['qt'],
        'customer_id': request.form['customer']
    }
    success = check_order_possibility(_transaction_info['product_id'],
                                      _transaction_info['quantity'],
                                      _transaction_info['customer_id'])
    if success:
        return render_template('shipping_info.html',
                               ship_info=get_shipping_info(
                                   _transaction_info['customer_id']))
    else:
        return render_template('order_form.html',
                               product_records=get_products(),
                               cust_records=get_customers(),
                               success=False)
Ejemplo n.º 5
0
def products():
    product_list = db.get_products()
    return render_template('products.html',
                           page="Products",
                           product_list=product_list)
def order_form():
    if not _initialized:
        initialize()
    return render_template('order_form.html',
                           product_records=get_products(),
                           cust_records=get_customers())
Ejemplo n.º 7
0
def products():
    args = {'active': 'products', 'products': db.get_products()}
    return render_template('products.html', args=args)
Ejemplo n.º 8
0
def api_get_products():
    resp = make_response(dumps(db.get_products()))
    resp.mimetype = 'application/json'
    return resp
Ejemplo n.º 9
0
def admin():
    # SECURITY NOTE : need to setup authentication to access this page
    products = database.get_products()
    return render_template("admin.html", products=products)
Ejemplo n.º 10
0
Archivo: app.py Proyecto: ayrton-sy/ITM
def products():
    code = request.args.get('code', '')
    product_list = db.get_products()
    return render_template('products.html',
                           page="Products",
                           product_list=product_list)
Ejemplo n.º 11
0
 def __init__(self, chat_id):
     self.chat_id = chat_id
     self.current_prod = 0
     self.products = get_products()
     self.prod_amount = len(self.products) - 1
     self.pre_order_params = None