Example #1
0
def get_pdf():
    deed_api_client = make_deed_api_client()
    deed_pdf = deed_api_client.get_deed(request.form["deed_id"],
                                        "application/pdf")

    if deed_pdf.status_code == 200:
        return deed_pdf
    else:
        return render_template('404.html')
Example #2
0
def service_check_routes():

    # Attempt to connect to deed-api which will attempt to connect to all
    # other services that are related to it.
    service_list = ""

    service_dict = {
        "status_code": 500,
        "service_from": "borrower frontend",
        "service_to": "deed-api",
        "service_message": "Successfully connected"
    }

    try:
        # Create the interface that allows us to call the deed api's health route
        # and retrieve the response
        deed_interface = make_deed_api_client()
        service_response = deed_interface.check_service_health()

        status_code = service_response.status_code
        service_list = service_response.json()

        # Add the success dict for Borrower Front End to the list of services
        # If there was an exception it would not get to this point
        service_dict["status_code"] = status_code
        service_list["services"].append(service_dict)

    # If a 500 error is reported, it will be far easier to determine the cause by
    # throwing an exception, rather than by getting an "unexpected error" output
    except Exception as e:
        # A RequestException resolves the error that occurs when a connection cant be established
        # and the ValueError/TypeError exception may occur if the dict string / object is malformed
        LOGGER.error('An exception has occurred in the service-check route: %s', (e,), exc_info=True)

        # We either have a differing status code, add an error for this service
        # This would imply that we were not able to connect to deed-api
        service_dict["status_code"] = 500
        service_dict["service_message"] = "Error: Could not connect"

        service_list = {
            "services":
            [
                service_dict
            ]
        }

    # Return the dict object containing the status of each service
    return jsonify(service_list)
def create_manager(deed_api_client=make_deed_api_client()):
    app = Flask(__name__)
    app.config.from_pyfile('config.py')

    manager = Manager(app)
    app.url_map.strict_slashes = False

    setattr(searchdeed, 'deed_api_client', deed_api_client)

    app.register_blueprint(health, url_prefix='/health')
    app.register_blueprint(searchdeed)
    app.register_blueprint(borrower_landing)
    app.secret_key = app.config['APP_SECRET_KEY']

    app.permanent_session_lifetime = timedelta(minutes=20)

    return manager
Example #4
0
def create_manager(deed_api_client=make_deed_api_client()):
    app = Flask(__name__)
    app.config.from_pyfile('config.py')

    manager = Manager(app)
    app.url_map.strict_slashes = False

    setattr(searchdeed, 'deed_api_client', deed_api_client)

    app.register_blueprint(health, url_prefix='/health')
    app.register_blueprint(searchdeed)
    app.register_blueprint(borrower_landing)
    app.secret_key = app.config['APP_SECRET_KEY']

    app.permanent_session_lifetime = timedelta(minutes=20)

    return manager
Example #5
0
def confirm_network_agreement():
    if request.method == "GET":
        return render_template('howtoproceed.html')
    elif request.method == "POST":
        if 'accept-naa' in request.form:
            session['agreement_naa'] = "accepted"
            borrower_id = session['borrower_id']
            interface = make_deed_api_client()
            result = interface.send_naa(borrower_id)
            if result.status_code == 500:
                LOGGER.warning(
                    "error- status code has returned as 500 and the audit has not been created"
                )
                return redirect('/server-error')
            elif result.status_code == 200:
                LOGGER.info(
                    "success- status code has returned as 200 and the audit has been created"
                )
                return redirect('/mortgage-deed', code=302)
        else:
            session['agreement_naa'] = "declined"
            return redirect('/how-to-proceed', code=307)
Example #6
0
def get_conveyancer_for_deed():
    interface = make_deed_api_client()
    return interface.get_conveyancer_for_deed(session['deed_token'])