Example #1
0
    def get_deed(deed_reference):
        conveyancer_credentials = process_organisation_credentials()
        organisation_id = conveyancer_credentials["O"][1]

        if organisation_id != '*':
            LOGGER.debug("Internal request to view deed reference %s" % deed_reference)
            result = Deed.query.filter_by(token=str(deed_reference), organisation_id=organisation_id).first()
        else:
            result = Deed.query.filter_by(token=str(deed_reference)).first()

        return result
Example #2
0
    def get_signed_deeds():
        conveyancer_credentials = process_organisation_credentials()
        organisation_name = conveyancer_credentials[os.getenv(
            'DEED_CONVEYANCER_KEY')][0]

        result = Deed.query.filter_by(
            organisation_name=organisation_name,
            status=DeedStatus.all_signed.value).all()

        all_signed_deeds = list(map(lambda deed: deed.token, result))

        return all_signed_deeds
Example #3
0
    def get_deed(deed_reference):
        conveyancer_credentials = process_organisation_credentials()
        organisation_id = conveyancer_credentials["O"][1]

        if organisation_id != '*':
            LOGGER.debug("Internal request to view deed reference %s" %
                         deed_reference)
            result = Deed.query.filter_by(
                token=str(deed_reference),
                organisation_id=organisation_id).first()
        else:
            result = Deed.query.filter_by(token=str(deed_reference)).first()

        return result
Example #4
0
    def get_deed(self, deed_reference):
        conveyancer_credentials = process_organisation_credentials()
        organisation_name = conveyancer_credentials[os.getenv(
            'DEED_CONVEYANCER_KEY')][0]

        if organisation_name != os.getenv('LR_ORGANISATION_NAME'):
            application.app.logger.debug(
                "Internal request to view deed reference %s" % deed_reference)
            result = Deed.query.filter_by(
                token=str(deed_reference),
                organisation_name=organisation_name).first()
        else:
            result = Deed.query.filter_by(token=str(deed_reference)).first()

        return result
Example #5
0
def create():
    deed_json = request.get_json()
    error_count, error_message = validate_helper(deed_json)

    if error_count > 0:
        LOGGER.error("Schema validation 400_BAD_REQUEST")
        return error_message, status.HTTP_400_BAD_REQUEST
    else:

        try:
            deed = Deed()
            deed.token = Deed.generate_token()
            check_result = Akuma.do_check(deed_json, "create deed")
            LOGGER.info("Check ID: " + check_result['id'])

            organisation_credentials = process_organisation_credentials()

            if organisation_credentials:
                deed.organisation_id = organisation_credentials["O"][1]
                deed.organisation_name = organisation_credentials["O"][0]
                success, msg = update_deed(deed, deed_json,
                                           check_result['result'])

                if not success:
                    LOGGER.error("Update deed 400_BAD_REQUEST")
                    return msg, status.HTTP_400_BAD_REQUEST
            else:
                LOGGER.error("Unable to process headers")
                return "Unable to process headers", status.HTTP_401_UNAUTHORIZED

            if check_result['result'] != "A":
                LOGGER.error("Akuma endpoint 503_SERVICE_UNAVAILABLE")
                return abort(status.HTTP_503_SERVICE_UNAVAILABLE)

            return jsonify({"path": '/deed/' + str(deed.token)
                            }), status.HTTP_201_CREATED

        except:
            msg = str(sys.exc_info())
            LOGGER.error("Database Exception - %s" % msg)
            abort(status.HTTP_500_INTERNAL_SERVER_ERROR)
    def validate_organisation_credentials(self):
        """
        Get the conveyancer's credentials

        :type list: organisation_credentials
        :rtype: dict
        """
        organisation_credentials = process_organisation_credentials()

        if organisation_credentials is not None:
            organisation_credentials = {
                'organisation_name':
                organisation_credentials[os.getenv('DEED_CONVEYANCER_KEY')][0],
                'organisation_locale':
                organisation_credentials[os.getenv('DEED_WEBSEAL_LOCALE')][0]
            }
            return organisation_credentials
        else:
            application.app.logger.error(
                "Unable to process organisation credentials")
            return None
Example #7
0
def create():
    deed_json = request.get_json()
    error_count, error_message = validate_helper(deed_json)

    if error_count > 0:
        LOGGER.error("Schema validation 400_BAD_REQUEST")
        return error_message, status.HTTP_400_BAD_REQUEST
    else:

        try:
            deed = Deed()
            deed.token = Deed.generate_token()
            check_result = Akuma.do_check(deed_json, "create deed")
            LOGGER.info("Check ID: " + check_result['id'])

            organisation_credentials = process_organisation_credentials()

            if organisation_credentials:
                deed.organisation_id = organisation_credentials["O"][1]
                deed.organisation_name = organisation_credentials["O"][0]
                success, msg = update_deed(deed, deed_json, check_result['result'])

                if not success:
                    LOGGER.error("Update deed 400_BAD_REQUEST")
                    return msg, status.HTTP_400_BAD_REQUEST
            else:
                LOGGER.error("Unable to process headers")
                return "Unable to process headers", status.HTTP_401_UNAUTHORIZED

            if check_result['result'] != "A":
                LOGGER.error("Akuma endpoint 503_SERVICE_UNAVAILABLE")
                return abort(status.HTTP_503_SERVICE_UNAVAILABLE)

            return jsonify({"path": '/deed/' + str(deed.token)}), status.HTTP_201_CREATED

        except:
            msg = str(sys.exc_info())
            LOGGER.error("Database Exception - %s" % msg)
            abort(status.HTTP_500_INTERNAL_SERVER_ERROR)