Serve trade data from DB
This commit is contained in:
parent
1a34121da6
commit
70c8bd413f
|
@ -901,7 +901,7 @@ class LocalPlatformClient(ABC):
|
||||||
"ad_id": ad_id,
|
"ad_id": ad_id,
|
||||||
}
|
}
|
||||||
log.info(f"Storing trade information: {str(trade_cast)}")
|
log.info(f"Storing trade information: {str(trade_cast)}")
|
||||||
trade = self.instance.new_trade(trade_cast)
|
self.instance.new_trade(trade_cast)
|
||||||
# await db.r.hmset(f"trade.{reference}", to_store)
|
# await db.r.hmset(f"trade.{reference}", to_store)
|
||||||
# await db.r.set(f"trade.{trade_id}.reference", reference)
|
# await db.r.set(f"trade.{trade_id}.reference", reference)
|
||||||
message = f"Generated reference for {trade_id}: {reference}"
|
message = f"Generated reference for {trade_id}: {reference}"
|
||||||
|
@ -915,12 +915,13 @@ class LocalPlatformClient(ABC):
|
||||||
# else: # User is verified
|
# else: # User is verified
|
||||||
# log.info(f"UID {uid} is verified.")
|
# log.info(f"UID {uid} is verified.")
|
||||||
ad_obj = self.instance.get_ad(ad_id)
|
ad_obj = self.instance.get_ad(ad_id)
|
||||||
if not ad_obj:
|
if ad_obj:
|
||||||
log.error(f"Could not get ad object for {ad_id}.")
|
|
||||||
return
|
|
||||||
|
|
||||||
await self.send_bank_details(currency, trade_id, ad_obj)
|
await self.send_bank_details(currency, trade_id, ad_obj)
|
||||||
await self.send_reference(trade_id, reference)
|
await self.send_reference(trade_id, reference)
|
||||||
|
else:
|
||||||
|
log.warning(f"Could not get ad object for {ad_id}.")
|
||||||
|
# return
|
||||||
|
|
||||||
if existing_ref:
|
if existing_ref:
|
||||||
return existing_ref
|
return existing_ref
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -208,6 +208,14 @@ class Platform(models.Model):
|
||||||
|
|
||||||
return references
|
return references
|
||||||
|
|
||||||
|
@property
|
||||||
|
def trades(self):
|
||||||
|
"""
|
||||||
|
Get all our open trades.
|
||||||
|
"""
|
||||||
|
our_trades = Trade.objects.filter(platform=self, open=True)
|
||||||
|
return our_trades
|
||||||
|
|
||||||
def contact_id_to_reference(self, contact_id):
|
def contact_id_to_reference(self, contact_id):
|
||||||
"""
|
"""
|
||||||
Get a reference from a contact_id.
|
Get a reference from a contact_id.
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
<th>amount</th>
|
<th>amount</th>
|
||||||
<th>crypto</th>
|
<th>crypto</th>
|
||||||
<th>provider</th>
|
<th>provider</th>
|
||||||
<th>type</th>
|
|
||||||
<th>actions</th>
|
<th>actions</th>
|
||||||
</thead>
|
</thead>
|
||||||
{% for item in trade_map.values %}
|
{% for item in trade_map.values %}
|
||||||
|
@ -27,7 +26,7 @@
|
||||||
<td>
|
<td>
|
||||||
<a
|
<a
|
||||||
class="has-text-grey"
|
class="has-text-grey"
|
||||||
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.data.contact_id }}');">
|
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.contact_id }}');">
|
||||||
<span class="icon" data-tooltip="Copy to clipboard">
|
<span class="icon" data-tooltip="Copy to clipboard">
|
||||||
<i class="fa-solid fa-copy" aria-hidden="true"></i>
|
<i class="fa-solid fa-copy" aria-hidden="true"></i>
|
||||||
</span>
|
</span>
|
||||||
|
@ -41,13 +40,10 @@
|
||||||
<code>{{ item.reference }}</code>
|
<code>{{ item.reference }}</code>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td data-tooltip="{{ item.data.buyer.name }}
|
<td>{{ item.buyer }}</td>
|
||||||
Trades: {{ item.data.buyer.trade_count }}
|
<td>{{ item.amount_fiat }} {{ item.currency }}</td>
|
||||||
Last online: {{ item.data.buyer.last_online }}">{{ item.data.buyer.username }}</td>
|
<td>{{ item.amount_crypto }} XMR</td>
|
||||||
<td>{{ item.data.amount }} {{ item.data.currency }}</td>
|
<td>{{ item.provider }}</td>
|
||||||
<td>{{ item.data.amount_xmr }} XMR</td>
|
|
||||||
<td>{{ item.data.advertisement.payment_method }}</td>
|
|
||||||
<td>{{ item.data.advertisement.trade_type }}</td>
|
|
||||||
<td>
|
<td>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -7,11 +7,12 @@ from mixins.views import ( # ObjectRead,
|
||||||
)
|
)
|
||||||
from two_factor.views.mixins import OTPRequiredMixin
|
from two_factor.views.mixins import OTPRequiredMixin
|
||||||
|
|
||||||
from core.clients.platforms.agora import AgoraClient
|
# from core.clients.platforms.agora import AgoraClient
|
||||||
from core.forms import PlatformForm
|
from core.forms import PlatformForm
|
||||||
from core.models import Platform
|
from core.models import Platform
|
||||||
from core.util import logs
|
from core.util import logs
|
||||||
from core.views.helpers import synchronize_async_helper
|
|
||||||
|
# from core.views.helpers import synchronize_async_helper
|
||||||
|
|
||||||
log = logs.get_logger(__name__)
|
log = logs.get_logger(__name__)
|
||||||
|
|
||||||
|
@ -30,9 +31,10 @@ class PlatformTrades(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
||||||
platforms = Platform.get_for_user(self.request.user)
|
platforms = Platform.get_for_user(self.request.user)
|
||||||
total_trades = {}
|
total_trades = {}
|
||||||
for platform in platforms:
|
for platform in platforms:
|
||||||
run = synchronize_async_helper(AgoraClient(platform))
|
# run = synchronize_async_helper(AgoraClient(platform))
|
||||||
dash = synchronize_async_helper(run.wrap_dashboard())
|
# dash = synchronize_async_helper(run.wrap_dashboard())
|
||||||
total_trades[platform.name] = dash
|
trades = platform.trades
|
||||||
|
total_trades[platform.name] = trades
|
||||||
|
|
||||||
return total_trades
|
return total_trades
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue