Adjust titles for CRUD panels

This commit is contained in:
Mark Veidemanis 2022-12-08 07:20:46 +00:00
parent 0aef440229
commit 312ddb4dc1
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
2 changed files with 11 additions and 1 deletions

View File

@ -192,6 +192,10 @@ class ObjectCreate(RestrictedViewMixin, ObjectNameMixin, CreateView):
request = None request = None
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title = "Create " + self.context_object_name_singular
def post_save(self, obj): def post_save(self, obj):
pass pass
@ -340,6 +344,10 @@ class ObjectUpdate(RestrictedViewMixin, ObjectNameMixin, UpdateView):
request = None request = None
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title = "Update " + self.context_object_name_singular
def post_save(self, obj): def post_save(self, obj):
pass pass
@ -380,6 +388,8 @@ class ObjectUpdate(RestrictedViewMixin, ObjectNameMixin, UpdateView):
form = kwargs.get("form", None) form = kwargs.get("form", None)
if form: if form:
context["form"] = form context["form"] = form
context["title"] = self.title + f" ({type})"
context["title_singular"] = self.title_singular
context["unique"] = unique context["unique"] = unique
context["window_content"] = self.window_content context["window_content"] = self.window_content
context["context_object_name"] = self.context_object_name context["context_object_name"] = self.context_object_name

View File

@ -70,7 +70,7 @@ class PositionAction(LoginRequiredMixin, OTPRequiredMixin, ObjectRead):
detail_template = "partials/position-detail.html" detail_template = "partials/position-detail.html"
context_object_name_singular = "position" context_object_name_singular = "position"
context_object_name = "positions" context_object_name = "position info"
detail_url_name = "position_action" detail_url_name = "position_action"
detail_url_args = ["type", "account_id", "symbol"] detail_url_args = ["type", "account_id", "symbol"]