Esempio n. 1
0
def archive_correction(queue_name: str,
                       correction_id: str,
                       version: int,
                       username: str,
                       moderator_comment: str = '',
                       corrected_val: str = None,
                       approved: bool = False):
    archive_repository = ArchiveRepository(
        app.config['DYNAMODB_ENDPOINT_URL'], app.config['REGION'],
        app.config['DYNAMODB_TABLE_ARCHIVE'])

    try:
        correction = read_correction(queue_name, correction_id, version)
        if not correction:
            return not_found(correction_id)

        entry = dict(
            **correction, **{
                'modifiedBy': username,
                'moderatorComment': moderator_comment,
                'correctedVal': corrected_val,
                'approved': approved
            })
        archive_repository.write(ArchiveItem.deserialize(entry))
        delete_correction(queue_name, correction_id, version)
    except ClientError as e:
        return jsonify(
            create_response_message(False, e.response['Error']['Message']))

    return jsonify(create_response_message(True, 'Success'))
Esempio n. 2
0
def archive_correction(
    queue_name: str,
    correction_id: str,
    version: int,
    username: str,
    corrected_val: str = None,
    approved: bool = False,
):
    archive_repository = ArchiveRepository(
        app.config["DYNAMODB_ENDPOINT_URL"],
        app.config["REGION"],
        app.config["DYNAMODB_TABLE_ARCHIVE"],
    )

    try:
        correction = read_correction(queue_name, correction_id, version)
        if not correction:
            return not_found(correction_id)

        entry = dict(
            **correction,
            **{
                "modifiedBy": username,
                "correctedVal": corrected_val,
                "approved": approved,
            },
        )
        archive_repository.write(ArchiveItem.deserialize(entry))
        delete_correction(queue_name, correction_id, version)
    except ClientError as e:
        return jsonify(create_response_message(False, e.response["Error"]["Message"]))

    return jsonify(create_response_message(True, "Success"))
 def setUp(self):
     self.repository = ArchiveRepository("http://dynamodb-local:8000/",
                                         "us-west-2",
                                         "HadithCorrectionsArchive")