Skip to content

Commit

Permalink
Fix cancel unstable status
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Feb 28, 2025
1 parent da13fee commit e52b038
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions api/logics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,9 @@ def finalize_contract(cls, take_order):
order.maker.robot.save(update_fields=["total_contracts"])
order.taker.robot.save(update_fields=["total_contracts"])

take_order.expires_at = timezone.now()
take_order.save(update_fields=["expires_at"])

# Log a market tick
try:
market_tick = MarketTick.log_a_tick(order)
Expand Down
9 changes: 6 additions & 3 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,12 @@ def get(self, request, format=None):
# Add booleans if user is maker, taker, partipant, buyer or seller
data["is_maker"] = order.maker == request.user
data["is_taker"] = order.taker == request.user
data["is_pretaker"] = TakeOrder.objects.filter(
taker=request.user, order=order, expires_at__gt=timezone.now()
).exists()
data["is_pretaker"] = (
not data["is_taker"]
and TakeOrder.objects.filter(
taker=request.user, order=order, expires_at__gt=timezone.now()
).exists()
)
data["is_participant"] = (
data["is_maker"] or data["is_taker"] or data["is_pretaker"]
)
Expand Down

0 comments on commit e52b038

Please sign in to comment.