From a59422c726a529585f1b707f5e9513405cbbd70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20Kol=C3=A1=C5=99?= Date: Wed, 15 Nov 2023 10:07:25 +0100 Subject: [PATCH] fix(sections): cleaned stats, removed redundant button --- .../parts/section_stats_buddy_btn.html | 3 --- fiesta/apps/sections/views/stats.py | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) delete mode 100644 fiesta/apps/sections/templates/sections/parts/section_stats_buddy_btn.html diff --git a/fiesta/apps/sections/templates/sections/parts/section_stats_buddy_btn.html b/fiesta/apps/sections/templates/sections/parts/section_stats_buddy_btn.html deleted file mode 100644 index adf45f7c..00000000 --- a/fiesta/apps/sections/templates/sections/parts/section_stats_buddy_btn.html +++ /dev/null @@ -1,3 +0,0 @@ -{% load i18n %} -{% trans "show all" %} diff --git a/fiesta/apps/sections/views/stats.py b/fiesta/apps/sections/views/stats.py index 527a3ac6..1774fe0e 100644 --- a/fiesta/apps/sections/views/stats.py +++ b/fiesta/apps/sections/views/stats.py @@ -3,8 +3,9 @@ from django.db import models from django.db.models import Count, OuterRef, Subquery from django.db.models.functions import Coalesce +from django.urls import reverse from django.utils.translation import gettext_lazy as _ -from django_tables2 import Column, Table, TemplateColumn +from django_tables2 import Column, Table from apps.buddy_system.models import BuddyRequest from apps.fiestatables.filters import BaseFilterSet, ProperDateFromToRangeFilter @@ -52,18 +53,22 @@ def qs(self): class BuddyStatsTable(Table): - abbr = Column(verbose_name=_("Faculty"), attrs=dict(td=dict(title=lambda record: record.name))) - matched_buddy_requests = Column(verbose_name=_("Matched requests")) - - actions = TemplateColumn(template_name="sections/parts/section_stats_buddy_btn.html") + university = Column( + verbose_name=_("University"), accessor="university.name", attrs=dict(td=dict(title=lambda record: record.name)) + ) + faculty = Column(verbose_name=_("Faculty"), accessor="abbr", attrs=dict(td=dict(title=lambda record: record.name))) + matched_buddy_requests = Column( + verbose_name=_("Matched requests"), + linkify=lambda record: reverse("buddy_system:requests") + f"?matcher_faculty={record.pk}", + ) class Meta: model = Faculty - fields = ("abbr",) - sequence = ( - "abbr", - "...", + fields = ( + "university", + "faculty", + "matched_buddy_requests", )