Ejemplo n.º 1
0
def addToCart(item_id):
	if 'email' not in session:
		return redirect(url_for('signin'))
	else:
		item=db.query(Product).filter_by(item_id=item_id).first()
		item_present=db.query(Storeshopper_track).filter_by(session_id=session['email'],sel_item_id=item_id).count()
		if item_present==0:
			mycart=Storeshopper_track(session_id=session['email'],name=item.name,sel_item_qty=1,sel_item_id=item_id,date_added=datetime.now(),price=item.price)
			db.add(mycart)
			db.commit()
		else:
			item_present=db.query(Storeshopper_track).filter_by(session_id=session['email'],sel_item_id=item_id).first()
			item_present.sel_item_qty+=2
		flash("Item is Added to Cart")
	return redirect(url_for('viewProduct',cat_id=item_id[0]))
Ejemplo n.º 2
0
def viewProduct(cat_id):
	show_category()
	if cat_id>=3:
		return render_template('game.html')
	else:
		items=db.query(Product).filter_by(cat_id=cat_id)
		return render_template('cat_item.html',items=items,category="category",categories=categories)
Ejemplo n.º 3
0
def checkout():
	msg=Message("you subject",sender='*****@*****.**',recipients=[session['email']])
	items=db.query(Storeshopper_track).filter_by(session_id=session['email']).all()
	msg.body=""" """
	total=0
	for i in items:
		msg.body+="""
		Name: %s Price: %s  Quantity: %s  
		Total Price: %s
		"""%(i.name,i.price,i.sel_item_qty,i.price*i.sel_item_qty)
		total=total+i.price*i.sel_item_qty
	msg.body+=""" 
		Total: %s 
		Thankyou For Shopping
	"""%(total)
	mail.send(msg)
	
	#adding user data to userData table
	newUserData=UserData(user_email=session['email'],date_added=items[0].date_added,amount=total)
	db.add(newUserData)
	db.commit()

	#deleting data from the storeshopper_trac
	for i in items:
		db.delete(i)
	db.commit()	
	return render_template('checkout.html')
Ejemplo n.º 4
0
def checkout():
    msg = Message("you subject",
                  sender='*****@*****.**',
                  recipients=[session['email']])
    items = db.query(Storeshopper_track).filter_by(
        session_id=session['email']).all()
    msg.body = """ """
    total = 0
    for i in items:
        msg.body += """
		Name: %s Price: %s  Quantity: %s  
		Total Price: %s
		""" % (i.name, i.price, i.sel_item_qty, i.price * i.sel_item_qty)
        total = total + i.price * i.sel_item_qty
    msg.body += """ 
		Total: %s 
		Thankyou For Shopping
	""" % (total)
    mail.send(msg)

    #adding user data to userData table
    newUserData = UserData(user_email=session['email'],
                           date_added=items[0].date_added,
                           amount=total)
    db.add(newUserData)
    db.commit()

    #deleting data from the storeshopper_trac
    for i in items:
        db.delete(i)
    db.commit()
    return render_template('checkout.html')
Ejemplo n.º 5
0
def profile():
	if 'email' not in session:
		return redirect(url_for('signin'))
	
	user=db.query(Users).filter_by(email=session['email']).first()
	if user is None:
		return redirect(url_for('signup'))
	else:
		return redirect(url_for('profileHome'))
Ejemplo n.º 6
0
def profile():
    if 'email' not in session:
        return redirect(url_for('signin'))

    user = db.query(Users).filter_by(email=session['email']).first()
    if user is None:
        return redirect(url_for('signup'))
    else:
        return redirect(url_for('profileHome'))
Ejemplo n.º 7
0
def showCart():
	if 'email' not in session:
		return redirect(url_for('signin'))
	else:
		cart_item=db.query(Storeshopper_track).filter_by(session_id=session['email'])
		total=0
		for item in cart_item:
			total=total+item.price*item.sel_item_qty
		return render_template('cart.html',cart_item=cart_item,total=total)
Ejemplo n.º 8
0
def showCart():
    if 'email' not in session:
        return redirect(url_for('signin'))
    else:
        cart_item = db.query(Storeshopper_track).filter_by(
            session_id=session['email'])
        total = 0
        for item in cart_item:
            total = total + item.price * item.sel_item_qty
        return render_template('cart.html', cart_item=cart_item, total=total)
Ejemplo n.º 9
0
def viewProduct(cat_id):
    show_category()
    if cat_id >= 3:
        return render_template('game.html')
    else:
        items = db.query(Product).filter_by(cat_id=cat_id)
        return render_template('cat_item.html',
                               items=items,
                               category="category",
                               categories=categories)
Ejemplo n.º 10
0
    def validate(self):
        if not Form.validate(self):
            return False

        user = db.query(Users).filter_by(email=self.email.data.lower()).first()
        if user and user.check_password(self.password.data):
            return True
        else:
            self.email.errors.append("Invalid email or password")
            return False
Ejemplo n.º 11
0
	def validate(self):
		if not Form.validate(self):
			return False

		user=db.query(Users).filter_by(email=self.email.data.lower()).first()
		if user:
			self.email.errors.append("That email is already taken")
			return False
		else:
			return True
Ejemplo n.º 12
0
	def validate(self):
		if not Form.validate(self):
			return False

		user=db.query(Users).filter_by(email=self.email.data.lower()).first()
		if user and user.check_password(self.password.data):
			return True
		else:
			self.email.errors.append("Invalid email or password")
			return False
Ejemplo n.º 13
0
    def validate(self):
        if not Form.validate(self):
            return False

        user = db.query(Users).filter_by(email=self.email.data.lower()).first()
        if user:
            self.email.errors.append("That email is already taken")
            return False
        else:
            return True
Ejemplo n.º 14
0
def addToCart(item_id):
    if 'email' not in session:
        return redirect(url_for('signin'))
    else:
        item = db.query(Product).filter_by(item_id=item_id).first()
        item_present = db.query(Storeshopper_track).filter_by(
            session_id=session['email'], sel_item_id=item_id).count()
        if item_present == 0:
            mycart = Storeshopper_track(session_id=session['email'],
                                        name=item.name,
                                        sel_item_qty=1,
                                        sel_item_id=item_id,
                                        date_added=datetime.now(),
                                        price=item.price)
            db.add(mycart)
            db.commit()
        else:
            item_present = db.query(Storeshopper_track).filter_by(
                session_id=session['email'], sel_item_id=item_id).first()
            item_present.sel_item_qty += 2
        flash("Item is Added to Cart")
    return redirect(url_for('viewProduct', cat_id=item_id[0]))
Ejemplo n.º 15
0
def removeItemFromCart(item_id):
    item = db.query(Storeshopper_track).filter_by(session_id=session['email'],
                                                  sel_item_id=item_id).one()
    db.delete(item)
    db.commit()
    return redirect(url_for('showCart'))
Ejemplo n.º 16
0
def show_category():
    global categories
    categories = db.query(Category).all()
Ejemplo n.º 17
0
def profileHome():
	userData=db.query(UserData).filter_by(user_email=session['email'])
	return render_template('profileHome.html',userData=userData)
Ejemplo n.º 18
0
def profileDetails():
	user=db.query(Users).filter_by(email=session['email']).first()
	return render_template('profileDetails.html',user=user)
Ejemplo n.º 19
0
def updateQuantity(item_id):
	if request.method=='POST':
		item=db.query(Storeshopper_track).filter_by(session_id=session['email'],sel_item_id=item_id).first()
		item.sel_item_qty=request.form['quantity']
	return redirect(url_for('showCart'))
Ejemplo n.º 20
0
def removeItemFromCart(item_id):
	item=db.query(Storeshopper_track).filter_by(session_id=session['email'],sel_item_id=item_id).one()
	db.delete(item)
	db.commit()
	return redirect(url_for('showCart'))
Ejemplo n.º 21
0
def updateQuantity(item_id):
    if request.method == 'POST':
        item = db.query(Storeshopper_track).filter_by(
            session_id=session['email'], sel_item_id=item_id).first()
        item.sel_item_qty = request.form['quantity']
    return redirect(url_for('showCart'))
Ejemplo n.º 22
0
def profileHome():
    userData = db.query(UserData).filter_by(user_email=session['email'])
    return render_template('profileHome.html', userData=userData)
Ejemplo n.º 23
0
def profileDetails():
    user = db.query(Users).filter_by(email=session['email']).first()
    return render_template('profileDetails.html', user=user)
Ejemplo n.º 24
0
 def decrease_student_year(self):
     all = db.query(Student).filter_by().all()
     for each_student in all:
         each_student.student_year -= 1
     db.session.commit()
Ejemplo n.º 25
0
def show_category():
	global categories
	categories=db.query(Category).all()