Пример #1
0
def create_component():
    clean()
    try:
        name = raw_input("Podaj nazwe elementu:")
        quantity = float(raw_input("Podaj ilosc:"))
        value = float(raw_input("Podaj koszt:"))
        description = raw_input("Opis elementu:")
        supplier = raw_input("Podaj dostawce:")
        delivery_time = float(raw_input("Podaj czas dostawy:"))
        if db.new_component(name, quantity, description, value, supplier,
                            delivery_time) == 0:
            print("Nie udało się utworzyć elementu")
            time.sleep(2)
            return 0

        print("Utworzono nowy element:")
        tmp = db.component.find_one({"name": name})
        tmp_id = tmp["_id"]
        db.show(tmp_id)
        time.sleep(5)
        return 1

    except:
        print("Nie udało się utworzyć elementu")
        time.sleep(2)
        return 0
Пример #2
0
def show():

    while True:
        clean()
        print("Wpisanie q kończy wyświetlanie")
        code = raw_input("Wczytaj kod produktu:")
        if code == "q": return 0

        print("Wczytany produkt:")
        db.show(code, True)
        time.sleep(2)
Пример #3
0
def admin():
    username = session.get('username')
    if username == None:
        return redirect(url_for('login'))
    message = db.show()
    print('tbSingle', message['tbSingle'])
    return render_template('admin.html', single=message['tbSingle'])
Пример #4
0
def index():
    username = session.get('username')
    # 如果还没有登录,就返回登录页面
    if username == None:
        return redirect(url_for('login'))
    # 从数据库中获取展示数据
    data = db.show()
    return render_template('index.html', all_message=data)
Пример #5
0
def update_quantity():
    while (1 == 1):
        clean()
        print("Wpisanie q przerywa dodawanie elementów do produktu\n")

        code = raw_input("Podaj kod elementu/materiału:")
        if code == 'q': break
        elif db.show(code) == 0:
            print("Błędny kod elementu")
            time.sleep(2)
            continue

        quantity = float(raw_input("Podaj aktualną ilość:"))
        db.update_quantity(code, quantity)
        print("Aktualny element/materiał:")
        db.show(code)

    return 1
Пример #6
0
def admin():
    # 检查是否已经登录
    username = session.get('username')
    # 如果还没有登陆,则返回登陆界面
    if username == None:
        return redirect(url_for('login'))
    # 得到展示数据
    message = db.show()
    # print('tbSingle', message['tbSingle'])
    return render_template('admin.html', single=message['tbSingle'])
Пример #7
0
def create_product():
    clean()
    try:
        name = raw_input("Podaj nazwe produktu:")
        description = raw_input("Opis produktu:")
        if db.new_product(name, description) == 0:
            print("Nie udało się utworzyć produkt")
            time.sleep(2)
            return 0

        print("Utworzono nowy produkt")
        tmp = db.product.find_one({"name": name})
        tmp_id = tmp["_id"]
        db.show(tmp_id)
        time.sleep(5)
        return 1

    except:
        print("Nie udało się utworzyć produkt")
        time.sleep(2)
        return 0
Пример #8
0
def product_sub_component():

    while True:
        clean()
        print("Wpisanie q kończy zdejmowanie zestawów elementów z magazynu")
        code = raw_input("Wczytaj kod produktu:")
        if code == "q": return 0

        print("Wczytany produkt:")
        if db.show(code) != 3: continue

        db.sub_product_sub_component(code)
        time.sleep(2)
Пример #9
0
def add_component_to_product():
    clean()
    product_code = raw_input("Podaj kod produktu:")
    if product_code == 'q': return

    if db.show(product_code) != 3:
        print("Brak elementu w bazie")
        time.sleep(2)
        return 0

    try:
        tmp = db.product.find_one({"_id": product_code})
    except:
        print("Brak elementu w bazie")
        time.sleep(2)
        return 0

    while (1 == 1):
        clean()
        print("Wpisanie q przerywa dodawanie elementów do produktu\n")
        print("Dodawanie elementu do produktu: {}".format(tmp["name"]))

        code = raw_input("Podaj kod elementu:")
        if code == 'q': break
        elif db.show(code) != 2:
            print("Błędny kod elementu")
            time.sleep(2)
            continue

        quantity = float(raw_input("Podaj ilość elementów:"))
        if db.extend_product(product_code, code, quantity) == 0:
            print("Nie udało się dodać elelemtu")
            continue
        else:
            print("Udało się dodać element do produktu")

    return 1
Пример #10
0
def get_show(day, time):
    show = db.show(day, time)
    hosts = [i for i in host_calc(show)]
    if len(hosts) == 2:
        hosts = ' and '.join(hosts)
    elif len(hosts) >= 3:
        hosts = ', '.join(hosts[0:len(hosts)-1]) + ', and {}'.format(hosts[-1])
    show_templates = ["Tune in to 99.9 FM now for {} with {}!".format(show[0], hosts),
                      "{} is now live with {} on 99.9 FM!".format(show[0], hosts),
                      "Check out {} with {} now on 99.9 FM!".format(show[0], hosts)]
    if show is None:
        pass
    else:
        twit = authenticate()
        twit.update_status(choice(show_templates))
Пример #11
0
def substract():

    while True:
        clean()
        print("Wpisanie q przerywa odejmowanie")
        code = raw_input("Wczytaj kod:")
        if code == "q": return 0

        print("Wczytany przedmiot:")
        if db.show(code) == 0: continue

        quantity = float(raw_input("Podaj ilości do odjęcia:"))
        if quantity > 1000: return 0

        db.sub(code, quantity)
Пример #12
0
def add():

    while True:
        clean()
        print("Wpisanie q przerywa dodawanie")
        code = raw_input("Wczytaj kod:")
        if code == "q": break

        print("Wczytany przedmiot:")
        if db.show(code) == 0: continue

        quantity = float(raw_input("Podaj ilości do dodania:"))
        if quantity > 1000: continue

        db.add(code, quantity)
Пример #13
0
def add_material_to_component():
    clean()
    element_code = raw_input("Podaj kod elementu:")
    if element_code == 'q': return

    if db.show(element_code) != 2:
        print("Brak elementu w bazie")
        time.sleep()
        return 0

    try:
        tmp = db.component.find_one({"_id": element_code})
    except:
        print("Brak elementu w bazie")
        return 0

    while (1 == 1):
        clean()
        print("Wpisanie q kończy dodawanie materiałow do elementu\n")
        print("Dodawanie materiału do elementu: {}".format(tmp["name"]))

        code = raw_input("Podaj kod materialu:")
        if code == 'q': break
        elif db.show(code) != 1:
            print("Błędny kod materiału")
            time.sleep(2)
            continue

        quantity = float(
            raw_input("Podaj ilosc materiału do dodania do elementu:"))
        if db.extend_component(element_code, code, quantity) == 0:
            print("Nie udało się dodać materiału")
            continue
        else:
            print("Udało się dodać materiał do elementu")
    return 1
Пример #14
0
def add_component_sub_material():

    while True:
        clean()
        print("Wpisanie q kończy dodawanie elementów do magazynu")
        code = raw_input("Wczytaj kod elementu:")
        if code == "q": return 0

        print("Wczytany element:")
        if db.show(code) != 2: continue

        quantity = float(raw_input("Podaj ilości elementów dodawanych:"))
        if quantity > 1000: break

        db.add_component_sub_material(code, quantity)
        time.sleep(1)
Пример #15
0
def loadin_account(username, password):
    contacts = db.show(username)
    data = {}
    for contact in contacts:
        data[contact[0]] = contact[1:]
    return account(username, password, addressBook.address_book(data))