Allow viewing profit
parent
1e201e3f26
commit
77dcd4dd8f
@ -0,0 +1,27 @@
|
||||
{% load cache %}
|
||||
{% load cachalot cache %}
|
||||
{% get_last_invalidation 'core.Platform' as last %}
|
||||
{% include 'mixins/partials/notify.html' %}
|
||||
{# cache 600 objects_platform_profit request.user.id object_list type last #}
|
||||
{% for platform_name, profit_map in object_list.items %}
|
||||
<h2 class="title is-4">{{ platform_name }}</h2>
|
||||
<table
|
||||
class="table is-fullwidth is-hoverable"
|
||||
hx-target="#{{ context_object_name }}-table"
|
||||
id="{{ context_object_name }}-table"
|
||||
hx-swap="outerHTML"
|
||||
hx-trigger="{{ context_object_name_singular }}Event from:body"
|
||||
hx-get="{{ list_url }}">
|
||||
<thead>
|
||||
<th>id</th>
|
||||
</thead>
|
||||
{% for item in profit_map.values %}
|
||||
<tr>
|
||||
<td> {{ item }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</table>
|
||||
{% endfor %}
|
||||
{# endcache #}
|
@ -0,0 +1,36 @@
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render
|
||||
from django.urls import reverse
|
||||
from django.views import View
|
||||
from mixins.views import (
|
||||
ObjectCreate,
|
||||
ObjectDelete,
|
||||
ObjectList,
|
||||
ObjectRead,
|
||||
ObjectUpdate,
|
||||
)
|
||||
from two_factor.views.mixins import OTPRequiredMixin
|
||||
|
||||
from core.clients.aggregators.nordigen import NordigenClient
|
||||
from core.clients.platforms.agora import AgoraClient
|
||||
from core.util import logs
|
||||
from core.models import Platform
|
||||
from core.lib.money import money
|
||||
from core.views.helpers import synchronize_async_helper
|
||||
|
||||
log = logs.get_logger(__name__)
|
||||
|
||||
class Profit(LoginRequiredMixin, OTPRequiredMixin, ObjectRead):
|
||||
context_object_name_singular = "profit"
|
||||
context_object_name = "profit"
|
||||
# detail_template = "partials/profit-info.html"
|
||||
|
||||
def get_object(self, **kwargs):
|
||||
res = synchronize_async_helper(money.check_all(user=self.request.user, nordigen=NordigenClient, agora=AgoraClient))
|
||||
results = {
|
||||
"Bank balance total (USD)": res["total"]["total_sinks_usd"],
|
||||
"Platform balance total (USD)": res["total"]["total_usd_agora"],
|
||||
"Sum of above": res["total"]["total_sinks_usd"] + res["total"]["total_usd_agora"],
|
||||
}
|
||||
return results
|
Loading…
Reference in New Issue