Skip to content

Commit

Permalink
Allow for existing extra_context (#22)
Browse files Browse the repository at this point in the history
This allows compatibility with other admin mixins
  • Loading branch information
underdoeg committed Apr 16, 2024
1 parent afa96f1 commit 35fa0a2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cabinet/base_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def folders_annotate_counts(self, folders):

return folders

def changelist_view(self, request):
def changelist_view(self, request, extra_context=None):
folder__id__exact = request.GET.get("folder__id__exact")
if folder__id__exact == "last":
kw = {}
Expand Down Expand Up @@ -447,13 +447,15 @@ def changelist_view(self, request):
),
}
)

response = super().changelist_view(
request,
extra_context={
extra_context_cabinet = {
"cabinet": cabinet_context,
"title": folder or _("Root folder"),
},
}
if extra_context:
extra_context_cabinet.update(extra_context)
response = super().changelist_view(
request,
extra_context=extra_context_cabinet,
)
response.set_cookie("cabinet_folder", folder.pk if folder else "")
return response
Expand Down

0 comments on commit 35fa0a2

Please sign in to comment.