Пример #1
0
def save_received_realtor_twilio_messages():
    try:
        print "save_received_realtor_twilio_messages"
        request_form_sid = request.form.get(
            'MessageSid')  # Twilio's unique identifier of the message
        request_form_from = request.form.get(
            'From')  # number that sent us the sms
        request_form_to = request.form.get(
            'To')  # Twilio number we used to receive the sms
        request_form_body = request.form.get('Body')  # Content of the sms

        if (request_form_sid
                is not None) and (request_form_from is not None) and (
                    request_form_to is not None) and (request_form_body
                                                      is not None):
            implementations_instance = Implementations()
            implementations_instance.save_realtor_twilio_message(
                request_form_sid, request_form_from, request_form_to,
                request_form_body)
            json_obj = jsonpickle.encode([], unpicklable=False)
            return Response(json_obj)
        else:
            abort(500)
    except Exception as e:
        print "There was an unexpected error: ", str(e)
        print traceback.format_exc()
        abort(500)
def create_calibration_test():
    try:
        implementation_instance = Implementations()
        implementation_instance.load_calibrations_test_data()
        return Response()
    except Exception as e:
        print "There was an unexpected error: ", str(e)
        print traceback.format_exc()
        abort(500)
Пример #3
0
def create_test_listing_owners():
    try:
        ## get calibration value
        test_instance = Implementations()
        test_instance.load_listing_owners_test_data()
        return Response()

    except Exception as e:
        print "There was an unexpected error: " , str(e)
        print traceback.format_exc()
        abort(500)
Пример #4
0
def get_unread_notifications(user_id = None):
    try:
        if user_id is not None:
            ## get calibration value
            implementations_instance = Implementations()
            notifcations_list = implementations_instance.get_unread_notifications(user_id)
            json_obj = jsonpickle.encode(notifcations_list, unpicklable=False)
            return Response(json_obj)
        else:
            abort(500)
    except Exception as e:
        print "There was an unexpected error: ", str(e)
        print traceback.format_exc()
        abort(500)
def save_preferences():
    try:
        # get parameters from form
        fullname = request.form['fullname']
        email = request.form['email']
        phone = request.form['phone']
        budget = int(request.form['budget'])
        bedrooms = int(request.form['bedrooms'])
        city = request.form['city']

        implementation_instance = Implementations()
        implementation_instance.save_preferences(fullname, email, phone,
                                                 budget, bedrooms, city)
        return Response()
    except Exception as e:
        print "There was an unexpected error: ", str(e)
        print traceback.format_exc()
        abort(500)
Пример #6
0
def save_received_user_mandrill_email():

    try:
        mandrill_events = request.form.get('mandrill_events')  #THIS WORKS EH
        mandrill_message = jsonpickle.decode(mandrill_events)[0][
            'msg']  #THIS WORKS EH
        mandrill_message_text = mandrill_message['text']  #THIS WORKS EH
        mandrill_message_from_email = mandrill_message[
            'from_email']  #THIS WORKS EH

        separator_string = "## Please do not write below this line ##"  #THIS WORKS
        conversation_separator_string = "CONVERSATION_ID###"  #THIS WORKS

        mandrill_message_reply_list = mandrill_message_text.split(
            separator_string)  #THIS WORKS
        mandrill_message_reply_text = mandrill_message_reply_list[
            0]  #THIS WORKS
        text_for_conversation = mandrill_message_reply_list[1]  #THIS WORKS
        conversation_split_list = text_for_conversation.split(
            conversation_separator_string)  #THIS WORKS
        conversation_id_string = conversation_split_list[1]  #THIS WORKS

        print mandrill_message_reply_text
        print conversation_id_string

        if (mandrill_message_reply_text
                is not None) and (mandrill_message_from_email
                                  is not None) and (conversation_id_string
                                                    is not None):
            implementations_instance = Implementations()
            implementations_instance.save_received_user_mandrill_email(
                mandrill_message_reply_text, mandrill_message_from_email,
                conversation_id_string)
            return Response()
        else:
            abort(500)
            #return Response()

    except Exception as e:
        print "There was an unexpected error: ", str(e)
        print traceback.format_exc()
        abort(500)
from persistence.mongodatabase import mongoDatabase

# TODO: improve the way this vars are loaded
# load constants
config = ConfigParser.ConfigParser()
config.read("config.cfg")
mongo_section = 'mongo_config'
MONGO_URL = config.get(mongo_section, 'url')
MONGO_DB = config.get(mongo_section, 'db')

# init db connection
myDB = mongoDatabase(MONGO_URL)
db = myDB.getDB(MONGO_DB)

newImplementation = Implementations()

create_user_email_api = Blueprint('create_user_email_api', __name__)


@create_user_email_api.route('/createUserEmail', methods=['POST'])
def send_email_create_user():

    reponseObj = Base()
    # json_object = request.form.keys()
    # json_resquest = json.loads(json_object[0])
    # # json_resquest = request.form

    try:

        # if "phone" in json_resquest.keys():