Esempio n. 1
0
def refresh_manage():
	cur_user = current_user()
	waitlist = []
	if cur_user:
	# Create a list of guests (as dicts) within the user's library
		for checkin in cur_user.get_checkedin_guests(): 
			guest = Guest.get_by_id(checkin.guest_key.id())
			checkedinGuest = {}
			checkedinGuest["guest_ID"] = checkin.guest_key.id()
			checkedinGuest["checkin_ID"] = checkin.key.id()
			checkedinGuest["firstName"] = guest.first_name
			checkedinGuest["lastName"] = guest.last_name
			if guest.sms_number:
				checkedinGuest["sms"] = functions.stylizePhoneNumber(guest.sms_number)
			checkedinGuest["email"] = guest.email
			checkedinGuest["partySize"] = checkin.party_size
			arrival_time = checkin.signin_time - timedelta(hours=6)
			checkedinGuest["arrival_time"] = arrival_time.strftime('%I:%M %p')
			checkedinGuest["wait_estimate"] = checkin.wait_estimate
			target_time = arrival_time + timedelta(minutes=checkin.wait_estimate)
			checkedinGuest["target_time"] = target_time.strftime('%I:%M %p')
			waitlist.append(checkedinGuest)
		# Sort guestlist by arrival time (oldest on top)
		waitlist.sort(key=lambda guest: guest["arrival_time"])
		jsondump = json.dumps(waitlist)
		return jsondump
	return "User Not Logged In"
Esempio n. 2
0
def manage():
	tour = request.args.get('tour')
	cur_user = current_user()
	guestlist = []
	if cur_user:
		
		# Get message template
		msgTemplate = MessageTemplate.query(MessageTemplate.restaurant_key==cur_user.key,MessageTemplate.message_type==1,MessageTemplate.is_active==True).get()
		if not msgTemplate:
			# No template exists, create one
			msgTemplate = MessageTemplate(restaurant_key=cur_user.key,message_type=1,is_active=True,message_text="{firstName}, your table is almost ready. Need more time? Reply ""bump"" and the # of minutes you'd like.")
			msgTemplate.put()
		
		# Create a list of guests (as dicts) within the user's library
		for checkin in cur_user.get_checkedin_guests(): 
			guest = Guest.get_by_id(checkin.guest_key.id())
			checkedinGuest = {}
			checkedinGuest["guest_ID"] = checkin.guest_key.id()
			checkedinGuest["checkin_ID"] = checkin.key.id()
			checkedinGuest["firstName"] = guest.first_name
			checkedinGuest["lastName"] = guest.last_name
			if guest.sms_number:
				checkedinGuest["sms"] = functions.stylizePhoneNumber(guest.sms_number)
			checkedinGuest["email"] = guest.email
			checkedinGuest["partySize"] = checkin.party_size
			arrival_time = checkin.signin_time - timedelta(hours=6)
			checkedinGuest["arrival_time"] = arrival_time
			checkedinGuest["wait_estimate"] = checkin.wait_estimate
			checkedinGuest["target_time"] = arrival_time + timedelta(minutes=checkin.wait_estimate)
			guestlist.append(checkedinGuest)
	# Sort guestlist by arrival time (oldest on top)
	guestlist.sort(key=lambda guest: guest["arrival_time"])
	return render_response("manage.html", guestlist=guestlist, cur_user=cur_user, tour=tour, default_message=msgTemplate.message_text)
Esempio n. 3
0
def advertise():
	demo = request.args.get('demo')
	if not demo:
		demo = False
	elif demo.lower() == "true":
		demo = True
	else:
		demo = False
	cur_user = current_user()
	# Create a list of guests (as dicts) within the user's library
	optInList = []
	for guest in cur_user.get_optins():
		if guest.sms_number or guest.email:
			optin = {}
			optin["guest_ID"] = guest.key.id()
			if guest.first_name and guest.last_name:
				optin["name"] = guest.first_name + ' ' + guest.last_name
			elif guest.first_name:
				optin["name"] = guest.first_name
			if guest.preferred_contact == 'sms':
				optin["smsNumber"] = functions.stylizePhoneNumber(guest.sms_number)
			elif guest.preferred_contact == 'email':
				optin["email"] = guest.email
			if guest.subscribe_date:
				optin["subscribe_date"] = guest.subscribe_date.strftime('%m/%d/%y')
			else:
				optin["subscribe_date"] = "Unknown"
			if guest.signup_method:
				if guest.signup_method == 1:
					optin["signup_method"] = 'Waitlist'
				elif guest.signup_method == 2:
					optin["signup_method"] = 'SMS'
				elif guest.signup_method == 3:
					optin["signup_method"] = "Website"
			else:
				optin["signup_method"] = 'Waitlist'
			optin["promos_sent"] = Message.query(Message.restaurant_key==cur_user.key,Message.recipient_key==guest.key).count() # TODO: Don't count table notifications (it's going to be nasty to fix that!)
			optInList.append(optin)
	optInList.sort(key=lambda optin: optin["subscribe_date"])
	
	# Create list of MessageTemplates
	msgTemplates = []
	for msgTemplate in MessageTemplate.query(MessageTemplate.restaurant_key==cur_user.key,MessageTemplate.message_type==2,MessageTemplate.is_active==True).fetch():
		if msgTemplate.message_name: # If it doesn't have a name, we can't show it
			msg = {}
			msg["msgID"] = msgTemplate.key.id()
			msg["msgName"] = msgTemplate.message_name
			msg["msgText"] = msgTemplate.message_text
			msgTemplates.append(msg)
	msgTemplates.sort(key=lambda msg: msg["msgName"])
	return render_response("advertise.html", optInList=optInList, msgTemplates=msgTemplates, demo=demo)