def process_sms(self): self.from_phone_number = self.from_phone_number[2:] self.to_phone_number = self.to_phone_number[2:] db_session = DB_Session_Factory.get_db_session() interviewer = Interviewer.get_interviewer_by_phone_number(self.from_phone_number) interview = None response_msg = "Thanks for your feedback" if interviewer is None: response_msg = "I don't know who you are or what you want from me." else: interview = interviewer.get_most_recently_completed_interview(self.to_phone_number, for_update = True) if interview is None: response_msg = "You haven't done an interview recently so we have nothing to talk about." if interview is not None and interview.technical_score is None and not interview.is_coffee_break(): # The user should be trying to send in the technical score. score = Handle_Score_SMS_HTTP_Response_Builder.parse_score(self.sms_body) if score is None: response_msg = "Invalid technical score. Valid input is 1, 2, 3, 4 or '-' if you don't have a score to give. You can use +/- for scores. Please try again." else: interview.technical_score = score response_msg = "What's the cultural score?" elif interview is not None and interview.cultural_score is None: # The user should be trying to send in the cultural score. score = Handle_Score_SMS_HTTP_Response_Builder.parse_score(self.sms_body) if score is None: response_msg = "Invalid cultural score. Valid input is 1, 2, 3, 4 or '-' if you don't have a score to give. You can use +/- for scores. Please try again." else: interview.cultural_score = score response_msg = "Would you recommend hiring this person?" elif interview is not None and interview.hire == -1: # The user should be trying to send in the hiring recommendation hiring_recommendation = Handle_Score_SMS_HTTP_Response_Builder.parse_hiring_recommendation(self.sms_body) if hiring_recommendation is None: response_msg = "Invalid hiring recommendation. Valid input is yes, no or '-' if you don't have a recommendation to give." else: interview.hire = hiring_recommendation response_msg = "Thanks. Feel free to send in any notes you have about " + interview.candidate_name + " in subsequent texts." elif interview is not None: # The user should be trying to send in notes for the interview. if interview.notes is None: interview.notes = "" interview.notes = interview.notes + self.sms_body if interview.notes_ts is None or datetime.now() - interview.notes_ts >= timedelta(seconds=3): response_msg = "Thanks. Your feedback was added to " + interview.candidate_name + "'s file." else: response_msg = None db_session.commit() return response_msg
def process_sms(self): opt_in_data = Handle_Opt_In_SMS_HTTP_Response_Builder.parse_opt_in(self.sms_body) response_msg = None if opt_in_data is None: response_msg = "Your message is formatted incorrectly. The format is: <name>:<box_email>" else: self.from_phone_number = self.from_phone_number[2:] db_session = DB_Session_Factory.get_db_session() opt_in = Interviewer.get_interviewer_by_phone_number(self.from_phone_number) if opt_in is None: opt_in = Interviewer(opt_in_data['email'], opt_in_data['name'], self.from_phone_number) db_session.add(opt_in) response_msg = "Thank you for registering your information with Onsite Inflight." else: opt_in.email = opt_in_data['email'] opt_in.name = opt_in_data['name'] response_msg = "I've updated your information as you requested. Thanks." db_session.commit() return response_msg