From 2c1a744c2de87ea89bf0812a2674a413a652d8f0 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 15 Sep 2019 23:09:58 +1000 Subject: [PATCH] Display singleton settings in the settings tab - Only visible to 'staff' user --- InvenTree/InvenTree/views.py | 9 +++++++++ InvenTree/common/admin.py | 8 +++++++- .../templates/InvenTree/settings/other.html | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index 610f3c0c00..ad0d70bfe8 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -16,6 +16,7 @@ from django.views.generic import UpdateView, CreateView from django.views.generic.base import TemplateView from part.models import Part +from common.models import InvenTreeSetting from .forms import DeleteForm, EditUserForm, SetPasswordForm from .helpers import str2bool @@ -511,3 +512,11 @@ class SettingsView(TemplateView): """ template_name = "InvenTree/settings.html" + + def get_context_data(self, **kwargs): + + ctx = super().get_context_data(**kwargs).copy() + + ctx['settings'] = InvenTreeSetting.objects.all().order_by('key') + + return ctx diff --git a/InvenTree/common/admin.py b/InvenTree/common/admin.py index e0db0a7136..cb643deca4 100644 --- a/InvenTree/common/admin.py +++ b/InvenTree/common/admin.py @@ -5,11 +5,17 @@ from django.contrib import admin from import_export.admin import ImportExportModelAdmin -from .models import Currency +from .models import Currency, InvenTreeSetting class CurrencyAdmin(ImportExportModelAdmin): list_display = ('symbol', 'suffix', 'description', 'value', 'base') +class SettingsAdmin(ImportExportModelAdmin): + + list_display = ('key', 'value', 'description') + + admin.site.register(Currency, CurrencyAdmin) +admin.site.register(InvenTreeSetting, SettingsAdmin) diff --git a/InvenTree/templates/InvenTree/settings/other.html b/InvenTree/templates/InvenTree/settings/other.html index bff3d4c2e6..d793788bb8 100644 --- a/InvenTree/templates/InvenTree/settings/other.html +++ b/InvenTree/templates/InvenTree/settings/other.html @@ -8,4 +8,23 @@

InvenTree Settings

+ + + + + + + + + + {% for setting in settings %} + + + + + + {% endfor %} + +
SettingValueDescription
{{ setting.key }}{{ setting.value }}{{ setting.description }}
+ {% endblock %} \ No newline at end of file