From 674bf2a040aa97fd2b98b8a513b0ec592fbeec8f Mon Sep 17 00:00:00 2001 From: Alejandro Cardenas Date: Tue, 7 Mar 2023 09:32:44 -0500 Subject: [PATCH] feat: add send survey report button (#31821) * feat: add send report button * fix: solve quality test issues * feat: add admin action to send report * style: fix pylint issues * style: fix pylint issues * fix: update openedx/features/survey_report/urls.py Co-authored-by: Maria Grimaldi * refactor: rename selected variable and move actions variable --------- Co-authored-by: Maria Grimaldi --- openedx/features/survey_report/admin.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/openedx/features/survey_report/admin.py b/openedx/features/survey_report/admin.py index 368159a08d..f2a422de2e 100644 --- a/openedx/features/survey_report/admin.py +++ b/openedx/features/survey_report/admin.py @@ -5,6 +5,7 @@ Django Admin page for SurveyReport. from django.contrib import admin from .models import SurveyReport +from .api import send_report_to_external_api class SurveyReportAdmin(admin.ModelAdmin): @@ -23,6 +24,17 @@ class SurveyReportAdmin(admin.ModelAdmin): 'id', 'summary', 'created_at', 'state' ) + actions = ['send_report'] + + @admin.action(description='Send report to external API') + def send_report(self, request, queryset): + """ + Add custom actions to send the reports to the external API. + """ + selected_reports = queryset.values_list('id', flat=True) + for report_id in selected_reports: + send_report_to_external_api(report_id=report_id) + def summary(self, obj) -> str: """ Show a summary of the survey report.