2019-09-13 13:02:54 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2019-09-02 22:30:14 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
|
2019-09-13 13:02:54 +00:00
|
|
|
from import_export.admin import ImportExportModelAdmin
|
|
|
|
|
2021-11-03 14:06:57 +00:00
|
|
|
import common.models
|
2019-09-02 23:07:03 +00:00
|
|
|
|
|
|
|
|
2019-09-15 13:09:58 +00:00
|
|
|
class SettingsAdmin(ImportExportModelAdmin):
|
2021-05-06 10:11:38 +00:00
|
|
|
|
2020-10-19 13:02:54 +00:00
|
|
|
list_display = ('key', 'value')
|
2019-09-15 13:09:58 +00:00
|
|
|
|
2021-11-11 11:39:31 +00:00
|
|
|
def get_readonly_fields(self, request, obj=None):
|
|
|
|
"""
|
|
|
|
Prevent the 'key' field being edited once the setting is created
|
|
|
|
"""
|
|
|
|
|
|
|
|
if obj:
|
2021-11-12 04:42:53 +00:00
|
|
|
return ['key']
|
2021-11-11 11:39:31 +00:00
|
|
|
else:
|
|
|
|
return []
|
|
|
|
|
2019-09-15 13:09:58 +00:00
|
|
|
|
2021-07-22 21:46:31 +00:00
|
|
|
class UserSettingsAdmin(ImportExportModelAdmin):
|
|
|
|
|
|
|
|
list_display = ('key', 'value', 'user', )
|
|
|
|
|
2021-11-11 11:39:31 +00:00
|
|
|
def get_readonly_fields(self, request, obj=None):
|
|
|
|
"""
|
|
|
|
Prevent the 'key' field being edited once the setting is created
|
|
|
|
"""
|
|
|
|
|
|
|
|
if obj:
|
2021-11-12 04:42:53 +00:00
|
|
|
return ['key']
|
2021-11-11 11:39:31 +00:00
|
|
|
else:
|
|
|
|
return []
|
|
|
|
|
2021-07-22 21:46:31 +00:00
|
|
|
|
2021-11-03 14:06:57 +00:00
|
|
|
class NotificationEntryAdmin(admin.ModelAdmin):
|
|
|
|
|
|
|
|
list_display = ('key', 'uid', 'updated', )
|
|
|
|
|
|
|
|
|
2021-11-27 15:02:23 +00:00
|
|
|
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', )
|
|
|
|
|
|
|
|
|
2021-11-03 14:06:57 +00:00
|
|
|
admin.site.register(common.models.InvenTreeSetting, SettingsAdmin)
|
|
|
|
admin.site.register(common.models.InvenTreeUserSetting, UserSettingsAdmin)
|
|
|
|
admin.site.register(common.models.NotificationEntry, NotificationEntryAdmin)
|
2021-11-27 15:02:23 +00:00
|
|
|
admin.site.register(common.models.NotificationMessage, NotificationMessageAdmin)
|