def newRegion(): if request.method == 'POST': region_name = request.form['name'] region_slug = '-'.join(region_name.lower().split(' ')) newRegion = Region(name=region_name, slug=region_slug, description=request.form['description']) session.add(newRegion) session.commit() return redirect(url_for('showRegions')) else: return render_template('newRegion.html')
def newRegion(): DBSession = sessionmaker(bind=engine) session = DBSession() if 'username' not in login_session: return redirect('/login') if request.method == 'POST': newRegion = Region(name=request.form['name'], user_id=login_session['user_id']) session.add(newRegion) flash('New Region %s Succesfully Created!' % newRegion.name) session.commit() return redirect(url_for('showAllRegions')) else: return render_template('newRegion.html')
def newRegion(): """Create a new region.""" if request.method == 'POST': newName = request.form['name'] if not newName: error = 'Please enter in a new restaurant name' return render_template('newRegion.html', error=error) else: session = getSession() newRegion = Region(name=newName, user_id=login_session['user_id']) session.add(newRegion) session.commit() flash("New region created!") session.close() return redirect(url_for('showRegions')) else: return render_template('newRegion.html')
session.add(country199) session.commit() country200 = Country(countryName="Yemen") session.add(country200) session.commit() country201 = Country(countryName="Zambia") session.add(country201) session.commit() country202 = Country(countryName="Zimbabwe") session.add(country202) session.commit() country203 = Country(countryName="Other") session.add(country203) session.commit() region1 = Region(cityName="Jaipur", country=country80) session.add(region1) session.commit() region2 = Region(cityName="Other", country=country203) session.add(region2) session.commit() craft1 = Craft(name="Textile") session.add(craft1) session.commit() craft2 = Craft(name="Paper") session.add(craft1) session.commit() craft3 = Craft(name="Wood")
}, { "country_id": "1", "id": "48", "name": "West Virginia" }, { "country_id": "1", "id": "49", "name": "Wisconsin" }, { "country_id": "1", "id": "50", "name": "Wyoming" }] for region in regions: newRegion = Region(name=region['name'], country_id=region['country_id']) session.add(newRegion) session.commit() # For this project I copied all the breweries and beers information/images on the website https://untappd.com/beer/top_rated # The website I created has no commercial purpose. # Create breweries breweries = [{ "country_id": "1", "region_id": "1", "user_id": "1", "name": "Good People Brewing Company", "image": "static/img/brewery_images/1.jpeg" }, { "country_id": "1",
# 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 a dummy user User1 = User(name='Wino Dino', email='*****@*****.**', picture='https://i.imgur.com/OXDj7nJ.jpg') session.add(User1) session.commit() # Create Burgundy Region region1 = Region(user_id=1, name='Burgundy') session.add(region1) session.commit() # Create Wines for Burgundy wine1 = Wine(user_id=1, name='Goisot Aligote 2017', description='This is a fine Aligote, unoaked and aged on the lees. It will absolutely keep for several years to come.', price='$18.96', region=region1) session.add(wine1) session.commit() wine2 = Wine(user_id=1, name='Lapiere Raisins Gauloins 2018', description='A simple Vin de France with lovely, fresh, grapey Gamay fruit. This joyous, refreshing, and lively wine is made by the son of Marcel Lapierre.', price='$15.99', region=region1) session.add(wine2) session.commit()
info_url_font = "http://gameinfo.na.leagueoflegends.com/en/game-info/champions/" """ champion1 = Champion(name = "", slug ="", role = "", description = description, region = region1) session.add() session.commit() """ # Champions for Demacia description = """ Demacia is a strong, lawful society with a prestigious military history. It values the ideals of justice, honor and duty highly, and its people are fiercely proud. """ region1 = Region(name="Demacia", slug="demacia", description=description) session.add(region1) session.commit() # No.1 champion description = """ Garen is a warrior of Demacia who has devoted his life to defending his kingdom and its ideals. Armed with his magic-resistant armor and broadsword, Garen puts his life on the line for both his nation, and his fellow soldiers. """ pic_url = pic_url_font + "Garen_0.jpg" info_url = info_url_font + "garen/" champion1 = Champion(name="Garen", slug="garen", role="Fighter", description=description, pic_url=pic_url,
# 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 initial user data User1 = User( name="John Doe", email="*****@*****.**", picture="https://pbs.twimg.com/profile_images/1237550450/mstom_400x400.jpg" ) session.add(User1) session.commit() # Create region for cities in the Pacific Northwest Region1 = Region(name="Pacific Northwest", user_id=1) session.add(Region1) session.commit() City1 = Cities( name="Seattle, WA", picture= "https://cdn.vox-cdn.com/uploads/chorus_image/image/53737065/eatersea0317_seattle_shutterstock.0.jpg", description= "Seattle is the largest city in the Pacific Northwest region of the United States. It is located in the U.S. state of Washington, about 108 miles (180 km) south of the American-Canadian border. ... Its official nickname is the Emerald City.", date=datetime.datetime.utcnow(), region_id=1, user_id=1) session.add(City1) session.commit()
# 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 dummy user User1 = User(name="Robo Barista", email="*****@*****.**", picture='https://pbs.twimg.com/profile_images/2671170543/18debd694829ed78203a5a36dd364160_400x400.png') session.add(User1) session.commit() # California california = Region(user_id=1, name="California") session.add(california) session.commit() trail1 = Trail(user_id=1, name="Braille Flow", difficulty="intermediate-advanced", description="The ridge climb is a bit of a haul, but the Braille Trail delivers nicely. It'll be over quick, but Braille is dense with small to medium (even medium-large) features, all of which are optional. Pick a good line and have a blast.", city="Day Valley", region=california) session.add(trail1) session.commit() trail2 = Trail(user_id=1, name="Downieville Classic", difficulty="intermediate-advanced", description="The Downieville Classic ride. Get your car/shuttle ride to the top. The trail starts immediately on singletrack. There is very, very little climbing. There will be snow in places through May.", city="Downieville", region=california) session.add(trail2) session.commit() # Colorado