Display singleton settings in the settings tab

- Only visible to 'staff' user
This commit is contained in:
Oliver Walters 2019-09-15 23:09:58 +10:00
parent 098cd0ec44
commit 2c1a744c2d
3 changed files with 35 additions and 1 deletions

View File

@ -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

View File

@ -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)

View File

@ -8,4 +8,23 @@
<h4>InvenTree Settings</h4>
<table class='table table-striped table-condensed' id='other-table'>
<thead>
<tr>
<th>Setting</th>
<th>Value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for setting in settings %}
<tr>
<td>{{ setting.key }}</td>
<td>{{ setting.value }}</td>
<td>{{ setting.description }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}