Example #1
0
def get_object_annotation_classes(request: HttpRequest) -> HttpResponse:
    if request.method != 'GET':
        return response.not_supported()

    response_data = object_annotation_get_service.get_object_annotation_classes(
    )

    return response.success(response_data)
Example #2
0
def get_all_annotations(request, photo_id=None) -> HttpResponse:
    if request.method != 'GET':
        return response.not_supported()

    all_rectangles = object_annotation_get_service.get_all_annotations(
        request.user.id, photo_id)

    return response.success(all_rectangles)
Example #3
0
def add_feedback(request, annotation_id):
    if request.method == 'POST':
        add_object_detection_feedback = AddObjectDetectionFeedback(
            QueryDict(request.body), request.user.id, annotation_id)

        object_annotation_feedback_service.add_feedback(
            add_object_detection_feedback)

        return response.success()
    elif request.method == 'DELETE':
        remove_object_annotation_feedback = RemoveObjectAnnotationFeedback(
            annotation_id, request.user.id)
        object_annotation_feedback_service.remove_feedback(
            remove_object_annotation_feedback)

        return response.success()

    return response.not_supported()
Example #4
0
def update_annotation(request: HttpRequest) -> HttpResponse:
    if request.method != 'PUT':
        return response.not_supported()

    object_annotation_update_request = ObjectAnnotationUpdateRequest(
        QueryDict(request.body))

    object_annotation_modify_service.update_object_annotation(
        request.user.id, object_annotation_update_request)

    return response.success()
Example #5
0
def add_annotation(request: HttpRequest) -> HttpResponse:
    if request.method != 'POST':
        return response.not_supported()

    add_detection_annotation = AddDetectionAnnotation(QueryDict(request.body),
                                                      request.user.id)

    object_annotation_add_service.add_annotation(add_detection_annotation,
                                                 request)

    return response.success()
Example #6
0
def remove_annotation(request: HttpRequest,
                      annotation_id: int) -> HttpResponse:
    if request.method != 'DELETE':
        return response.not_supported()

    face_annotation_remove_request = FaceAnnotationRemoveRequest(
        annotation_id, request.user.id)
    has_removed_successfully = face_annotation_delete_service.remove_annotation(
        face_annotation_remove_request)

    if has_removed_successfully:
        return response.success()

    return response.action_failed()
Example #7
0
def update_annotation(request: HttpRequest, annotation_id: int):
    if request.method != 'PUT':
        return response.not_supported()

    face_annotation_update_request = FaceAnnotationUpdateRequest(
        QueryDict(request.body), annotation_id, request.user.id)

    is_successful = face_annotation_edit_service.update_face_annotation(
        face_annotation_update_request, request)

    if is_successful:
        return response.success()

    return response.action_failed()