Exemple #1
0
def droptables():
	# Drops all the data we have currently.
	deleteAll_Password = '******'
	deleteAll_ExceptUsers = 'delete'


	if request.method == 'POST' and request.form['verify'] == deleteAll_Password:
		db.drop_all()
		db.create_all()
		createDefaultAccounts()
		createSampleGuests()
		createSampleBuildings()
		createSampleRooms()
		print("TABLES REBUILT")
		return render('basic.html',title="Tables erased.",content="Data has been reset")

	elif request.method == 'POST' and request.form['verify'] == deleteAll_ExceptUsers:
		db.drop_all(bind=Reservation)
		db.create_all()
		createDefaultAccounts()
		print("TABLES REBUILT")
		return render('basic.html',title="Tables erased.",content="SOME data has been reset")

	else:
		content = 'Type the password to verify. <form action="/droptables" method="POST">'
		content += '<input type="text" name="verify">'
		content += '<input type="submit" value="Delete All Data">'
		return render('basic.html',title="Drop Table Verification",content=content)
Exemple #2
0
def page_create_all():
	try:
		db.drop_all()
		db.create_all()
		createDefaultAccounts()

		db.session.add(Building(name="Miller", numfloors=8, status=CONST.ready_status, description="Contains numerous two person rooms and two elevators.", notes="This building is available for the summer."))
		db.session.add(Building(name="Dieseth", numfloors=8, status=CONST.ready_status, description="Contains numerous two person rooms and a single elevator.", notes="This building is available for the summer."))
		db.session.add(Building(name="Brandt", numfloors=5, status=CONST.ready_status, description="First year hall that has both three person and two person rooms.", notes="This building is used for parents for graduation and some camps."))
		db.session.add(Building(name="Farwell", numfloors=8, status=CONST.ready_status, description="Rooms are set up and organized around central rooms.", notes="This building is available for the summer school students."))
		db.session.add(Building(name="Larsen", numfloors=4, status=CONST.inactive_status, description="Larsen has heaters in each room and contains a wardrobe in each room as well.", notes="This building is unavailable."))
		db.session.add(Building(name="Ylvisaker", numfloors=5, status=CONST.ready_status, description="First year hall that has numerous two person rooms. The hallways are a bit smaller here.", notes="This building is available for the summer."))
		db.session.add(Building(name="Olson", numfloors=3, status=CONST.ready_status, description="Olson has many two person rooms and suites that are two person rooms with a central room between those two.", notes="This building is available for the summer."))
		db.session.commit()
		for j in range(1, 16):
			db.session.add(Room(roomnumber= j, buildingID='3', capacity='2', description="Room in Brandt",  status=CONST.ready_status, notes="Groud Floor"))
		for i in range(1, 9):
			for j in range(1, 31):
				db.session.add(Room(roomnumber=(i * 100 + j), buildingID='1', capacity='2', description="Room in Miller",  status=CONST.ready_status, notes=""))
				db.session.add(Room(roomnumber=(i * 100 + j), buildingID='2', capacity='2', description="Room in Dieseth",  status=CONST.ready_status, notes=""))
				db.session.add(Room(roomnumber=(i * 100 + j), buildingID='4', capacity='2', description="Room in Farwell",  status=CONST.ready_status, notes=""))
				if i < 5:
					db.session.add(Room(roomnumber=(i * 100 + j), buildingID='3', capacity='2', description="Room in Brandt",  status=CONST.ready_status, notes=""))
					db.session.add(Room(roomnumber=(i * 100 + j + 30), buildingID='3', capacity='3', description="Room in Brandt",  status=CONST.ready_status, notes="Three person room"))
					db.session.add(Room(roomnumber=(i * 100 + j), buildingID='5', capacity='2', description="Room in Larsen",  status=CONST.inactive_status, notes=""))
					if i != 4:
						db.session.add(Room(roomnumber=(i * 100 + j), buildingID='7', capacity='4', description="Room in Olson",  status=CONST.ready_status, notes=""))
					db.session.add(Room(roomnumber=(i * 100 + j), buildingID='6', capacity='2', description="Room in Ylvi",  status=CONST.ready_status, notes=""))

		db.session.commit()
		fnlist = ["Bruce", "Tom", "Harry", "David", "Henry", "Thomas", "Isaac", "Katie", "Susan", "Peter", "Kelly", "Emilay", "Alahna", "Morgan", "Neil", "Kierra", "Leah", "Lucia", "Marissa", "Melissa", "Aidan"]
		lnlist = ["Bennett", "Dhondup", "Stekel", "Miller", "Lee", "Ranum", "Newton", "Smith", "Brown", "Davidson", "Robinson", "Schroeder", "Keil", "Mortenson", "Anderson", "Blackstad", "Williams", "Holte", "Wales", "Hrdlicka", "Cook"]
		hatlist = ["Beanie", "Coonskin Hat", "Top Hat", "Sombrero", "Trucker Hat"]
		for i in range(0, len(fnlist)):
			for j in range(0, len(lnlist)):
				db.session.add(Guest(fnlist[i], lnlist[j], lnlist[j][:4].lower() + fnlist[i][:2].lower() + "*****@*****.**", "563" + "-" + str(495-i*7) + "-" + str(9321 - j*17),  str(i*100 + j * 10 + j%10) + " College Drive, Decorah IA", payment=(i * 10 + j), notes="Wears a " + hatlist[i%len(hatlist)]))
		#still need to add reservations

		db.session.commit()

		from RoomReserve.admin.rooms import getRoomByID

		myiter = 0
		for i in range(1, len(fnlist)*len(lnlist)):
			#change the month below to 5 for when we present
			myiter += 1
			while getRoomByID(myiter).status == CONST.inactive_status:
				myiter += 1

			x = int(i%20+1)
			mydate = date(2016, 5, x)
			mydate2 = mydate + timedelta(days=(randint(1, 30)))
			if datetime.today().date() < mydate:
				mystatus = CONST.ready_status
			else:
				if datetime.today().date() < mydate2:
					mystatus = CONST.checkedin_status
					getRoomByID(myiter).set_status(CONST.occupied_status)
				else:
					mystatus = CONST.checkedout_status
					getRoomByID(myiter).set_status(CONST.unclean_status)
			db.session.add(Reservation(i , 1, myiter, mydate, mydate2, mystatus, "Beds need lofting."))

		db.session.commit()
		return redirect(url_for("page_rooms"))
	except:
		print("Hit the except statement")
		return render("basic.html", content=str(traceback.format_exc()).replace('\n', '<br>'))