Skip to content

Commit

Permalink
Merge pull request #1082 from CodingPirates/907-fjern-link-til-foreni…
Browse files Browse the repository at this point in the history
…ng-under-afdeling-i-admin

Admin > Afdeling: Flyt Foreningskolonne, og sorter på Venteliste antal
  • Loading branch information
lakridserne authored Jul 21, 2024
2 parents fff7e2a + a237ca8 commit 7aa36a1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions members/admin/department_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
)
from django.utils.html import escape
from django.http import HttpResponse
from django.db.models import Count


class AdminUserDepartmentInline(admin.TabularInline):
Expand Down Expand Up @@ -97,8 +98,6 @@ def queryset(self, request, queryset):
class DepartmentAdmin(admin.ModelAdmin):
inlines = [AdminUserDepartmentInline]
list_display = (
"id",
"department_union_link",
"department_link",
"address",
"isVisible",
Expand All @@ -107,6 +106,7 @@ class DepartmentAdmin(admin.ModelAdmin):
"created",
"closed_dtm",
"waitinglist_count_link",
"department_union_link",
)
list_filter = (
"address__region",
Expand Down Expand Up @@ -149,7 +149,9 @@ def formfield_for_manytomany(self, db_field, request, **kwargs):
return super().formfield_for_manytomany(db_field, request, **kwargs)

def get_queryset(self, request):
qs = super(DepartmentAdmin, self).get_queryset(request)
queryset = super().get_queryset(request)
qs = queryset.annotate(waitinglist_count=Count("waitinglist"))

if request.user.is_superuser or request.user.has_perm(
"members.view_all_departments"
):
Expand Down Expand Up @@ -210,11 +212,12 @@ def waitinglist_count_link(self, item):
link = f"""<a
href="{admin_url}?waiting_list={item.id}"
title="Vis venteliste for afdelingen Coding Pirates {item.name}">
{item.waitinglist_set.count()}
{item.waitinglist_count}
</a>"""
return mark_safe(link)

waitinglist_count_link.short_description = "Venteliste"
waitinglist_count_link.admin_order_field = "waitinglist_count"

def export_department_info_csv(self, request, queryset):
result_string = """"Forening"; "Afdeling"; "Afdeling-Startdato"; "Afdeling-lukkedato";\
Expand Down

0 comments on commit 7aa36a1

Please sign in to comment.