kopia lustrzana https://github.com/jedie/PyInventory
Better changelists for super users
rodzic
043e47eab9
commit
4baaa8d95e
|
@ -43,6 +43,26 @@ class BaseUserAdmin(CompareVersionAdmin):
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
def get_list_filter(self, request):
|
||||||
|
list_filter = self.list_filter
|
||||||
|
|
||||||
|
if request.user.is_superuser:
|
||||||
|
# Superuser sees entries from all users -> Add "By user" filter
|
||||||
|
list_filter = list(list_filter)
|
||||||
|
list_filter.insert(0, 'user')
|
||||||
|
|
||||||
|
return list_filter
|
||||||
|
|
||||||
|
def get_list_display(self, request):
|
||||||
|
list_display = self.list_display
|
||||||
|
|
||||||
|
if request.user.is_superuser:
|
||||||
|
# Superuser sees entries from all users -> Display the user in change list
|
||||||
|
list_display = list(list_display)
|
||||||
|
list_display.insert(0, 'user')
|
||||||
|
|
||||||
|
return list_display
|
||||||
|
|
||||||
|
|
||||||
class BaseImageModelInline(UserInlineMixin, SortableInlineAdminMixin, admin.TabularInline):
|
class BaseImageModelInline(UserInlineMixin, SortableInlineAdminMixin, admin.TabularInline):
|
||||||
def preview(self, instance):
|
def preview(self, instance):
|
||||||
|
|
|
@ -24,5 +24,6 @@ class LocationModelAdmin(ImportExportMixin, BaseUserAdmin):
|
||||||
return text
|
return text
|
||||||
|
|
||||||
list_display = ('location', 'create_dt', 'update_dt')
|
list_display = ('location', 'create_dt', 'update_dt')
|
||||||
|
list_display_links = ('location',)
|
||||||
list_filter = (LimitTreeDepthListFilter,)
|
list_filter = (LimitTreeDepthListFilter,)
|
||||||
ordering = ('path_str',)
|
ordering = ('path_str',)
|
||||||
|
|
Ładowanie…
Reference in New Issue