From cda72d11b4c7c4cb9bc8a146b5f3a15850c07b89 Mon Sep 17 00:00:00 2001 From: koalasat Date: Sat, 21 Jun 2025 18:09:09 +0200 Subject: [PATCH] Working version --- api/oas_schemas.py | 4 +-- api/serializers.py | 5 ++++ api/views.py | 2 +- docs/assets/schemas/api-latest.yaml | 5 +++- frontend/src/basic/OrderPage/index.tsx | 4 +-- .../src/components/OrderDetails/index.tsx | 13 +++++----- frontend/src/models/Order.model.ts | 1 + tests/test_trade_pipeline.py | 25 +++++++------------ 8 files changed, 30 insertions(+), 29 deletions(-) diff --git a/api/oas_schemas.py b/api/oas_schemas.py index 19af089d..83bbd864 100644 --- a/api/oas_schemas.py +++ b/api/oas_schemas.py @@ -168,7 +168,7 @@ class OrderViewSchema: "examples": [ OpenApiExample( "Order cancelled", - value={"bad_request": "This order has been cancelled by the maker"}, + value={"bad_request": "This order has been cancelled"}, status_codes=[400], ), OpenApiExample( @@ -178,7 +178,7 @@ class OrderViewSchema: ), OpenApiExample( "Order cancelled", - value={"bad_request": "This order has been cancelled collaborativelly"}, + value={"bad_request": "This order has been cancelled"}, status_codes=[400], ), OpenApiExample( diff --git a/api/serializers.py b/api/serializers.py index 4fd41017..fd81e737 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -207,6 +207,10 @@ class OrderDetailSerializer(serializers.ModelSerializer): required=False, help_text="True if you are either a taker or maker, False otherwise", ) + has_password = serializers.BooleanField( + required=False, + help_text="True if the order is password protected", + ) maker_status = serializers.CharField( required=False, help_text="Status of the maker:\n" @@ -438,6 +442,7 @@ class OrderDetailSerializer(serializers.ModelSerializer): "is_maker", "is_taker", "is_participant", + "has_password", "maker_status", "taker_status", "price_now", diff --git a/api/views.py b/api/views.py index 21de4a4d..79a98020 100644 --- a/api/views.py +++ b/api/views.py @@ -258,7 +258,7 @@ class OrderView(viewsets.ViewSet): data["penalty"] = request.user.robot.penalty_expiration # 2.1) If order has a password - if not data["is_participant"] and order.password is not None: + if not data["is_participant"] and data["has_password"]: return Response(data, status.HTTP_200_OK) # 3.a) If not a participant and order is not public, forbid. diff --git a/docs/assets/schemas/api-latest.yaml b/docs/assets/schemas/api-latest.yaml index 18851a4f..d37b90f8 100644 --- a/docs/assets/schemas/api-latest.yaml +++ b/docs/assets/schemas/api-latest.yaml @@ -405,7 +405,7 @@ paths: examples: OrderCancelled: value: - bad_request: This order has been cancelled collaborativelly + bad_request: This order has been cancelled summary: Order cancelled WhenTheOrderIsNotPublicAndYouNeitherTheTakerNorMaker: value: @@ -1444,6 +1444,9 @@ components: is_participant: type: boolean description: True if you are either a taker or maker, False otherwise + has_password: + type: boolean + description: True if the order is password protected maker_status: type: string description: |- diff --git a/frontend/src/basic/OrderPage/index.tsx b/frontend/src/basic/OrderPage/index.tsx index 6c58bb28..b727dba0 100644 --- a/frontend/src/basic/OrderPage/index.tsx +++ b/frontend/src/basic/OrderPage/index.tsx @@ -119,7 +119,7 @@ const OrderPage = (): React.JSX.Element => { }); }} /> - {!currentOrder?.maker_hash_id && !currentOrder?.bad_request && } + {!currentOrder?.maker && !currentOrder?.bad_request && } {currentOrder?.bad_request && currentOrder.status !== 5 ? ( <> @@ -141,7 +141,7 @@ const OrderPage = (): React.JSX.Element => { )} ) : null} - {currentOrder?.maker_hash_id && (!currentOrder.bad_request || currentOrder.status === 5) ? ( + {currentOrder?.maker && (!currentOrder.bad_request || currentOrder.status === 5) ? ( currentOrder.is_participant ? ( windowSize.width > doublePageWidth ? ( // DOUBLE PAPER VIEW diff --git a/frontend/src/components/OrderDetails/index.tsx b/frontend/src/components/OrderDetails/index.tsx index f858556b..6d9eebe8 100644 --- a/frontend/src/components/OrderDetails/index.tsx +++ b/frontend/src/components/OrderDetails/index.tsx @@ -301,9 +301,9 @@ const OrderDetails = ({ )} - - {!currentOrder.bad_request && ( + {!currentOrder.bad_request && currentOrder.maker_hash_id && ( <> + - @@ -539,7 +538,7 @@ const OrderDetails = ({ {/* If the user has a penalty/limit */} {currentOrder?.penalty !== undefined ? ( - + )} - {currentOrder.bad_request?.includes('password') && ( - + {!currentOrder?.is_participant && currentOrder?.has_password && ( + )} - {!currentOrder?.is_participant || currentOrder.bad_request?.includes('password') ? ( + {!currentOrder?.is_participant ? (