050
This commit is contained in:
parent
47ad38fed7
commit
1423925b1a
BIN
db5.sqlite3
BIN
db5.sqlite3
Binary file not shown.
64
src/a3.nim
64
src/a3.nim
@ -236,14 +236,15 @@ import
|
|||||||
email: string
|
email: string
|
||||||
password: string
|
password: string
|
||||||
db = newDatabase()
|
db = newDatabase()
|
||||||
productName= ""
|
productName: string
|
||||||
quantity = 0
|
quantity: int
|
||||||
cart: seq[Cart]
|
cart: seq[Cart]
|
||||||
products: seq[Products]
|
products: seq[Products]
|
||||||
productCount = 0
|
productCount = 0
|
||||||
form = ctx.urlForm
|
form = ctx.urlForm
|
||||||
val: Validity
|
val: Validity
|
||||||
validity = initTable[string, Validity]()
|
validity = initTable[string, Validity]()
|
||||||
|
echo 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
email = ctx.cookies["email"]
|
email = ctx.cookies["email"]
|
||||||
@ -259,6 +260,8 @@ import
|
|||||||
productName = ""
|
productName = ""
|
||||||
quantity = 0
|
quantity = 0
|
||||||
|
|
||||||
|
echo ctx.queryParams["prod"]
|
||||||
|
|
||||||
var
|
var
|
||||||
country = form["c_country"]
|
country = form["c_country"]
|
||||||
firstName = form["c_fname"]
|
firstName = form["c_fname"]
|
||||||
@ -270,6 +273,8 @@ import
|
|||||||
phone = form["c_phone"]
|
phone = form["c_phone"]
|
||||||
password1: string
|
password1: string
|
||||||
|
|
||||||
|
echo 3
|
||||||
|
|
||||||
try:
|
try:
|
||||||
password1 = form["password"]
|
password1 = form["password"]
|
||||||
except:
|
except:
|
||||||
@ -278,6 +283,8 @@ import
|
|||||||
if email != "":
|
if email != "":
|
||||||
productCount = micsCartProductCount(email, password)
|
productCount = micsCartProductCount(email, password)
|
||||||
|
|
||||||
|
echo 4
|
||||||
|
|
||||||
if country != "" and firstName != "" and lastName != "" and address != "" and state != "" and zip != "" and email != "" and phone != "":
|
if country != "" and firstName != "" and lastName != "" and address != "" and state != "" and zip != "" and email != "" and phone != "":
|
||||||
var
|
var
|
||||||
userId = db.getUserId(email, password)
|
userId = db.getUserId(email, password)
|
||||||
@ -311,6 +318,9 @@ import
|
|||||||
ctx.send(sendThankYou())
|
ctx.send(sendThankYou())
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
echo 5
|
||||||
|
|
||||||
for a, b in form:
|
for a, b in form:
|
||||||
if form[a] == "":
|
if form[a] == "":
|
||||||
val.name = ""
|
val.name = ""
|
||||||
@ -323,19 +333,31 @@ import
|
|||||||
val.mark = ""
|
val.mark = ""
|
||||||
validity[a] = val
|
validity[a] = val
|
||||||
|
|
||||||
if productName != "":
|
echo productName
|
||||||
var
|
|
||||||
product: Products
|
|
||||||
ca: Cart
|
|
||||||
|
|
||||||
product.id = 1
|
# elif productName != "":
|
||||||
product.name = productName
|
# var
|
||||||
product.price = db.getPriceByProductName(productName)
|
# product: Products
|
||||||
ca.quantity = quantity
|
# ca: Cart
|
||||||
products.add(product)
|
|
||||||
cart.add(ca)
|
|
||||||
|
|
||||||
else:
|
# product.id = 1
|
||||||
|
# product.name = productName
|
||||||
|
# product.price = db.getPriceByProductName(productName)
|
||||||
|
# ca.quantity = quantity
|
||||||
|
# products.add(product)
|
||||||
|
# cart.add(ca)
|
||||||
|
# ch = "d"
|
||||||
|
|
||||||
|
# else:
|
||||||
|
# var
|
||||||
|
# userId = db.getUserId(email, password)
|
||||||
|
# cart = db.getUserCart(userId)
|
||||||
|
|
||||||
|
# for c, d in cart:
|
||||||
|
# var product = db.getProductById(d.productId)
|
||||||
|
# products.add(product)
|
||||||
|
|
||||||
|
if productName == "":
|
||||||
var
|
var
|
||||||
userId = db.getUserId(email, password)
|
userId = db.getUserId(email, password)
|
||||||
cart = db.getUserCart(userId)
|
cart = db.getUserCart(userId)
|
||||||
@ -344,6 +366,21 @@ import
|
|||||||
var product = db.getProductById(d.productId)
|
var product = db.getProductById(d.productId)
|
||||||
products.add(product)
|
products.add(product)
|
||||||
|
|
||||||
|
else:
|
||||||
|
var
|
||||||
|
product: Products
|
||||||
|
ca: Cart
|
||||||
|
|
||||||
|
product.id = 1
|
||||||
|
echo product
|
||||||
|
product.name = productName
|
||||||
|
echo product
|
||||||
|
product.price = db.getPriceByProductName(productName)
|
||||||
|
echo product
|
||||||
|
ca.quantity = quantity
|
||||||
|
products.add(product)
|
||||||
|
cart.add(ca)
|
||||||
|
|
||||||
ctx.send(sendCheckOut(validity, totalPriceHTML(products, cart)))
|
ctx.send(sendCheckOut(validity, totalPriceHTML(products, cart)))
|
||||||
|
|
||||||
"/lname" -> post:
|
"/lname" -> post:
|
||||||
@ -538,6 +575,7 @@ import
|
|||||||
compileTemplateFile(getScriptDir() / "a3a" / "login.nimja")
|
compileTemplateFile(getScriptDir() / "a3a" / "login.nimja")
|
||||||
|
|
||||||
"/login" -> post:
|
"/login" -> post:
|
||||||
|
echo ctx.queryParams
|
||||||
var
|
var
|
||||||
email = ctx.urlForm["email"]
|
email = ctx.urlForm["email"]
|
||||||
password = ctx.urlForm["password"]
|
password = ctx.urlForm["password"]
|
||||||
|
Loading…
Reference in New Issue
Block a user