def newSportItem():
    if 'username' not in login_session:
        flash("You must be logged in to create a new Item!")
        return redirect('/login/')
    logged_in = True
    session = DBSession()
    if request.method == 'POST':
        if request.form['sport']:
            try:
                sport_id = session.query(Sport).filter_by(
                    name=request.form['sport']).one().id
            except NoResultFound:
                flash("You didn't enter a valid sport, please choose from " +
                      "one of the below sports")
                return redirect(url_for('showSports'))
            newItem = SportItem(name=request.form['name'],
                                description=request.form['description'],
                                sport_id=sport_id,
                                user_id=login_session['user_id'])
            session.add(newItem)
            session.commit()
            flash('New Sport %s Item Successfully Created' % (newItem.name))
            return redirect(url_for('showSports'))
        elif not request.form['name'] or not request.form['description']:
            flash('You were missing some fields, please try again')
            return render_template('newSportItem.html', logged_in=logged_in)
        else:
            flash("Something unknown happened, please try again")
            return render_template('newSportItem.html', logged_in=logged_in)
    else:
        sports = session.query(Sport).all()
        return render_template('newSportItem.html',
                               sports=sports,
                               logged_in=logged_in)
def newItem():
	if 'username' not in login_session:
		return redirect('/login')
	sports = session.query(Sport).order_by(asc(Sport.name))
	if login_session['user_id']:
		if request.method == 'POST':
			sport_id = request.form['sport_id']
			sport = session.query(Sport).filter_by(id=sport_id).one()
			newItem = SportItem(name=request.form['name'], description=request.form['description'], sport_id=sport_id, user_id=login_session['user_id'])
			session.add(newItem)
			session.commit()
			flash('New %s Item Successfully Created' % (newItem.name))
			return redirect(url_for('showItems', sport_name=sport.name))
		else:
			return render_template('newsportitem.html', sports=sports, login=True)
def newSportItem():
    creator = getUserInfo(Sport.user_id)
    if 'username' not in login_session:
        return redirect(url_for('showLogin'))
    if request.method == 'POST':
        # new Sport Item is added to the database
        newSportItem = SportItem(name=request.form['name'],
                                 description=request.form['description'],
                                 sport=Sport(name=request.form['sport']),
                                 user_id=login_session['user_id'])
        session.add(newSportItem)
        flash('New Sport Item %s Successfully Created' % newSportItem.name)
        session.commit()
        return redirect(url_for('showSports'))
    else:
        return render_template('newSportItem.html')
Beispiel #4
0
def newItem():
    categories = session.query(SportCategory).all()
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newItem = SportItem(name=request.form['name'],
                            description=request.form['description'],
                            category_id=request.form['category'],
                            user_id=login_session['user_id'])
        session.add(newItem)

        # flash)('New item %s successfully created' %newItem.name)

        session.commit()
        return redirect(url_for('catalog'))
    else:
        return render_template('newitem.html', categories=categories)
Beispiel #5
0
def newItem():
    categories = session.query(SportCategory).all()
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newCatalogItem = SportItem(
            name=request.form['name'],
            description=request.form['description'],
            price=request.form['price'],
            sportcategory_name=request.form['sportcategory_name'],
            user_id=login_session['user_id'])
        session.add(newCatalogItem)
        session.commit()
        return redirect(
            url_for('singleCategoryItems',
                    name=newCatalogItem.sportcategory_name))
    else:
        return render_template('new_individual_item.html')
Beispiel #6
0
def createCategoryItem(category_name):
    if 'username' not in login_session:
        return redirect('/login')

    category = session.query(Category).filter_by(name=category_name).one()
    if request.method == 'GET':
        return render_template('createCategoryItem.html', category=category)
    else:
        category_items = session.query(SportItem).filter_by(
            category_id=category.id).all()
        newitem = SportItem(name=request.form['name'],
                            description=request.form['description'],
                            category=category,
                            user_id=login_session['user_id'])
        session.add(newitem)
        session.commit()

        return redirect(
            url_for('showCategoryItems', category_name=category_name))
Beispiel #7
0
def newSportItem(catalog_id):
    if 'username' not in login_session:
        return redirect('/login')

    catalog = session.query(Catalog).filter_by(id=catalog_id).one()
    username = login_session['username']
    picture = login_session['picture']
    if request.method == 'POST':
        newItem = SportItem(name=request.form['name'],
                            description=request.form['description'],
                            catalog_id=catalog_id)
        session.add(newItem)
        session.commit()
        message = flash('New %s Item Created Successfully' % (newItem.name))
        return redirect(url_for('showItem', picture=picture,
                                username=username, catalog_id=catalog_id,
                                message=message))
    else:
        return render_template('newSportItem.html', picture=picture,
                               username=username, catalog=catalog)
Beispiel #8
0
def addItem():
    if 'username' not in login_session:
        return redirect('/login')

    if request.method == 'GET':
        return render_template('addItem.html', categories=categories)
    else:

        category = session.query(Category).filter_by(
            name=str(request.form.get('selectedcategory'))).one()
        user = session.query(User).filter_by(
            email=login_session['email']).one()
        newitem = SportItem(name=request.form['name'],
                            description=request.form['description'],
                            category=category,
                            user=user)
        session.add(newitem)
        session.commit()

        return redirect(
            url_for('showCategoryItems', category_name=category.name))
Beispiel #9
0
# Users
user1 = User(name='Dawit Bekele', email='*****@*****.**', picture='')
session.add(user1)
session.commit()

user2 = User(name='John Doe', email='*****@*****.**', picture='')
session.add(user2)
session.commit()

#Items for Soccer
category1 = Category(name = "Soccer")
session.add(category1)
session.commit()


sportItem1 = SportItem(name = "Shinguards", description = "shinguard to protect the shins", category = category1, user = user1)

session.add(sportItem1)
session.commit()

sportItem2 = SportItem(name = 'Two shinguards', description=" two shinguards", category=category1, user=user2)
session.add(sportItem2)
session.commit()

sportItem3 = SportItem(name= "Jersey", description="Soccer team jersey", category=category1, user=user1)
session.add(sportItem3)
session.commit()

sportItem4 = SportItem(name="Soccer Cleats", description="soccer cleats", category=category1, user=user2)
session.add	(sportItem4)
session.commit()
    name="Savneet Singh",
    email="*****@*****.**",
    picture=
    'https://pbs.twimg.com/profile_images/2671170543/18debd694829ed78203a5a36dd364160_400x400.png'
)  # noqa
session.add(User1)
session.commit()

# Menu for Football
sport1 = Sport(user_id=User1.id, name="Football")

session.add(sport1)
session.commit()

sportItem1 = SportItem(user_id=User1.id,
                       name="Ball",
                       description="Leather ball, one per game.",
                       sport=sport1)

session.add(sportItem1)
session.commit()

sportItem2 = SportItem(user_id=User1.id,
                       name="Gloves",
                       description="Goalie uses gloves to protect hands.",
                       sport=sport1)

session.add(sportItem2)
session.commit()

sportItem3 = SportItem(user_id=User1.id,
                       name="Net",
Beispiel #11
0
# Create dummy user
User1 = User(name="Vivek Lingayat",
             email="*****@*****.**",
             picture='https://avatars1.githubusercontent.com/u/36252861')
session.add(User1)
session.commit()

# Kit for Soccer
sport1 = Sport(user_id=1, name="Soccer")

session.add(sport1)
session.commit()

SportItem1 = SportItem(
    user_id=1,
    name="Two shinguards",
    description=
    "A shin guard or shin pad is a piece of equipment worn on the front of a player's shin to protect them from injury. These are commonly used in sports including association football, baseball, ice hockey, field hockey, lacrosse, cricket, and other sports. This is due to either being required by the rules/laws of the sport or worn voluntarily by the participants for protective measures.",
    sport=sport1)

session.add(SportItem1)
session.commit()

SportItem2 = SportItem(
    user_id=1,
    name="Uniform",
    description=
    "Most youth soccer leagues require a standard uniform for all players. This might range from a simple T-shirt to a complete soccer uniform with matching jersey, shorts and socks. Some leagues issue the uniform to players, while others require you to order the uniform yourself.",
    sport=sport1)

session.add(SportItem2)
session.commit()
Beispiel #12
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()

# soccer
sport1 = Sport(name="Soccer")

session.add(sport1)
session.commit()

sportItem1 = SportItem(
    name="Ball",
    description=
    "Ball inflated with air to 9 PSI, usually made of hexagons of fabric.",
    sport=sport1)

session.add(sportItem1)
session.commit()

sportItem1 = SportItem(name="Goal",
                       description="Rectangular goal, with a net.",
                       sport=sport1)

session.add(sportItem1)
session.commit()

sportItem1 = SportItem(
    name="Cleats",
Beispiel #13
0
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"
                       " Neymar Mercurial Lite Soccer Shin Guards. The "
                       "durable resin shells are matched with EVA foam to "
                       "help diffuse any kicks to the shin, and they are "
                       "anatomically shaped for targeted comfort.",
                       price="$21.99",
Beispiel #14
0
# 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)

session.add(sportItem2)
session.commit()

# Sports items for Basketball
category2 = SportCategory(name="Basketball")
Beispiel #15
0

# Create dummy user
User1 = User(name="Captain Marvel", email="*****@*****.**",
             picture='')
session.add(User1)
session.commit()

# Sport items for Soccer
catalog1 = Catalog(user_id=1, name="Soccer")

session.add(catalog1)
session.commit()

sportItem2 = SportItem(user_id=1, name="Ball",
                       description="This brand of soccer ball \
                                   was used in the last world cup.",
                       catalog=catalog1)

session.add(sportItem2)
session.commit()


sportItem1 = SportItem(user_id=1, name="Goal net",
                       description="FIFA standard size goal with \
                                    net and posts",
                       catalog=catalog1)

session.add(sportItem1)
session.commit()

sportItem2 = SportItem(user_id=1, name="Rebounder",
Beispiel #16
0
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)
session.commit()

item2 = SportItem(name="Football Cleats",
                  description="Find the latest football boots \
    from Nike, adidas, Puma, Umbro & many more",
                  sport=category1,
                  user_id=1)

session.add(item2)