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,
|
||||
}
|
||||
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.set(f"trade.{trade_id}.reference", reference)
|
||||
message = f"Generated reference for {trade_id}: {reference}"
|
||||
|
@ -915,12 +915,13 @@ class LocalPlatformClient(ABC):
|
|||
# else: # User is verified
|
||||
# log.info(f"UID {uid} is verified.")
|
||||
ad_obj = self.instance.get_ad(ad_id)
|
||||
if not ad_obj:
|
||||
log.error(f"Could not get ad object for {ad_id}.")
|
||||
return
|
||||
|
||||
if ad_obj:
|
||||
await self.send_bank_details(currency, trade_id, ad_obj)
|
||||
await self.send_reference(trade_id, reference)
|
||||
else:
|
||||
log.warning(f"Could not get ad object for {ad_id}.")
|
||||
# return
|
||||
|
||||
if existing_ref:
|
||||
return existing_ref
|
||||
else:
|
||||
|
|
|
@ -208,6 +208,14 @@ class Platform(models.Model):
|
|||
|
||||
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):
|
||||
"""
|
||||
Get a reference from a contact_id.
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
<th>amount</th>
|
||||
<th>crypto</th>
|
||||
<th>provider</th>
|
||||
<th>type</th>
|
||||
<th>actions</th>
|
||||
</thead>
|
||||
{% for item in trade_map.values %}
|
||||
|
@ -27,7 +26,7 @@
|
|||
<td>
|
||||
<a
|
||||
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">
|
||||
<i class="fa-solid fa-copy" aria-hidden="true"></i>
|
||||
</span>
|
||||
|
@ -41,13 +40,10 @@
|
|||
<code>{{ item.reference }}</code>
|
||||
</a>
|
||||
</td>
|
||||
<td data-tooltip="{{ item.data.buyer.name }}
|
||||
Trades: {{ item.data.buyer.trade_count }}
|
||||
Last online: {{ item.data.buyer.last_online }}">{{ item.data.buyer.username }}</td>
|
||||
<td>{{ item.data.amount }} {{ item.data.currency }}</td>
|
||||
<td>{{ item.data.amount_xmr }} XMR</td>
|
||||
<td>{{ item.data.advertisement.payment_method }}</td>
|
||||
<td>{{ item.data.advertisement.trade_type }}</td>
|
||||
<td>{{ item.buyer }}</td>
|
||||
<td>{{ item.amount_fiat }} {{ item.currency }}</td>
|
||||
<td>{{ item.amount_crypto }} XMR</td>
|
||||
<td>{{ item.provider }}</td>
|
||||
<td>
|
||||
<div class="buttons">
|
||||
<button
|
||||
|
|
|
@ -7,11 +7,12 @@ from mixins.views import ( # ObjectRead,
|
|||
)
|
||||
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.models import Platform
|
||||
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__)
|
||||
|
||||
|
@ -30,9 +31,10 @@ class PlatformTrades(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
|||
platforms = Platform.get_for_user(self.request.user)
|
||||
total_trades = {}
|
||||
for platform in platforms:
|
||||
run = synchronize_async_helper(AgoraClient(platform))
|
||||
dash = synchronize_async_helper(run.wrap_dashboard())
|
||||
total_trades[platform.name] = dash
|
||||
# run = synchronize_async_helper(AgoraClient(platform))
|
||||
# dash = synchronize_async_helper(run.wrap_dashboard())
|
||||
trades = platform.trades
|
||||
total_trades[platform.name] = trades
|
||||
|
||||
return total_trades
|
||||
|
||||
|
|
Loading…
Reference in New Issue