Add more columns/filters in admin
This commit is contained in:
parent
285e1a1f96
commit
fae6f31794
1 changed files with 31 additions and 15 deletions
|
|
@ -58,21 +58,6 @@ class GovernmentPlanAdmin(admin.ModelAdmin):
|
|||
prepopulated_fields = {"slug": ("title",)}
|
||||
search_fields = ("title",)
|
||||
raw_id_fields = ("responsible_publicbody",)
|
||||
list_display = (
|
||||
"title",
|
||||
"public",
|
||||
"status",
|
||||
"rating",
|
||||
"organization",
|
||||
"get_categories",
|
||||
)
|
||||
list_filter = (
|
||||
"status",
|
||||
"rating",
|
||||
"public",
|
||||
"government",
|
||||
"categories",
|
||||
)
|
||||
|
||||
actions = ["make_public"]
|
||||
|
||||
|
|
@ -81,9 +66,40 @@ class GovernmentPlanAdmin(admin.ModelAdmin):
|
|||
qs = qs.prefetch_related(
|
||||
"categories",
|
||||
"organization",
|
||||
"group",
|
||||
)
|
||||
return qs
|
||||
|
||||
def get_list_display(self, request):
|
||||
list_display = [
|
||||
"title",
|
||||
"public",
|
||||
"status",
|
||||
"rating",
|
||||
"organization",
|
||||
"get_categories",
|
||||
]
|
||||
if not has_limited_access(request.user):
|
||||
list_display.append("group")
|
||||
return list_display
|
||||
|
||||
def get_list_filter(self, request):
|
||||
list_filter = [
|
||||
"status",
|
||||
"rating",
|
||||
"public",
|
||||
]
|
||||
if not has_limited_access(request.user):
|
||||
list_filter.extend(
|
||||
[
|
||||
"organization",
|
||||
"group",
|
||||
"government",
|
||||
"categories",
|
||||
]
|
||||
)
|
||||
return list_filter
|
||||
|
||||
def get_fields(self, request, obj=None):
|
||||
if has_limited_access(request.user):
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue