Fix positions CRUD
This commit is contained in:
parent
d396abca84
commit
1e85e830b2
|
@ -107,7 +107,6 @@ class ObjectList(RestrictedViewMixin, ObjectNameMixin, ListView):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
self.request = request
|
self.request = request
|
||||||
self.object_list = self.get_queryset(**kwargs)
|
self.object_list = self.get_queryset(**kwargs)
|
||||||
print("OBJ , ", self.object_list)
|
|
||||||
allow_empty = self.get_allow_empty()
|
allow_empty = self.get_allow_empty()
|
||||||
|
|
||||||
type = kwargs.get("type", None)
|
type = kwargs.get("type", None)
|
||||||
|
@ -120,7 +119,8 @@ class ObjectList(RestrictedViewMixin, ObjectNameMixin, ListView):
|
||||||
|
|
||||||
list_url_args = {}
|
list_url_args = {}
|
||||||
for arg in self.list_url_args:
|
for arg in self.list_url_args:
|
||||||
list_url_args[arg] = locals()[arg]
|
if arg in locals():
|
||||||
|
list_url_args[arg] = locals()[arg]
|
||||||
|
|
||||||
orig_type = type
|
orig_type = type
|
||||||
if type == "page":
|
if type == "page":
|
||||||
|
|
|
@ -42,13 +42,15 @@ def annotate_positions(positions, user, return_order_ids=False):
|
||||||
|
|
||||||
|
|
||||||
class Positions(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
class Positions(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
||||||
allowed_types = ["modal", "widget", "window", "page"]
|
|
||||||
window_content = "window-content/objects.html"
|
|
||||||
list_template = "partials/position-list.html"
|
list_template = "partials/position-list.html"
|
||||||
page_title = "Live positions from all exchanges"
|
page_title = "Live positions from all exchanges"
|
||||||
page_subtitle = "Manual trades are editable under 'Bot Trades' tab."
|
page_subtitle = "Manual trades are editable under 'Bot Trades' tab."
|
||||||
context_object_name_singular = "position"
|
context_object_name_singular = "position"
|
||||||
context_object_name = "positions"
|
context_object_name = "positions"
|
||||||
|
|
||||||
|
list_url_name = "positions"
|
||||||
|
list_url_args = ["type", "account_id"]
|
||||||
|
|
||||||
widget_options = 'gs-w="12" gs-h="1" gs-y="0" gs-x="0"'
|
widget_options = 'gs-w="12" gs-h="1" gs-y="0" gs-x="0"'
|
||||||
|
|
||||||
def get_queryset(self, **kwargs):
|
def get_queryset(self, **kwargs):
|
||||||
|
@ -68,47 +70,6 @@ class Positions(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
||||||
annotate_positions(items, self.request.user, return_order_ids=False)
|
annotate_positions(items, self.request.user, return_order_ids=False)
|
||||||
return items
|
return items
|
||||||
|
|
||||||
# def get(self, request, type, account_id=None):
|
|
||||||
# if type not in self.allowed_types:
|
|
||||||
# return HttpResponseBadRequest
|
|
||||||
# self.template_name = f"wm/{type}.html"
|
|
||||||
# unique = str(uuid.uuid4())[:8]
|
|
||||||
# items = get_positions(request.user, account_id)
|
|
||||||
# annotate_positions(items, request.user, return_order_ids=False)
|
|
||||||
|
|
||||||
# orig_type = type
|
|
||||||
# if type == "page":
|
|
||||||
# type = "modal"
|
|
||||||
# cast = {
|
|
||||||
# "type": orig_type,
|
|
||||||
# }
|
|
||||||
# if account_id:
|
|
||||||
# cast["account_id"] = account_id
|
|
||||||
# list_url = reverse("positions", kwargs={**cast})
|
|
||||||
# context = {
|
|
||||||
# "title": f"Positions ({type})",
|
|
||||||
# "unique": unique,
|
|
||||||
# "window_content": self.window_content,
|
|
||||||
# "list_template": self.list_template,
|
|
||||||
# "items": items,
|
|
||||||
# "type": type,
|
|
||||||
# "page_title": self.page_title,
|
|
||||||
# "page_subtitle": self.page_subtitle,
|
|
||||||
# "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:
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
|
|
||||||
class PositionAction(LoginRequiredMixin, OTPRequiredMixin, View):
|
class PositionAction(LoginRequiredMixin, OTPRequiredMixin, View):
|
||||||
allowed_types = ["modal", "widget", "window", "page"]
|
allowed_types = ["modal", "widget", "window", "page"]
|
||||||
|
|
Loading…
Reference in New Issue