Skip to content

POST api/order/ cancel returns error 400 bad_request when successful #1245

@jerryfletcher21

Description

@jerryfletcher21

Describe the bug
Other POST api/order/ action do not return error when successful, but cancel returns error 400 "bad_request": "This order has been cancelled by the maker". I think this is because when requesting an order that is canceled this is what is returned, but while doing the cancelling action is weird to be returned an error when successful.
Maybe to fix, when requesting an order that is cancelled, it can be returned a json without error, something like "status": "This order has been cancelled by the maker".

in api/views.py:

        # 2) If order has been cancelled
        if order.status == Order.Status.UCA:
            return Response(
                {"bad_request": "This order has been cancelled by the maker"},
                status.HTTP_400_BAD_REQUEST,
            )
        if order.status == Order.Status.CCA:
            return Response(
                {"bad_request": "This order has been cancelled collaborativelly"},
                status.HTTP_400_BAD_REQUEST,
            )

To Reproduce
Make a POST request at api/order/ with the action cancel.

Expected behavior
Not to be returned an error when then cancel is successful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't workinghelp wantedExtra attention is neededpythonPull requests that update Python code

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions