diff --git a/app/stiftung/views.py b/app/stiftung/views.py index bac3737..37ad643 100644 --- a/app/stiftung/views.py +++ b/app/stiftung/views.py @@ -1190,11 +1190,18 @@ def destinataer_list(request): else: order_fields = fields destinataere = destinataere.order_by(*order_fields) + else: + # Default sorting by last name (nachname) ascending + destinataere = destinataere.order_by("nachname", "vorname") - paginator = Paginator(destinataere, 20) + paginator = Paginator(destinataere, 50) # Increased from 20 to 50 entries per page page_number = request.GET.get("page") page_obj = paginator.get_page(page_number) + # Set default sort to nachname if no sort is specified + effective_sort = sort if sort else "nachname" + effective_direction = direction if sort else "asc" + context = { "page_obj": page_obj, "search_query": search_query, @@ -1203,8 +1210,8 @@ def destinataer_list(request): "aktiv_filter": aktiv_filter, "familienzweig_choices": Destinataer.FAMILIENZWIG_CHOICES, "berufsgruppe_choices": Destinataer.BERUFSGRUPPE_CHOICES, - "sort": sort, - "dir": direction, + "sort": effective_sort, + "dir": effective_direction, } return render(request, "stiftung/destinataer_list.html", context) diff --git a/app/templates/stiftung/destinataer_list.html b/app/templates/stiftung/destinataer_list.html index ef27fd0..e87ac3d 100644 --- a/app/templates/stiftung/destinataer_list.html +++ b/app/templates/stiftung/destinataer_list.html @@ -88,10 +88,28 @@ - Vorname + + Vorname + {% if sort == 'vorname' %} + {% if dir == 'desc' %} + + {% else %} + + {% endif %} + {% endif %} + - Nachname + + Nachname + {% if sort == 'nachname' %} + {% if dir == 'desc' %} + + {% else %} + + {% endif %} + {% endif %} + E-Mail @@ -170,6 +188,16 @@ + +
+ + Zeige {{ page_obj.start_index }} - {{ page_obj.end_index }} von {{ page_obj.paginator.count }} Destinatären + (50 Einträge pro Seite{% if sort %}, sortiert nach + {% if sort == 'nachname' %}Nachname{% elif sort == 'vorname' %}Vorname{% elif sort == 'email' %}E-Mail{% elif sort == 'vierteljaehrlicher_betrag' %}Vierteljährlicher Betrag{% elif sort == 'aktiv' %}Status{% elif sort == 'unterstuetzung_bestaetigt' %}Unterstützung bestätigt{% endif %} + {% if dir == 'desc' %} (absteigend){% else %} (aufsteigend){% endif %}{% endif %}) + +
+ {% if page_obj.has_other_pages %}