Skip to content

Commit

Permalink
chore: start sending auction leaving informatino in websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
sandronadiradze committed Nov 5, 2024
1 parent 063a982 commit a50bd97
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 17 deletions.
17 changes: 17 additions & 0 deletions auction/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,7 @@ def post(self, request, auction_id, *args, **kwargs):
"cancelled_auction_count": user_bids_count,
}

self.notify_auction_group(auction, self.request.user.id)
return Response(response_data, status=status.HTTP_200_OK)

except Exception as e:
Expand All @@ -1498,6 +1499,22 @@ def post(self, request, auction_id, *args, **kwargs):
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
)

def notify_auction_group(self, auction, user_id):
channel_layer = get_channel_layer()
data = {
"auction_id": str(auction.id),
"auction_status": "left",
"user_id": str(user_id),
}

async_to_sync(channel_layer.group_send)(
f"auction_{str(auction.id)}",
{
"type": "auction_left_notification",
"message": data,
},
)


@extend_schema(
tags=["Statistics"],
Expand Down
11 changes: 11 additions & 0 deletions bid/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,14 @@ async def auction_cancelled_notification(self, event):
"data": event["message"],
}
)

async def auction_left_notification(self, event):
"""
Handles real-time notifications for cancelled auctions.
"""
await self.send_json(
{
"type": "auction_left_notification",
"data": event["message"],
}
)
34 changes: 17 additions & 17 deletions locale/ka/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-05 06:25+0000\n"
"POT-Creation-Date: 2024-11-05 08:56+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -74,78 +74,78 @@ msgstr "თქვენ არ შეგიძლიათ შეცვალო
msgid "There was an error during the update of the auction. Please try again."
msgstr "აუქციონის შექმნისას პრობლემამ იჩინა თავი. გთხოვთ სცადოთ თავიდან."

#: auction/views.py:614
#: auction/views.py:613
msgid "Auction deleted successfully."
msgstr "აუქციონი წარმატებით წაიშალა."

#: auction/views.py:724
#: auction/views.py:723
#, python-brace-format
msgid "Auction with UUID {id} does not exist."
msgstr "აუქციონი მოცემული იდენტიფიკატორით {id} არ არსებობს."

#: auction/views.py:733
#: auction/views.py:732
#, python-brace-format
msgid ""
"{deleted} auctions deleted and {marked_deleted} auctions marked as deleted."
msgstr ""
"წაიშალა {deleted} აუქციონი და {marked_deleted} აუქციონი მონიშნულია, როგორც "
"წაშლილი."

#: auction/views.py:1104
#: auction/views.py:1103
msgid ""
"Only the bids with a status of either Pending or Approved can be declared as "
"winner bids."
msgstr ""
"მხოლოდ დაეფრუვებული ან მომლოდინე რეჟიმის მქონე ბიდები შეიძლება გამოცხადნენ "
"გამარჯვებულებად."

#: auction/views.py:1120
#: auction/views.py:1119
msgid "You can only declare a winner after the auction has been completed."
msgstr ""
"გამარჯვებულის გამოცხადება მხოლოდ აუქციონის დასრულების შემდეგ შეგიძლიათ."

#: auction/views.py:1165
#: auction/views.py:1164
msgid "Winner of this auction has successfully been declared"
msgstr "აუქციონის გამარჯვებული წარმატებით გამოვლინდა."

#: auction/views.py:1291
#: auction/views.py:1290
msgid "You can not cancel draft auctions."
msgstr "თქვენ არ შეგიძლიათ დრაფტ სტატუსის მქონე აუქციონის გაუქმება."

#: auction/views.py:1292
#: auction/views.py:1291
msgid "This auction is already canceled."
msgstr "ეს აუქციონი უკვე გაუქმებულია."

#: auction/views.py:1293
#: auction/views.py:1292
msgid "You can not cancel deleted auctions."
msgstr "თქვენ არ შეგიძლიათ წაშლილი აუქციონის გაუქმება."

#: auction/views.py:1295
#: auction/views.py:1294
msgid "You can not cancel auctions that have already been completed."
msgstr "თქვენ არ შეგიძლიათ გააუქომთ აუქციონი, რომელიც უკვე დასრულებულია."

#: auction/views.py:1317
#: auction/views.py:1316
msgid "Auction was successfully canceled."
msgstr "აუქციონის გაუქმება წარმატებით განხორციელდა."

#: auction/views.py:1409
#: auction/views.py:1408
msgid "You can not leave an auction that has already been completed."
msgstr "თქვენ არ შეგიძლიათ დატოვოთ აუქციონი რომელიც უკვე დასრულდა."

#: auction/views.py:1413
#: auction/views.py:1412
msgid "You can not leave an auction that has not started yet."
msgstr "თქვენ არ შეგიძლიათ დატოვოთ აუქციონი, რომელიც ჯერ არ დაწყებულა."

#: auction/views.py:1417
#: auction/views.py:1416
msgid "You can not leave an auction that has been cancelled, drafted."
msgstr ""
"თქვენ არ შეგიძლიათ გაუქმებული ან drafter სტატუსის მქონე აუქციონის დატოვება."

#: auction/views.py:1422
#: auction/views.py:1421
msgid "As a winner of an auction, you can not leave it."
msgstr "როგორც გამარჯვებული, თქვენ ვერ დატოვებთ აუქციონს."

#: bid/permissions.py:50
#: bid/permissions.py:53
msgid ""
"As a non-premium user you can not place more than five unique bids on this "
"auction. But you can change the offer of a bid as many times as you want."
Expand Down

0 comments on commit a50bd97

Please sign in to comment.