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
snps-msilva authored and mjsir911 committed Jul 28, 2023
1 parent a768673 commit 2c71785
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions simple_history/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,16 @@ 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 2c71785

Please sign in to comment.