Ejemplo n.º 1
0
def newSport():
    categories = session.query(SportCategory).all()
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newSport = SportCategory(name=request.form['name'])
        session.add(newSport)
        session.commit()
        return redirect(url_for('catalog'))
    else:
        return render_template('newcategory.html', categories=categories)
Ejemplo n.º 2
0
def newSportCategory():
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        print login_session['user_id']
        newSportCategory = SportCategory(name=request.form['name'],
                                         userId=login_session['user_id'])
        session.add(newSportCategory)
        session.commit()
        flash(" Sport Category created.")
        return redirect(url_for('showSportCategory'))
    else:
        return render_template('newsportscategory.html')
Ejemplo n.º 3
0
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)

session = DBSession()

# Create dummy user
User1 = User(name="Schevon Joseph",
             email="*****@*****.**",
             picture='''https://pbs.twimg.com/profile_images/2671170543/
             18debd694829ed78203a5a36dd364160_400x400.png''')
session.add(User1)
session.commit()
# Insert a sports category record into the db
sportsCategory1 = SportCategory(name="Soccer", userId=1)

session.add(sportsCategory1)
session.commit()

# Insert a Sporting Item record into the db
sportingItem1 = SportingItem(name="Goal Keeping Gloves",
                             userId=1,
                             description="Gloves provides a better grip",
                             sport=sportsCategory1)

session.add(sportingItem1)
session.commit()

sportingItem2 = SportingItem(name="Soccer cleats",
                             userId=1,
Ejemplo n.º 4
0
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

from database_setup import SportCategory, Base, SportItem
engine = create_engine('sqlite:///catalog.db')

Base.metadata.bind = engine

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

# List for Soccer
category1 = SportCategory(name="Soccer")
session.add(category1)
session.commit()

sportItem1 = SportItem(name="Soccer Ball",
                       description="Aim for the corners and practice "
                       "through-passes with this adidas Starlancer V Adult "
                       "Soccer Ball. The butyl bladder retains air while you "
                       "train and hone your on-field skills, while the machine"
                       "-stitched imitation leather cover provides a great"
                       "feel as you pass and shoot.",
                       price="$12.99",
                       sportcategory=category1)
session.add(sportItem1)
session.commit()

sportItem1 = SportItem(name="Shin Guards",
                       description="You'll get the most protection with the "
                       "least amount of coverage with the Nike Adults"
Ejemplo n.º 5
0
# Bind the engine to the metadata of the Base class so that the
# declaratives can be accessed through a DBSession instance
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
# 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()

# Sports items for Soccer
category1 = SportCategory(name="Soccer")

session.add(category1)
session.commit()

sportItem1 = SportItem(name="Soccer ball",
                       description="For you to kick around",
                       sportcategory=category1)

session.add(sportItem1)
session.commit()

sportItem2 = SportItem(name="Soccer shirt",
                       description="A shirt with number",
                       sportcategory=category1)
Ejemplo n.º 6
0
# declaratives can be accessed through a DBSession instance
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
# 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()


# Menu for Soccer
sport1 = SportCategory(sport="Soccer")

session.add(sport1)
session.commit()

item1 = MenuItem(name="Soccer Ball", description="High quality materials in the cover, \
backing and bladder help to provide next level match ball performance.\
Thermally bonded, seamless surface for a more predictable flight path, better \
touch, and less water uptake. TSBE technology for a seamless surface with \
better touch and lower water uptake.COVER: Textured TPU",price="$20.50",
                 date='2010-01-23', sport=sport1)
item2 = MenuItem(name="G-form Shin Gaurd", description="This soft, flexible soccer \
shin guard hardens on impact. No hard shell for better comfort, performance, \
and compliance. Lightweight, breathable guard that reduces heat and sweat.\
Combines G-Form's proprietary and patented molded composite constructions\
and designs with a unique integration of XRD Technology to provide the best\
Ejemplo n.º 7
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="Robo Barista",
             email="*****@*****.**",
             picture='https://pbs.twimg.com/profile_images/2671170543/\
    18debd694829ed78203a5a36dd364160_400x400.png')
session.add(User1)
session.commit()

category1 = SportCategory(name="Football", user_id=1)
session.add(category1)
session.commit()

item1 = SportItem(name="Gloves",
                  description="No matter if you're a skill player \
    or a lineman in the trenches, football gloves help \
    players gain an edge on the field. \
    Receivers, running backs and defensive backs \
    depend on football gloves to grip the ball, while\
    linemen benefit from the added warmth and\
    protection gloves provide.",
                  sport=category1,
                  user_id=1)

session.add(item1)