def validate_patch_monitoring_data(request):
    """
    Validate monitoring data PATCH
    """
    data = validate_data(request, Monitoring, partial=True)
    _validate_patch_monitoring_fields(request)
    _validate_patch_monitoring_status(request)
    return data
def validate_post_data(request):
    """
    Validate post data POST
    """
    update_logging_context(request, {'POST_ID': '__new__'})
    data = validate_data(request, Post)
    _validate_post_post_status(request)
    return data
def validate_elimination_report_data(request):
    """
    Validate elimination report data POST
    """
    if request.validated["monitoring"].eliminationReport is not None:
        raise_operation_error(request,
                              "Can't post another elimination report.")
    _validate_elimination_report_status(request)
    return validate_data(request, EliminationReport)
示例#4
0
def validate_liability_data(request):
    """
    Validate liability report data POST
    """

    _validate_monitoring_statuses(
        request,
        "Liability",
        (ADDRESSED_STATUS, ),
    )
    return validate_data(request, Liability)
示例#5
0
def validate_appeal_data(request):
    """
    Validate appeal report data POST
    """
    monitoring = request.validated['monitoring']
    _validate_monitoring_statuses(request, "Appeal",
                                  (ADDRESSED_STATUS, DECLINED_STATUS))

    if monitoring.appeal is not None:
        raise_operation_error(request, "Can't post another appeal.")

    return validate_data(request, Appeal)
def validate_appeal_data(request):
    """
    Validate appeal report data POST
    """
    monitoring = request.validated['monitoring']
    if monitoring.appeal is not None:
        raise_operation_error(request, "Can't post another appeal.")

    if monitoring.conclusion is None or monitoring.conclusion.datePublished is None:
        request.errors.status = 422
        request.errors.add('body', 'appeal',
                           'Can\'t post before conclusion is published.')
        raise error_handler(request.errors)

    return validate_data(request, Appeal)
示例#7
0
def validate_patch_liability_data(request):
    """
    Validate liability report data PATCH
    """

    _validate_monitoring_statuses(
        request,
        "Liability proceeding",
        (ADDRESSED_STATUS, COMPLETED_STATUS),
    )

    if request.context.proceeding:
        raise_operation_error(request, "Can't post another proceeding.")

    return validate_data(request, Liability, partial=True)
def validate_monitoring_data(request):
    """
    Validate monitoring data POST
    """
    update_logging_context(request, {'MONITOR_ID': '__new__'})
    data = validate_data(request, Monitoring)

    monitoring = request.validated['monitoring']
    if monitoring.status != DRAFT_STATUS:
        request.errors.add(
            'body', 'status',
            "Can't create a monitoring in '{}' status.".format(
                monitoring.status))
        request.errors.status = 422
        raise error_handler(request.errors)
    return data
示例#9
0
def validate_patch_appeal_data(request):
    """
    Validate appeal report data PATCH
    """
    monitoring = request.validated['monitoring']
    if monitoring.appeal is None:
        raise_operation_error(request, "Appeal not found", status=404)

    _validate_monitoring_statuses(
        request,
        "Appeal proceeding",
        (ADDRESSED_STATUS, DECLINED_STATUS, COMPLETED_STATUS, CLOSED_STATUS,
         STOPPED_STATUS),
    )

    if request.context.proceeding is not None:
        raise_operation_error(request, "Can't post another proceeding.")

    return validate_data(request, Appeal, partial=True)
def validate_patch_party_data(request):
    """
    Validate party data PATCH
    """
    data = validate_data(request, Party, partial=True)
    return data
def validate_party_data(request):
    """
    Validate party data POST
    """
    update_logging_context(request, {'PARTY_ID': '__new__'})
    return validate_data(request, Party)
示例#12
0
def validate_request_data(request):
    update_logging_context(request, {"REQUEST_ID": "__new__"})
    return validate_data(request, Request)
示例#13
0
def validate_patch_request_data(request):
    return validate_data(request, Request, partial=True)