From 4b7ef2697e84bae269983dfce63f1af60bb247df Mon Sep 17 00:00:00 2001 From: Alejandro Cardenas Date: Tue, 30 Jan 2024 15:14:14 -0500 Subject: [PATCH] feat: add state sent to state column (#34127) --- openedx/features/survey_report/admin.py | 14 +++++++++++++- .../templates/survey_report/change_list.html | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/openedx/features/survey_report/admin.py b/openedx/features/survey_report/admin.py index adb759a84f..a5719d966a 100644 --- a/openedx/features/survey_report/admin.py +++ b/openedx/features/survey_report/admin.py @@ -22,7 +22,7 @@ class SurveyReportAdmin(admin.ModelAdmin): ) list_display = ( - 'id', 'summary', 'created_at', 'state' + 'id', 'summary', 'created_at', 'report_state' ) actions = ['send_report'] @@ -81,6 +81,18 @@ class SurveyReportAdmin(admin.ModelAdmin): del actions['delete_selected'] return actions + def report_state(self, obj): + """ + Method to define the custom State column with the new "send" state, + to avoid modifying the current models. + """ + try: + if obj.surveyreportupload_set.last().is_uploaded(): + return "Sent" + except AttributeError: + return obj.state.capitalize() + report_state.short_description = 'State' + if settings.SURVEY_REPORT_ENABLE: admin.site.register(SurveyReport, SurveyReportAdmin) diff --git a/openedx/features/survey_report/templates/survey_report/change_list.html b/openedx/features/survey_report/templates/survey_report/change_list.html index c4c0ebcb67..2cd947273e 100644 --- a/openedx/features/survey_report/templates/survey_report/change_list.html +++ b/openedx/features/survey_report/templates/survey_report/change_list.html @@ -5,7 +5,7 @@
  • {% csrf_token %} - +