Make a proper front page
This commit is contained in:
@@ -93,6 +93,7 @@ class Positions(LoginRequiredMixin, OTPRequiredMixin, View):
|
||||
"list_url": list_url,
|
||||
"context_object_name_singular": self.context_object_name_singular,
|
||||
"context_object_name": self.context_object_name,
|
||||
"widget_options": 'gs-w="12" gs-h="1" gs-y="0" gs-x="0"',
|
||||
}
|
||||
# Return partials for HTMX
|
||||
if self.request.htmx:
|
||||
|
||||
@@ -5,15 +5,15 @@ from django.http import HttpResponseBadRequest
|
||||
from django.shortcuts import render
|
||||
from django.urls import reverse
|
||||
from django.views import View
|
||||
from rest_framework.parsers import FormParser
|
||||
from two_factor.views.mixins import OTPRequiredMixin
|
||||
|
||||
from core.exchanges import GenericAPIError
|
||||
from core.models import Account, Trade
|
||||
from core.models import Account
|
||||
from core.util import logs
|
||||
|
||||
log = logs.get_logger(__name__)
|
||||
|
||||
|
||||
def get_profit(user):
|
||||
items = []
|
||||
accounts = Account.objects.filter(user=user)
|
||||
@@ -21,12 +21,18 @@ def get_profit(user):
|
||||
try:
|
||||
details = account.client.get_account()
|
||||
pl = details["pl"]
|
||||
item = {"account": account, "pl": float(pl), "balance": details["balance"], "currency": details["currency"]}
|
||||
item = {
|
||||
"account": account,
|
||||
"pl": float(pl),
|
||||
"balance": details["balance"],
|
||||
"currency": details["currency"],
|
||||
}
|
||||
items.append(item)
|
||||
except GenericAPIError:
|
||||
continue
|
||||
return items
|
||||
|
||||
|
||||
class Profit(LoginRequiredMixin, OTPRequiredMixin, View):
|
||||
allowed_types = ["modal", "widget", "window", "page"]
|
||||
window_content = "window-content/objects.html"
|
||||
@@ -65,10 +71,10 @@ class Profit(LoginRequiredMixin, OTPRequiredMixin, View):
|
||||
}
|
||||
# Return partials for HTMX
|
||||
if self.request.htmx:
|
||||
if request.headers["HX-Target"] == self.context_object_name+"-table":
|
||||
if request.headers["HX-Target"] == self.context_object_name + "-table":
|
||||
self.template_name = self.list_template
|
||||
elif orig_type == "page":
|
||||
self.template_name = self.list_template
|
||||
else:
|
||||
context["window_content"] = self.list_template
|
||||
return render(request, self.template_name, context)
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
Reference in New Issue
Block a user