Skip to content

Commit

Permalink
POC for jazzband#72
Browse files Browse the repository at this point in the history
Note that if you are using any custom methods on the model for the admin
display, you need to use a History Base class for this to work(jazzband#311).
  • Loading branch information
Marco Silva authored and mjsir911 committed Apr 27, 2023
1 parent b5eadd5 commit 0303f7f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions simple_history/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,18 @@ def enforce_history_permissions(self):
return getattr(
settings, "SIMPLE_HISTORY_ENFORCE_HISTORY_MODEL_PERMISSIONS", False
)


class SimpleHistoryShowDeletedFilter(admin.SimpleListFilter):
title = "Entries"
parameter_name = "entries"

def lookups(self, request, model_admin):
return (
("deleted_only", "Only Deleted"),
)

def queryset(self, request, queryset):
if self.value():
return queryset.model.history.filter(history_type='-').distinct()
return queryset

0 comments on commit 0303f7f

Please sign in to comment.