feat: add state sent to state column (#34127)

This commit is contained in:
Alejandro Cardenas
2024-01-30 15:14:14 -05:00
committed by GitHub
parent 3bf3aeaf31
commit 4b7ef2697e
2 changed files with 14 additions and 2 deletions

View File

@@ -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)

View File

@@ -5,7 +5,7 @@
<li>
<form method="POST" action="{% url 'openedx.generate_survey_report' %}" class="inline">
{% csrf_token %}
<input type="submit" value="Generate Report" class="default" name="_generatereport">
<input type="submit" value="Generate and Send Report" class="default" name="_sendreport">
</form>
</li>
</ul>