From 7efc777a3e65d28d76525d4960e73bf9adf22621 Mon Sep 17 00:00:00 2001 From: Andres Espinel Date: Fri, 12 Jan 2024 14:13:30 -0500 Subject: [PATCH] fix: fixed non Attribute error when a report hasn't been sent yet --- lms/templates/admin/base_site.html | 2 +- openedx/features/survey_report/admin.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lms/templates/admin/base_site.html b/lms/templates/admin/base_site.html index e274c8e006b7..2dfd0bef7a50 100644 --- a/lms/templates/admin/base_site.html +++ b/lms/templates/admin/base_site.html @@ -23,4 +23,4 @@

{{ site_header|default:_('D {% block messages %}{{ block.super }} {% include "survey_report/admin_banner.html" %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/openedx/features/survey_report/admin.py b/openedx/features/survey_report/admin.py index 917a6e437f2e..8d4652282b5f 100644 --- a/openedx/features/survey_report/admin.py +++ b/openedx/features/survey_report/admin.py @@ -85,9 +85,11 @@ def report_state(self, obj): Method to define the custom State column with the new "send" state, to avoid modifying the current models. """ - if obj.surveyreportupload_set.last().is_uploaded(): - return "Sent" - return obj.state.capitalize() + try: + if obj.surveyreportupload_set.last().is_uploaded(): + return "Sent" + except AttributeError: + return obj.state.capitalize() report_state.short_description = 'State' admin.site.register(SurveyReport, SurveyReportAdmin)