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 <maria.grimaldi@edunext.co> * refactor: rename selected variable and move actions variable --------- Co-authored-by: Maria Grimaldi <maria.grimaldi@edunext.co>
This commit is contained in:
committed by
GitHub
parent
0f02c7b3d9
commit
674bf2a040
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user