feat: add state sent to state column (#34127)
This commit is contained in:
committed by
GitHub
parent
3bf3aeaf31
commit
4b7ef2697e
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user