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.phone_number = self.phone_number[2:] db_session = DB_Session_Factory.get_db_session() opt_in = db_session.query(Opt_In).get(self.phone_number) if opt_in is None: opt_in = Opt_In(opt_in_data["email"], opt_in_data["name"], self.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
def print_body(self): opt_ins = [] for opt_in in Opt_In.get_opt_ins_after_date(self.date): opt_ins.append(opt_in.dict_representation()) print json.dumps(opt_ins)