Example #1
0
def daftar_seller():
	if request.method == 'POST':
		nama = request.form['nama']
		gender = request.form['gender']
		lahir = request.form['lahir']
		address = request.form['address']
		phone = request.form['phone']
		email = request.form['email']
		username = request.form['username']
		password = request.form['password']
		photo = request.files['photo']
		category = request.form['category']
		company = request.form['company']
		photoname = secure_filename(photo.filename)
		if(not allowed_file(photoname)):
			return ('photo type is not allowed')
		photodir =  os.path.join(app.config['UPLOAD_FOLDER'], photoname)
		while(session.query(ArticlePhoto).filter_by(dir=photodir).first() or session.query(ShopPhoto).filter_by(dir=photodir).first() or session.query(User).filter_by(photodir=photodir).first()):
			photoname = str(1) + photoname
			photodir =  os.path.join(app.config['UPLOAD_FOLDER'], photoname)
			print(session.query(ArticlePhoto).filter_by(dir=photodir))
		new_user = User(username,password,nama,email,gender,lahir,phone,address,photodir)
		new_shop = Shop(name=company,user=username)
		new_shoptag = ShopTag(name=company, tag=category)
		new_shopphoto = ShopPhoto(shopname=company,dir=photodir)
		session.add(new_user)
		session.add(new_shop)
		session.add(new_shoptag)
		session.add(new_shopphoto)
		session.commit()
		photo.save(os.path.join(app.config['UPLOAD_FOLDER'], photoname))
		return(redirect(url_for('login')))
	else:
		return render_template('be_a_seller.html')
Example #2
0
def createShop():
    newShop = Shop(name=request.data, owner_id=login_session['user_id'],
        image = defImgUrl)
    session.add(newShop)
    session.commit()
    shop = session.query(Shop).filter_by(name=request.data,
        owner_id=login_session['user_id']).order_by(Shop.id.desc()).first()
    return jsonify(shop=shop.serialize)
def newShop():
    if request.method == 'POST':
        newShop = Shop(name=request.form['name'],
                       user_id=login_session['user_id'])
        session.add(newShop)
        flash('New Shop %s Successfully Created' % newShop.name)
        session.commit()
        return redirect(url_for('showShops'))
    else:
        return render_template('newShop.html')
Example #4
0
def newShop():
    if request.method == 'POST':
        name = request.form['name']
        if validShopname(name):
            user_id = login_session['user_id']
            newShop = Shop(name=name, user_id=user_id)
            session.add(newShop)
            flash('New Shop %s Successfully Created' % newShop.name)
            session.commit()
        else:
            flash('Name %s has been used.Please try another one.' % name,
                  'error')
        return redirect(url_for('showShops'))
    else:
        return render_template('newShop.html')
Example #5
0
def newShop():
    if 'username' not in login_session:
        return redirect('/login')

    if request.method == 'POST':
        if 'shopPic' in request.files:
            file = request.files['shopPic']
            filename = savingImgs(file)
        else:
            filename = "ImgPlaceHolder.png"
        newShop = Shop(name=request.form['shopName'],
                       shopImgName=filename,
                       user_id=login_session['user_id'])
        session.add(newShop)
        session.commit()
        flash("Your shop %s has been added!" % newShop.name)
        return redirect(url_for('showShops'))

    else:
        return render_template('addShop.html')
Example #6
0
# A DBSession() instance establishes all conversations with the database
# and represents a "staging zone" for all the objects loaded into the
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()

#Create first user
User1 = User(name="Mona Musterfrau", email="*****@*****.**", picture='https://cdn.pixabay.com/photo/2017/09/01/21/53/blue-2705642_1280.jpg')
session.add(User1)
session.commit()

# Offer for Fancy Dresses
shop1 = Shop(user_id=1, name = "Fancy Wedding Dresses")

session.add(shop1)
session.commit()


offerItem1 = OfferItem(user_id=1, name = "Wedding dress", description = "A dream for the best day of your life", price = "$2000.99", style = "Dresses", shop = shop1)

session.add(offerItem1)
session.commit()

offerItem2 = OfferItem(user_id=1, name = "High Heels", description = "Fabulous and still comfortable to wear", price = "$20.50", style = "Shoes", shop = shop1)

session.add(offerItem2)
session.commit()
from database_setup import Base, Item, Shop
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import datetime

# Create session and connect to DB
engine = create_engine('sqlite:///item.db')
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()

# Shops for db

shop1 = Shop(name="Tmall")
session.add(shop1)
session.commit()

shop2 = Shop(name="Walmart")
session.add(shop2)
session.commit()

shop3 = Shop(name="Amazon")
session.add(shop3)
session.commit()

shop4 = Shop(name="Shopbop")
session.add(shop4)
session.commit()

shop5 = Shop(name="Gilt")
session.add(shop5)
Example #8
0
session = DBSession()

# Placeholder Data

user = User(email="*****@*****.**")
session.add(user)
session.commit()

user = User(email="*****@*****.**")
session.add(user)
session.commit()

#############Store 1
shop = Shop(
    name="Blair's Blankets",
    hours="9am-7pm",
    phone_number="555-7654",
    image="https://images.pexels.com/photos/90317/pexels-photo-90317.jpeg",
    owner_id=1)
session.add(shop)
session.commit()

product = Product(
    name="duvet",
    description="it is the one that goes on the bed",
    image=
    "https://cdn.pixabay.com/photo/2016/04/28/13/41/sunday-1358907__340.jpg",
    price="$36",
    shop_id=1)
session.add(product)
session.commit()
Example #9
0
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()

# Create dummy user
User1 = User(name="Muteb",
             email="*****@*****.**",
             picture='https://wmpics.pics/di-L2Z5.png')
session.add(User1)
session.commit()

# items for Men's Fashion
shop1 = Shop(user_id=1, name="Men's Fashion")

session.add(shop1)
session.commit()

category_item1 = CategoryItem(
    user_id=1,
    name="Shirt",
    description="A cloth garment for the upper body.",
    price="$20",
    item="Clothing",
    shop=shop1)

session.add(category_item1)
session.commit()
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
session = DBSession()

# Create dummy user
User1 = User(
    name="Ivan Baranov",
    email="*****@*****.**",
    picture=
    "https://pbs.twimg.com/profile_images/557287123867279362/AHJEXcNA.jpeg")
session.add(User1)
session.commit()

# Item for Adidas
shop1 = Shop(name="Adidas")

session.add(shop1)
session.commit()

menuItem1 = MenuItem(
    name="ALPHABOUNCE CHINESE NEW YEAR SHOES",
    description="CUSHIONED RUNNERS THAT HONOR THE LUNAR NEW YEAR.",
    price="$100",
    image="adidas/1.jpg",
    shops=shop1,
    user_id=1)

session.add(menuItem1)
session.commit()
Example #11
0
from database_setup import Base,Item,Shop
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import datetime

# Create session and connect to DB
engine = create_engine('postgresql://*****:*****@localhost/catalog')
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()

# Shops for db

shop1 = Shop(name="Finish Line")
session.add(shop1)
session.commit()

shop2 = Shop(name="Walmart")
session.add(shop2)
session.commit()

shop3 = Shop(name="American Eagle")
session.add(shop3)
session.commit()

shop4 = Shop(name="Amazon")
session.add(shop4)
session.commit()

shop5 = Shop(name="Forever 21")
session.add(shop5)