From b57a78dea40049cefe19420e2c412a9f02fca9fc Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 25 Oct 2020 08:10:52 +1100 Subject: [PATCH] Add some context data to the view for editing a setting --- .../common/templates/common/edit_setting.html | 14 ++++++++++++++ InvenTree/common/views.py | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 InvenTree/common/templates/common/edit_setting.html diff --git a/InvenTree/common/templates/common/edit_setting.html b/InvenTree/common/templates/common/edit_setting.html new file mode 100644 index 0000000000..815ac76702 --- /dev/null +++ b/InvenTree/common/templates/common/edit_setting.html @@ -0,0 +1,14 @@ +{% extends "modal_form.html" %} +{% load i18n %} + +{% block pre_form_content %} + +{{ block.super }} + +

+ {{ name }}
+ {{ description }}
+ {% trans "Current value" %}: {{ value }} +

+ +{% endblock %} \ No newline at end of file diff --git a/InvenTree/common/views.py b/InvenTree/common/views.py index a205b8b915..8a91248063 100644 --- a/InvenTree/common/views.py +++ b/InvenTree/common/views.py @@ -46,3 +46,20 @@ class SettingEdit(AjaxUpdateView): model = models.InvenTreeSetting ajax_form_title = _('Change Setting') form_class = forms.SettingEditForm + ajax_template_name = "common/edit_setting.html" + + def get_context_data(self, **kwargs): + """ + Add extra context information about the particular setting object. + """ + + ctx = super().get_context_data(**kwargs) + + setting = self.get_object() + + ctx['key'] = setting.key + ctx['value'] = setting.value + ctx['name'] = models.InvenTreeSetting.get_setting_name(setting.key) + ctx['description'] = models.InvenTreeSetting.get_setting_description(setting.key) + + return ctx