mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
dd44eb389f
part of #2282
59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import unicode_literals
|
|
|
|
from django.contrib import admin
|
|
|
|
from import_export.admin import ImportExportModelAdmin
|
|
|
|
import common.models
|
|
|
|
|
|
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):
|
|
|
|
list_display = ('key', 'uid', 'updated', )
|
|
|
|
|
|
class NotificationMessageAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('age_human', 'user', 'category', 'name', 'read', 'target_object', 'source_object', )
|
|
|
|
list_filter = ('category', 'read', 'user', )
|
|
|
|
search_fields = ('name', 'category', 'message', )
|
|
|
|
|
|
admin.site.register(common.models.InvenTreeSetting, SettingsAdmin)
|
|
admin.site.register(common.models.InvenTreeUserSetting, UserSettingsAdmin)
|
|
admin.site.register(common.models.NotificationEntry, NotificationEntryAdmin)
|
|
admin.site.register(common.models.NotificationMessage, NotificationMessageAdmin)
|