Exemple #1
0
def guest_signin():
	cur_user = current_user()
	tour = request.args.get('tour')
	if cur_user:
		if request.method == 'POST':
			firstName = request.form["firstName"]
			try:
				lastName = request.form["lastName"]
			except:
				lastName = None
			preferredContact = request.form["preferredContact"]
			if preferredContact == 'sms':
				smsNumber = functions.digitizePhoneNumber(request.form["smsNumber"])
				email = None
			elif preferredContact == 'email':
				email = request.form["email"]
				smsNumber = None
			try:
				if request.form["optIn"] == 'on':
					optIn = True
				else:
					optIn = False
			except:
				optIn = False
			# Add guest to database
			guest = Guest.add_guest(firstName=firstName,lastName=lastName,preferredContact=preferredContact,smsNumber=smsNumber,email=email,optIn=optIn,signup_method=1,user=cur_user)
			if not guest:
				return "Error"
			checkin = CheckIn.check_in_guest(guest)
			if not checkin:
				return "Error"
			if tour == "continue":
				return redirect(url_for("manage") + '?tour=continue')
			return "Success"
	return render_response("guest-signin.html", tour=tour)
Exemple #2
0
def update_party_size(checkin_ID):
	cur_user = current_user()
	if not cur_user:
		logging.info("there is not a user logged in")
		return "Error"
	else:
		checkin = CheckIn.get_by_id(int(checkin_ID))
		checkin.party_size = int(request.form["party-size"])
		checkin.put()
	return "Success"
Exemple #3
0
def undo_checkin_guest(checkin_ID):
	cur_user = current_user()
	if not cur_user:
		logging.info("there is not a user logged in")
		return "Error"
	else:
		# Place CheckIn back in queue 
		checkin = CheckIn.get_by_id(int(checkin_ID))
		checkin.in_queue = True
		checkin.put()
	return "Success"
Exemple #4
0
def update_wait_estimate(checkin_ID):
	cur_user = current_user()
	if not cur_user:
		logging.info("there is not a user logged in")
		return "Error"
	else:
		checkin = CheckIn.get_by_id(int(checkin_ID))
		checkin.wait_estimate = int(request.form["wait-estimate"])
		target_seating_time = checkin.signin_time - timedelta(hours=6) + timedelta(minutes=checkin.wait_estimate)
		checkin.put()
	return jsonify({"target": target_seating_time.strftime('%I:%M %p')})
Exemple #5
0
def checkin_guest(checkin_ID):
	cur_user = current_user()
	if not cur_user:
		logging.info("there is not a user logged in")
		return "Error"
	else:
		checkin = CheckIn.get_by_id(int(checkin_ID))
		# Find checkin object and check in
		checkin.in_queue = False
		checkin.seat_time = datetime.datetime.now()
		wait_time_timedelta = checkin.seat_time - checkin.signin_time
		calculated_wait_time = float(wait_time_timedelta.seconds) / float(60)
		checkin.wait_time = calculated_wait_time
		checkin.put()
	return "Success"
Exemple #6
0
def logout():
	# Clear out guests and checkins if demo account
	cur_user = current_user()
	if cur_user.is_demo:
		# Delete guest objects, checkin objects, and user object
		guests = Guest.query(Guest.restaurant_key==cur_user.key).fetch()
		for guest in guests:
			checkins = CheckIn.query(CheckIn.guest_key==guest.key).fetch()
			for checkin in checkins:
				checkin.key.delete()
			guest.key.delete()
		for msg in Message.query(Message.restaurant_key==cur_user.key).fetch():
			msg.key.delete()
		for msgTemplate in MessageTemplate.query(MessageTemplate.restaurant_key==cur_user.key).fetch():
			msgTemplate.key.delete()
		cur_user.key.delete()
	# Logs out User
	logout_account()
	return redirect(users.create_logout_url("/"))
Exemple #7
0
def quick_add():
	cur_user = current_user()
	if not cur_user:
		logging.info("there is not a user logged in")
		return "Error"
	else:
		# Create/Update Guest and Create New Checkin, adding to queue
		firstName = request.form["quickAddName"]
		try:
			# Not used anymore, but if neither SMS or Email is checked, this gives error
			preferredContact = request.form["preferredContact"]
		except:
			preferredContact = None
		# Check to see if a phone number or email was given
		quickAddContact = request.form["quickAddContact"]
		if quickAddContact == '':
			preferredContact = None # This causes email and smsNumber to be set to None later (even though it's passing an empty string)
		partySize = int(request.form["quickAddPartySize"])
		waitEstimate = int(request.form["quickAddWaitEstimate"])
		if preferredContact == 'sms':
			smsNumber = functions.digitizePhoneNumber(request.form["quickAddContact"])
			email = None
		elif preferredContact == 'email':
			email = request.form["quickAddContact"]
			smsNumber = None
		else:
			# email or smsNumber could be empty string, but set to none
			email = None
			smsNumber = None
		try:
			if request.form["quickAddOptIn"] == 'on':
				optIn = True
			else:
				optIn = False
		except:
			optIn = False
		guest = Guest.add_guest(firstName=firstName,lastName=None,preferredContact=preferredContact,smsNumber=smsNumber,email=email,optIn=optIn,signup_method=1,user=cur_user)
		if not guest:
			return "Error"
		checkin = CheckIn.check_in_guest(guest,partySize,waitEstimate)
		if not checkin:
			return "Error"
	return "Success"
Exemple #8
0
	def get_checkedin_guests(self):
		from src.checkins.models import CheckIn
		return CheckIn.query(CheckIn.restaurant_key==self.key,CheckIn.in_queue==True).fetch()