mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +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')
|
||||
|
||||
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):
|
||||
|
||||
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):
|
||||
|
||||
|
@ -63,6 +63,8 @@ class BaseInvenTreeSetting(models.Model):
|
||||
Enforce validation and clean before saving
|
||||
"""
|
||||
|
||||
self.key = str(self.key).upper()
|
||||
|
||||
self.clean()
|
||||
self.validate_unique()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user