mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Tweaks for settings admin views
This commit is contained in:
parent
d4db750d2f
commit
03aa9bc9b0
@ -12,11 +12,31 @@ class SettingsAdmin(ImportExportModelAdmin):
|
|||||||
|
|
||||||
list_display = ('key', 'value')
|
list_display = ('key', 'value')
|
||||||
|
|
||||||
|
def get_readonly_fields(self, request, obj=None):
|
||||||
|
"""
|
||||||
|
Prevent the 'key' field being edited once the setting is created
|
||||||
|
"""
|
||||||
|
|
||||||
|
if obj:
|
||||||
|
return ['key',]
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
class UserSettingsAdmin(ImportExportModelAdmin):
|
class UserSettingsAdmin(ImportExportModelAdmin):
|
||||||
|
|
||||||
list_display = ('key', 'value', 'user', )
|
list_display = ('key', 'value', 'user', )
|
||||||
|
|
||||||
|
def get_readonly_fields(self, request, obj=None):
|
||||||
|
"""
|
||||||
|
Prevent the 'key' field being edited once the setting is created
|
||||||
|
"""
|
||||||
|
|
||||||
|
if obj:
|
||||||
|
return ['key',]
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
class NotificationEntryAdmin(admin.ModelAdmin):
|
class NotificationEntryAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
|
@ -63,6 +63,8 @@ class BaseInvenTreeSetting(models.Model):
|
|||||||
Enforce validation and clean before saving
|
Enforce validation and clean before saving
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
self.key = str(self.key).upper()
|
||||||
|
|
||||||
self.clean()
|
self.clean()
|
||||||
self.validate_unique()
|
self.validate_unique()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user