From 312ddb4dc163dd63b595bef55b9435e83b2dd7c9 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 8 Dec 2022 07:20:46 +0000 Subject: [PATCH] Adjust titles for CRUD panels --- core/views/__init__.py | 10 ++++++++++ core/views/positions.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/views/__init__.py b/core/views/__init__.py index d7fbef2..9e62ace 100644 --- a/core/views/__init__.py +++ b/core/views/__init__.py @@ -192,6 +192,10 @@ class ObjectCreate(RestrictedViewMixin, ObjectNameMixin, CreateView): request = None + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.title = "Create " + self.context_object_name_singular + def post_save(self, obj): pass @@ -340,6 +344,10 @@ class ObjectUpdate(RestrictedViewMixin, ObjectNameMixin, UpdateView): request = None + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.title = "Update " + self.context_object_name_singular + def post_save(self, obj): pass @@ -380,6 +388,8 @@ class ObjectUpdate(RestrictedViewMixin, ObjectNameMixin, UpdateView): form = kwargs.get("form", None) if form: context["form"] = form + context["title"] = self.title + f" ({type})" + context["title_singular"] = self.title_singular context["unique"] = unique context["window_content"] = self.window_content context["context_object_name"] = self.context_object_name diff --git a/core/views/positions.py b/core/views/positions.py index c67c40a..b29f0c6 100644 --- a/core/views/positions.py +++ b/core/views/positions.py @@ -70,7 +70,7 @@ class PositionAction(LoginRequiredMixin, OTPRequiredMixin, ObjectRead): detail_template = "partials/position-detail.html" context_object_name_singular = "position" - context_object_name = "positions" + context_object_name = "position info" detail_url_name = "position_action" detail_url_args = ["type", "account_id", "symbol"]