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)
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"
def optin_guest(user_ID,signup_method): user = UserAccount.get_by_id(int(user_ID)) # Opt in the guest (this will add them if they don't exist, and update and optin if they already do) guest = Guest.add_guest(firstName=request.form["firstName"], lastName=None, smsNumber=functions.digitizePhoneNumber(request.form["smsNumber"]), email=request.form["email"], preferredContact=request.form["preferredContact"], optIn=True, signup_method=int(signup_method), user=user) if guest: return "Success" else: return "Error"