Ejemplo n.º 1
0
def create_details_report(json_details_report):
    """Create details report.

    Fact collection consists of a DetailsReport record
    :param json_details_report: dict representing a details report
    :returns: The newly created DetailsReport
    """
    # Create new details report
    serializer = DetailsReportSerializer(data=json_details_report)
    if serializer.is_valid():
        details_report = serializer.save()
        logger.debug('Fact collection created: %s', details_report)
        return details_report

    logger.error('Fact collection could not be persisted.')
    logger.error('Invalid json_details_report: %s', json_details_report)
    logger.error('DetailsReport errors: %s', serializer.errors)

    return None
Ejemplo n.º 2
0
def create_details_report(report_version, json_details_report):
    """Create details report.

    Fact collection consists of a DetailsReport record
    :param report_version: major.minor.patch version of report.
    :param json_details_report: dict representing a details report
    :returns: The newly created DetailsReport
    """
    # Create new details report
    serializer = DetailsReportSerializer(data=json_details_report)
    if serializer.is_valid():
        details_report = serializer.save()
        # removed by serializer since it is read-only.  Set again.
        details_report.report_version = report_version
        details_report.save()
        logger.debug('Fact collection created: %s', details_report)
        return details_report

    logger.error('Details report could not be persisted.')
    logger.error('Invalid json_details_report: %s', json_details_report)
    logger.error('DetailsReport errors: %s', serializer.errors)

    return None