def message():
        subscriber = Subscriber.query.filter(Subscriber.phone_number == request.form['From']).first()
        if subscriber is None:
            subscriber = Subscriber(phone_number=request.form['From'])
            db.session.add(subscriber)
            db.session.commit()
            output = "Thanks for contacting TWBC! Text 'subscribe' if you would like to receive updates via text message."
        else:
            output = _process_message(request.form['Body'], subscriber)
            db.session.commit()

        twilio_services = TwilioServices()
        return twiml(twilio_services.respond_message(output))
예제 #2
0
    def message():
        subscriber = Subscriber.query.filter(
            Subscriber.phone_number == request.form['From']).first()
        if subscriber is None:
            subscriber = Subscriber(phone_number=request.form['From'])
            db.session.add(subscriber)
            db.session.commit()
            output = "Thanks for contacting TWBC! Text 'add' if you would like to receive updates via text message."
        else:
            output = _process_message(request.form['Body'], subscriber)
            db.session.commit()

        twilio_services = TwilioServices()
        return twiml(twilio_services.respond_message(output))
예제 #3
0
    def message():
        subscriber = Subscriber.query.filter(
            Subscriber.phone_number == request.form['From']).first()
        if subscriber is None:
            subscriber = Subscriber(phone_number=request.form['From'])
            db.session.add(subscriber)
            db.session.commit()
            output = "Thanks for contacting the UCI parent text message study. Text " \
                     "\"subscribe\" if you would like to receive updates via text message in English. " \
                     "Gracias por contactar el estudio conducido por UCI, el mensaje de texto para los padres. " \
                     "Responde con un mensaje de texto con la palabra " \
                     "\"inscribe\" si gustarían recibir notificaciones por mensaje de texto en Español."

        elif not subscriber.subscribed:
            output = _process_message(request.form['Body'], subscriber)
            db.session.commit()

        elif subscriber.zipcode is None and subscriber.spanish:
            output = _process_zip_spanish(request.form['Body'], subscriber)
            db.session.commit()

        elif subscriber.zipcode is None and not subscriber.spanish:
            output = _process_zip(request.form['Body'], subscriber)
            db.session.commit()

        elif subscriber.age is None and subscriber.spanish:
            output = _process_age_spanish(request.form['Body'], subscriber)
            db.session.commit()

        elif subscriber.age is None and not subscriber.spanish:
            output = _process_age(request.form['Body'], subscriber)
            db.session.commit()

        elif subscriber.interests is None and subscriber.spanish:
            output = _process_interests_spanish(request.form['Body'],
                                                subscriber)
            db.session.commit()

        elif subscriber.interests is None and not subscriber.spanish:
            output = _process_interests(request.form['Body'], subscriber)
            db.session.commit()

        else:  # trying to fix the unbound local error message that happens after trying to unsubscribe after signup,
            # this fixes it
            output = _process_message(request.form['Body'], subscriber)
            db.session.commit()

        twilio_services = TwilioServices()
        return twiml(twilio_services.respond_message(output))