Simplify schema and error handling

This commit is contained in:
2022-11-04 07:20:55 +00:00
parent 04a87c1da6
commit b36791d56b
8 changed files with 181 additions and 128 deletions

View File

@@ -111,7 +111,10 @@ class HookList(LoginRequiredMixin, ObjectList):
title = "Hooks"
title_singular = "Hook"
page_title = "List of active URL endpoints for receiving hooks."
page_subtitle = "Add URLs here to receive Drakdoo callbacks. Make then unique!"
page_subtitle = (
"Add URLs here to receive Drakdoo callbacks. "
"Make then unique and hard to guess!"
)
list_url_name = "hooks"
list_url_args = ["type"]

View File

@@ -6,7 +6,6 @@ from django.shortcuts import render
from django.views import View
from rest_framework.parsers import FormParser
from core.lib import trades
from core.models import Account
from core.util import logs
@@ -17,10 +16,7 @@ def get_positions(user, account_id=None):
items = []
accounts = Account.objects.filter(user=user)
for account in accounts:
success, positions = account.client.get_all_positions()
if not success:
items.append({"name": account.name, "status": "error"})
continue
positions = account.client.get_all_positions()
for item in positions:
items.append(item)
@@ -71,11 +67,8 @@ class PositionAction(LoginRequiredMixin, View):
unique = str(uuid.uuid4())[:8]
account = Account.get_by_id(account_id, request.user)
success, info = account.client.get_position_info(symbol)
info = account.client.get_position_info(symbol)
print("ACCT INFO", info)
if not success:
message = "Position does not exist"
message_class = "danger"
items = get_positions(request.user, account_id)
if type == "page":
@@ -87,9 +80,6 @@ class PositionAction(LoginRequiredMixin, View):
"items": items,
"type": type,
}
if success:
context["items"] = info
else:
context["message"] = message
context["class"] = message_class
context["items"] = info
return render(request, template_name, context)