예제 #1
0
def addProductBySaler():
    name = request.form['name']
    print(name)
    desc = request.form['description']
    print(desc)
    price = request.form['price']
    print(price)
    cate = request.form['cate']
    print(cate)
    subcate = request.form['subcate']
    print(subcate)
    stock = request.form["stock"]
    target = os.path.join(APP_ROOT,
                          r'\Users\hp\PycharmProjects\shop\static\images')
    print(target)
    file = None
    for file in request.files.getlist("image"):
        filename = file.filename
        print("here21212")
        destination = "/".join([target, filename])
        print("Accept incoming file:", filename)
        print(destination)
        file.save(destination)
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    db.addproductBySaler(name, session["username"], session["email"], desc,
                         price, cate, subcate, file.filename, stock)
    return render_template("SellerDashboard.html", status=True)
예제 #2
0
def addProductByAdmin():
    print("ADMIN")
    name = request.form['name']
    print(name)
    desc = request.form['description']
    print(desc)
    price = request.form['price']
    print(price)
    cate = request.form['cate']
    print(cate)
    subcate = request.form['subcate']
    print(subcate)
    stock = request.form["stock"]

    target = os.path.join(APP_ROOT,
                          r'\Users\hp\PycharmProjects\shop\static\images')
    print(target)
    file = None
    for file in request.files.getlist("image"):
        filename = file.filename
        print("here21212")
        destination = "/".join([target, filename])
        print("Accept incoming file:", filename)
        print(destination)

    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    obj = db.ShowProducts()
    print("AfterShow")
    if db.addproduct(name, desc, price, cate, subcate, file.filename, stock):
        print("innerIf")
        file.save(destination)
        return render_template("addProductByAdmin.html", status=True)
    else:
        return render_template("addProductByAdmin.html", status=False)
예제 #3
0
def productDetails():
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.getproductbyid(session["pid"])
    review = db.getreview(session["pid"])
    print(dd)
    return render_template("product-detail.html", product=dd, review=review)
예제 #4
0
def review():
    print("inside review")
    rev = request.form['message']
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.setreview(session["pid"], session["email"], rev)
    if dd:
        db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                         app.config["DB_PASSWORD"], app.config["DATABASE"])
        dd = db.getproductbyid(session["pid"])
        review = db.getreview(session["pid"])
        print(dd)
        return render_template("product-detail.html",
                               product=dd,
                               review=review)
    else:
        return "garbar"
예제 #5
0
def checkout():
    if session.get("email") != None:
        db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                         app.config["DB_PASSWORD"], app.config["DATABASE"])
        cartlist = db.getCartforCheckout(session.get("email"))
        return render_template("checkout.html", summaryList=cartlist)
    else:
        return render_template("index.html")
예제 #6
0
def totalcart():
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.totalFromCart(session["email"])
    if dd is not None:
        return jsonify(dd)
    else:
        va = [{"check": "true"}]
        return jsonify(va)
예제 #7
0
def adminMain():
    if session.get("admin-email") is not None:
        db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                         app.config["DB_PASSWORD"], app.config["DATABASE"])
        obj = db.ShowProducts()
        return render_template("table.html",
                               listOfProducts=obj,
                               adminName=session.get("admin-username"))

    else:
        return render_template("adminLogin.html")
예제 #8
0
def wishlist():
    if session.get("email") != None:

        obj = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                          app.config["DB_PASSWORD"], app.config["DATABASE"])
        print(session["email"])
        wishdic = obj.getWishlist(session["email"])
        print(wishdic)
        return render_template("wishlist.html", wishList=wishdic)
    else:
        return render_template("index.html")
예제 #9
0
def sellerApproved():
    if session.get("email") is not None:
        db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                         app.config["DB_PASSWORD"], app.config["DATABASE"])
        obj = db.Approved3partyProducts(session["email"])
        return render_template("SellerApproved.html",
                               listOfProducts=obj,
                               adminName=session.get("admin-username"))

    else:
        return render_template("adminLogin.html")
예제 #10
0
def cart():
    if session.get("email") != None:

        obj = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                          app.config["DB_PASSWORD"], app.config["DATABASE"])
        print(session["email"])
        cartdic = obj.getCart(session["email"])
        print(cartdic)
        return render_template("cart.html", cartList=cartdic)
    else:
        return render_template("index.html")
예제 #11
0
def orderdetail():
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.orderitem(session["oid"])
    adres = db.orderadress(session["oid"])
    status = db.orderstatus(session["oid"])
    print(dd)
    return render_template("orderdetail.html",
                           orderitem=dd,
                           orderadres=adres,
                           oid=session["oid"],
                           status=status)
예제 #12
0
def feedback():
    name = request.form['name']
    email = request.form['email']
    subject = request.form['subject']
    message = request.form['message']
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.feedback(name, email, subject, message)
    if dd:
        return render_template("contact.html")
    else:
        return "Not added Feedback"
예제 #13
0
def reenterpass():
    email = request.form['email']
    passw = request.form['pass']
    cpass = request.form['cpass']
    if passw == cpass:
        obj = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                          app.config["DB_PASSWORD"], app.config["DATABASE"])
        result = obj.changepass(email, passw)
        if result:
            return render_template("account.html", change=True)
    else:
        return render_template("reenterpass.html", change=False)
예제 #14
0
def deleteFromCart():
    key1 = str(request.data)
    print(key1)
    key1 = key1.split("'")
    score = int(key1[1])
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.delproductbyIdFromCart(score)
    if dd:
        va = [{"check": "true"}]
        return jsonify(va)
    else:
        va = [{"check": "false"}]
        return jsonify(va)
예제 #15
0
def hello_world():
    # session.clear()
    # session.pop("admin-email", None)
    # session.pop("admin-username", None)
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    men = db.CATAGERY('Men')
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    women = db.CATAGERY('Women')
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    sports = db.CATAGERY('Sports')
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    kids = db.CATAGERY('Kids')
    cartlist = db.getCarthower(session.get("email"))
    return render_template("index.html",
                           product=men,
                           wproduct=women,
                           kproduct=kids,
                           sproduct=sports,
                           cartList=cartlist)
예제 #16
0
def addToCart():
    key1 = str(request.data)
    print(key1)
    key1 = key1.split("'")
    pid = int(key1[1])
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.addToCart(session["email"], pid)
    if dd:
        va = [{"check": "true"}]
        return jsonify(va)
    else:
        va = [{"check": "false"}]
        return jsonify(va)
예제 #17
0
def register():
    email = request.form["email"]
    username = request.form["uname"]
    password = request.form["pass"]
    role = request.form["rad"]

    web_projectobj = web_project(app.config["DATABASEIP"],
                                 app.config["DB_USER"],
                                 app.config["DB_PASSWORD"],
                                 app.config["DATABASE"])
    if web_projectobj.register_user(username, email, password, role):
        return render_template("index.html", status=True)
    else:
        return render_template("account.html",
                               status="This user email Already Exists")
예제 #18
0
def deliveered():
    key1 = str(request.data)
    print(key1)
    key1 = key1.split("'")
    oid = int(key1[1])
    print("In Place order before calling db handler")
    print(oid)
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.updateStatus(oid)
    if dd:
        va = [{"check": "true"}]
        return jsonify(va)
    else:
        va = [{"check": "false"}]
        return None
예제 #19
0
def Oadress():
    key1 = str(request.data)
    print(key1)
    key1 = key1.split("'")
    oid = int(key1[1])
    print("In Place order before calling db handler")
    print(oid)
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.getAddress(oid)
    if dd:

        return jsonify(dd)
    else:
        va = [{"check": "false"}]
        return jsonify(va)
예제 #20
0
def admin():
    print("admin Portal")
    email = request.form["email"]
    password = request.form["pass"]
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dict = db.validateAdmin(email, password)
    if dict:
        obj = db.ShowProducts()
        session["admin-email"] = email
        session["admin-username"] = dict["username"]
        print()
        return render_template("table.html",
                               listOfProducts=obj,
                               adminName=dict["username"])
    else:
        return render_template("adminLogin.html", error=True)
예제 #21
0
def pssrcvry():
    email = request.form['email']
    obj = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                      app.config["DB_PASSWORD"], app.config["DATABASE"])
    isuser = obj.isexist(email)
    if isuser:
        email = str(email)
        print(email)
        msg = "This is 6 digit code:" + str(otp)
        message = Message("OTP",
                          sender='*****@*****.**',
                          recipients=[email])
        message.body = msg
        mail.send(message)
        return render_template("pasrecvry.html", status=True)
    else:
        return render_template("pasrecvry.html", warning=True)
예제 #22
0
def upateStock():
    key1 = str(request.data)
    key1 = key1.split("'")
    score = key1[1]
    score = score.split(",")
    name = int(score[0])
    print(name)
    score = int(score[1])
    print(score)
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.updateInventory(name, score)
    if dd:
        va = [{"check": "true"}]
        return jsonify(va)
    else:
        va = [{"check": "false"}]
        return jsonify(va)
예제 #23
0
def anouncement():
    subject = request.form['sub']

    msg = request.form['message']

    obj = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                      app.config["DB_PASSWORD"], app.config["DATABASE"])
    email = obj.getusers()
    print(email)

    for i in email:
        message = Message(subject,
                          sender='*****@*****.**',
                          recipients=[i])
        message.body = msg

        mail.send(message)

    return render_template("anounce.html", status=True)
예제 #24
0
def placeOrder():
    key1 = str(request.data)
    key1 = key1.split("'")
    score = key1[1]
    score = score.split(",")
    total = int(score[0])

    cell = int(score[1])
    address = score[2]

    print("In Place order before calling db handler")
    print(total)
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.placeOrder(session.get("email"), total, cell, address)
    if dd:
        id = db.getOID()
        dd = db.orderitem(id)
        item = ""
        j = 1
        for i in dd:
            j = str(j)
            item = item + j + " Product Title:  " + i[
                "name"] + " Quantity:   " + str(
                    i["quantity"]) + " Product Price    " + str(
                        i["price"]) + "\n"
            j = int(j)
            j = j + 1
        adress = "On Following Address\n" + " address  " + address + "  cell no. " + str(
            cell)
        detail = "Your order id " + str(id) + "\n" + item + adress
        message = Message("Order",
                          sender='*****@*****.**',
                          recipients=[session["email"]])
        message.body = detail

        mail.send(message)
        va = [{"check": "true"}]
        return jsonify(va)
    else:
        va = [{"check": "false"}]
        return jsonify(va)
예제 #25
0
def upateCart():
    key1 = str(request.data)
    key1 = key1.split("'")
    score = key1[1]
    score = score.split(",")
    id = int(score[0])
    print(id)
    price = int(score[1])
    print(price)
    quan = int(score[2])
    print(quan)
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.updateCart(id, price, quan)
    if dd:
        va = [{"check": "true"}]
        return jsonify(va)
    else:
        va = [{"check": "false"}]
        return jsonify(va)
예제 #26
0
def login():
    print("login")
    email = request.form["email"]
    passw = request.form["pass"]
    print("login1")
    obj = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                      app.config["DB_PASSWORD"], app.config["DATABASE"])
    user_dic = obj.login(email, passw)
    print("login 2")
    print(user_dic)
    if user_dic:
        session["email"] = email
        session["username"] = user_dic["username"]
        if user_dic["role"] == "BuyerAccount":
            return redirect('/')
        else:
            return render_template("SellerDashboard.html",
                                   email=email,
                                   password=passw,
                                   role=user_dic["role"],
                                   username=user_dic["username"])
    else:
        return render_template("account.html")
예제 #27
0
def showfeedback():
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.getfeedback()
    return render_template("feedback.html", feedbackList=dd)
예제 #28
0
def showdigital():
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.CATAGERY('Digital')
    return render_template("product.html", product=dd)
예제 #29
0
def sellerpendingRequest():
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.sellershowpending(session["email"])
    return render_template("SellerPending.html", listOfProducts=dd)
예제 #30
0
def showorder():
    db = web_project(app.config["DATABASEIP"], app.config["DB_USER"],
                     app.config["DB_PASSWORD"], app.config["DATABASE"])
    dd = db.showOrder()
    df = db.detail
    return render_template("showOrder.html", listOfProducts=dd)