From 3bd8df50ce4987455a6171fef0f8bb2f5272d0de Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson Date: Mon, 2 Jun 2025 14:00:28 +0200 Subject: [PATCH] Add report info to project table. --- hypha/apply/projects/reports/models.py | 3 +++ hypha/apply/projects/tables.py | 28 ++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/hypha/apply/projects/reports/models.py b/hypha/apply/projects/reports/models.py index dc88876c63..1221540e74 100644 --- a/hypha/apply/projects/reports/models.py +++ b/hypha/apply/projects/reports/models.py @@ -312,6 +312,9 @@ def has_very_late_reports(self): def past_due_reports(self): return self.project.reports.to_do() + def submitted_reports(self): + return self.project.reports.submitted() + def last_report(self): today = timezone.now().date() # Get the most recent report that was either: diff --git a/hypha/apply/projects/tables.py b/hypha/apply/projects/tables.py index 5d833c56c7..beb8ec0234 100644 --- a/hypha/apply/projects/tables.py +++ b/hypha/apply/projects/tables.py @@ -3,7 +3,7 @@ import django_tables2 as tables from django.utils.safestring import mark_safe from django.utils.text import slugify -from django.utils.translation import gettext_lazy as _ +from django.utils.translation import gettext as _ from django_tables2.utils import A from heroicons.templatetags.heroicons import heroicon_outline @@ -157,16 +157,32 @@ def render_reporting(self, record): if not hasattr(record, "report_config"): return "-" + display = [] + if record.report_config.is_up_to_date(): - return "Up to date" + display.append(_("Up to date")) + + if record.report_config.submitted_reports(): + display.append( + _("{submitted_reports} submitted").format( + submitted_reports=len(record.report_config.submitted_reports()) + ) + ) if record.report_config.has_very_late_reports(): - display = f"{heroicon_outline(name='exclamation-triangle', size=20)}" + very_late = f"{heroicon_outline(name='exclamation-triangle', size=20)}" else: - display = "" + very_late = "" + + if record.report_config.outstanding_reports(): + display.append( + _("{outstanding_reports} outstanding{very_late}").format( + very_late=very_late, + outstanding_reports=record.report_config.outstanding_reports(), + ) + ) - display += f"{record.report_config.outstanding_reports()} outstanding" - return mark_safe(display) + return mark_safe("
".join(display)) class ProjectsDashboardTable(BaseProjectsTable):