Beispiel #1
0
    def save_item(self):
        if len(self.ui.itemNameField.text().strip()) <= 0:
            self.ui.errorMessagesLabel.setText("Item name is required!")
        elif item_name_exists(self.ui.itemNameField.text().strip()):
            self.ui.errorMessagesLabel.setText(
                "Item with that name already exists in database")
        elif len(self.ui.itemCostPriceField.text().strip()) <= 0 or (
                not is_float(self.ui.itemPriceField.text().strip())):
            self.ui.errorMessagesLabel.setText(
                "Cost Price is required! (Use valid characters)")
        elif len(self.ui.itemPriceField.text().strip()) <= 0 or (not is_float(
                self.ui.itemPriceField.text().strip())):
            self.ui.errorMessagesLabel.setText(
                "Unit Price is required! (Use valid characters)")
        elif len(self.ui.itemQuantityField.text().strip()) <= 0 or (
                not is_integer(self.ui.itemQuantityField.text().strip())):
            self.ui.errorMessagesLabel.setText(
                "Quantity is required! (Be sure to enter an integer)")
        else:
            item_name = self.ui.itemNameField.text().strip()
            cost_price = self.ui.itemCostPriceField.text().strip()
            unit_price = self.ui.itemPriceField.text().strip()
            quantity = self.ui.itemQuantityField.text().strip()

            if len(self.ui.itemDescField.toPlainText().strip()) > 0:
                description = self.ui.itemDescField.toPlainText().strip()
                if add_item('', item_name, description, cost_price, unit_price,
                            quantity):
                    self.new_item_added.emit()
                    self.close()
            else:
                if add_item('', item_name, '', cost_price, unit_price,
                            quantity):
                    self.new_item_added.emit()
                    self.close()
Beispiel #2
0
def push_content_to_the_db(dict_of_items):
    for item in dict_of_items:
        add_item(
            title=item['title'],
            link=item['link'],
            # photo=item['photo'],
            price_usd=item['price_usd'],
        )
Beispiel #3
0
def add_item(form):
    print("Добавляю новый товар в наколадную")
    new_item = db.Item(name=form.name.data,
                       size_x=form.size_x.data,
                       size_y=form.size_y.data,
                       size_z=form.size_z.data,
                       weight=form.weight.data)

    # Добавление в БД новой записи о товаре
    db.add_item(new_item)
    print("Товар добавлен")
Beispiel #4
0
def items_page():
    global item
    if request.method == 'POST':
        item = request.form.to_dict(flat=False)
        purchaseId = item["purchaseid"]
        brand = item["brand"]
        name = item["name"]
        price = item["price"]
        db.add_item(purchaseId[0], brand[0], name[0], price[0])
        print(item)
        return redirect(url_for('items_page'))
    return render_template('items.html')
Beispiel #5
0
def import_inventory():
    service = build('sheets', 'v4', credentials=creds)

    sheet = service.spreadsheets()
    result = sheet.values().get(spreadsheetId=settings.secrets["sheets"]["tuotteet"], range="A1:3", majorDimension = "COLUMNS").execute()
    values = result.get('values', [])
    values = list(map(lambda x: [x[0], int(x[1]), int(x[2])], values[1:]))

    print(values)
    db.delete_inventory()
    for i in values:
        db.add_item(i[0], i[1], i[2])
    return len(values)
def add_item():
    name        = input("Name: ")
    types        = input("Type: ")
    cost     = int(input("Cost (cost cannot include cents): "))
    store_id = int(input("Store ID: "))
    
    store = db.get_store(store_id)
    if store == None:
        print("There is no category with that ID. Movie NOT added.\n")
    else:        
        item = Item(name=name, types=types, cost=cost, store=store)
        db.add_item(item)    
        print(name + " was added to database.\n")
Beispiel #7
0
def add_item():
    content: dict = request.json
    current_login = content.get("current_login")
    name = content.get("name")
    location = content.get("location")
    barcode = content.get("barcode")
    user_id = db.check_login(current_login)
    db.log_event(user_id, current_login, f"Add Item {name} @ {location} with barcode {barcode}")

    if user_id is None:
        abort(403, messsage="Not authenticated")
        return

    db.add_item(name, location, barcode)
    return jsonify({"status": "good"})
Beispiel #8
0
def import_inventory():
    service = build('sheets', 'v4', credentials=google_auth.creds)

    sheet = service.spreadsheets()
    result = sheet.values().get(spreadsheetId=config.INVENTORY_SHEET_ID,
                                range="A1:3",
                                majorDimension="COLUMNS").execute()
    values = result.get('values', [])
    values = list(map(lambda x: [x[0], int(x[1]), int(x[2])], values[1:]))

    print(values)
    db.delete_inventory()
    for i in values:
        db.add_item(i[0], i[1], i[2])
    return len(values)
Beispiel #9
0
def start_scan(path,
               scan_for,
               scan_type,
               scan_title=None,
               scan_lookup_type=None,
               scan_lookup_id=None):
    section = utils.get_plex_section(conf.configs, path)
    if section <= 0:
        return False
    else:
        logger.info("Using Section ID '%d' for '%s'", section, path)
    if conf.configs['SERVER_USE_SQLITE']:
        db_exists, db_file = db.exists_file_root_path(path)
        if not db_exists and db.add_item(path, scan_for, section, scan_type):
            logger.info("Added '%s' to Plex Autoscan database.", path)
            logger.info("Proceeding with scan...")
        else:
            logger.info(
                "Already processing '%s' from same folder. Skip adding extra scan request to the queue.",
                db_file)
            resleep_paths.append(db_file)
            return False
    thread.start(plex.scan,
                 args=[
                     conf.configs, scan_lock, path, scan_for, section,
                     scan_type, resleep_paths, scan_title, scan_lookup_type,
                     scan_lookup_id
                 ])
    return True
Beispiel #10
0
def add():
	if 'admin' in session:
		if request.method == 'POST':
			if 'tag' in session:
				tag = session['tag']
				session['tag'] = None
			else:
				tag = None
			name = request.form['item']
			desc = request.form['desc']
			cost = request.form['cost']
			in_stock = 'in_stock' in request.form
			db.add_item(tag, name, desc, cost, in_stock)
			return redirect(url_for('items'))
		elif request.method == 'GET':
			return render_template('add.html.j2')
	else:
		return redirect(url_for('login'))
Beispiel #11
0
def start_scan(path, scan_for, scan_type):
    section = utils.get_plex_section(conf.configs, path)
    if section <= 0:
        return False
    else:
        logger.debug("Using section id: %d for '%s'", section, path)

    if conf.configs['SERVER_USE_SQLITE']:
        db_exists, db_file = db.exists_file_root_path(path)
        if not db_exists and db.add_item(path, scan_for, section, scan_type):
            logger.info("Added '%s' to database, proceeding with scan", path)
        else:
            logger.info(
                "Already processing '%s' from same folder, aborting adding an extra scan request to the queue", db_file)
            resleep_paths.append(db_file)
            return False

    thread.start(plex.scan, args=[conf.configs, scan_lock, path, scan_for, section, scan_type, resleep_paths])
    return True
Beispiel #12
0
def init_demo_items():
    db.clean_items()
    new_item = db.Item(name="Компьютер 1",
                       size_x=900,
                       size_y=900,
                       size_z=300,
                       weight=15)
    db.add_item(new_item)
    new_item = db.Item(name="Монитор",
                       size_x=900,
                       size_y=1500,
                       size_z=50,
                       weight=7)
    db.add_item(new_item)
    new_item = db.Item(name="Доска маркерная",
                       size_x=1900,
                       size_y=1100,
                       size_z=900,
                       weight=5)
    db.add_item(new_item)