From 00630cf22dd341a8bc607a68691d0cfcd46e999c Mon Sep 17 00:00:00 2001 From: Asespinel <79876430+Asespinel@users.noreply.github.com> Date: Tue, 16 Jan 2024 16:25:05 -0500 Subject: [PATCH] =?UTF-8?q?refactor:=20changed=20survey=20report=20message?= =?UTF-8?q?=20location=20and=20added=20a=20new=20info=E2=80=A6=20(#34033)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: changed survey report message location and added a new informative sent state * chore: added Generate and Send text on button * chore: added comment to new state column and added reference to static jquery. * fix: fixed non Attribute error when a report hasn't been sent yet --- lms/templates/admin/base_site.html | 4 ++-- openedx/features/survey_report/admin.py | 14 +++++++++++++- .../templates/survey_report/admin_banner.html | 2 ++ .../templates/survey_report/change_list.html | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lms/templates/admin/base_site.html b/lms/templates/admin/base_site.html index fa93f9c3e84a..2dfd0bef7a50 100644 --- a/lms/templates/admin/base_site.html +++ b/lms/templates/admin/base_site.html @@ -21,6 +21,6 @@

{{ site_header|default:_('D {% endblock %} -{% block header %}{{ block.super }} +{% 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 f2a422de2ef8..8d4652282b5f 100644 --- a/openedx/features/survey_report/admin.py +++ b/openedx/features/survey_report/admin.py @@ -21,7 +21,7 @@ class SurveyReportAdmin(admin.ModelAdmin): ) list_display = ( - 'id', 'summary', 'created_at', 'state' + 'id', 'summary', 'created_at', 'report_state' ) actions = ['send_report'] @@ -80,4 +80,16 @@ def get_actions(self, request): 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' + admin.site.register(SurveyReport, SurveyReportAdmin) diff --git a/openedx/features/survey_report/templates/survey_report/admin_banner.html b/openedx/features/survey_report/templates/survey_report/admin_banner.html index 6a8e2ea92e8c..e881966f146f 100644 --- a/openedx/features/survey_report/templates/survey_report/admin_banner.html +++ b/openedx/features/survey_report/templates/survey_report/admin_banner.html @@ -1,5 +1,6 @@ {% block survey_report_banner %} {% if show_survey_report_banner %} +{% load static %}

Join the Open edX Data Sharing Initiative and shape the future of learning

@@ -31,6 +32,7 @@

Join the Open edX Data Sh {% endif %} +