def create_app(self): config_name = 'testing' app.config.update( SQLALCHEMY_DATABASE_URI=os.getenv('TEST_DB_URI'), SECRET_KET=os.getenv('TEST_SECRET_KEY'), WTF_CSRF_ENABLES=False, DEBUG=True ) self.user = Admin( email='*****@*****.**', password=bcrypt.generate_password_hash('ThisPasswordSucks')) self.contact = Contact( first_name= 'John', last_name= 'Johnson', email_address= '*****@*****.**', phone_number= '+446789261532', location_id = 1 ) self.location = Locations( first_line = 'number 1', second_line = 'some street', city = 'Manchester', post_code = 'AAA1 AAA' ) return app
def setUp(self): db.create_all() location = Locations(wall_name='The big one', county='Cheshire', town='Chester', postcode='CH1 4HX') activity1 = Activities(wall_id=1, activity_name='Rock Climbing', additional_equiptment=True) db.session.add(location) db.session.add(activity1) db.session.commit()
def add(): form = LocationForm() if form.validate_on_submit(): location = Locations( wall_name = form.wall_name.data, county = form.county.data, town = form.town.data, postcode = form.postcode.data ) db.session.add(location) db.session.commit() return redirect(url_for('index')) return render_template('addwall.html', title="New Wall", form=form)
def setUp(self): db.create_all() test_exercise = Exercises(exercise_name="Test Jumping", description="Test up and down", sets="3", reps="12") test_location = Locations(location_name="Test Park", description="Test description", address="Test address") test_location_exercise = Location_exercises(exercise_id=1, location_id=1) db.session.add(test_exercise) db.session.add(test_location) db.session.add(test_location_exercise) db.session.commit()
def add_location(country, activity, rating, city, ref): if not current_user.is_authenticated: return redirect(url_for('register')) country = str(country).strip("'") activity = str(activity) rating = str(rating) city = str(city).strip("'") ref = str(ref) location = Locations(country=country, city=city, activity=activity, address=rating, user_id=current_user.id, ref=ref) db.session.add(location) db.session.commit() return redirect(url_for('view_location'))
def data(self): with open("Tooling/office_location_data.csv", "r") as Data: for line in Data: DATASTREAM = line.split(',') print(DATASTREAM) Location_Data = Locations( first_line=DATASTREAM[0], second_line=DATASTREAM[1], city=DATASTREAM[2], post_code=DATASTREAM[3], ) db.session.add(Location_Data) contact = Contact(first_name='John', last_name='Johnson', email_address='*****@*****.**', phone_number='+446251893271', location_id=1) db.session.add(contact) db.session.commit()
from application import db from application.models import Locations, Admin, Contact db.drop_all() db.create_all() with open("Tooling/office_location_data.csv", "r") as Data: for line in Data: DATASTREAM = line.split(',') print(DATASTREAM) Location_Data = Locations( first_line = DATASTREAM[0], second_line = DATASTREAM[1], city = DATASTREAM[2], post_code = DATASTREAM[3], ) db.session.add(Location_Data) db.session.commit()