Skip to content

Commit

Permalink
refactor: changed survey report message location and added a new info… (
Browse files Browse the repository at this point in the history
openedx#34033)

* 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
  • Loading branch information
Asespinel authored Jan 16, 2024
1 parent 73a446d commit 00630cf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lms/templates/admin/base_site.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ <h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('D

{% endblock %}

{% block header %}{{ block.super }}
{% block messages %}{{ block.super }}
{% include "survey_report/admin_banner.html" %}
{% endblock %}
{% endblock %}
14 changes: 13 additions & 1 deletion openedx/features/survey_report/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SurveyReportAdmin(admin.ModelAdmin):
)

list_display = (
'id', 'summary', 'created_at', 'state'
'id', 'summary', 'created_at', 'report_state'
)

actions = ['send_report']
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% block survey_report_banner %}
{% if show_survey_report_banner %}
{% load static %}
<div id="originalContent" style="border: 3px solid #06405d; margin-bottom: 50px; rgb(0 0 0 / 18%) 0px 3px 5px;">
<div style="background-color: #06405d;padding: 17px 37px;">
<h1 style="margin: 0; color: #FFFF; font-weight: 600;">Join the Open edX Data Sharing Initiative and shape the future of learning</h1>
Expand Down Expand Up @@ -31,6 +32,7 @@ <h1 style="margin: 0; color: #FFFF; font-weight: 600;">Join the Open edX Data Sh
{% endif %}

<!-- The original content of the block -->
<script type="text/javascript" src="{% static 'common/js/vendor/jquery.js' %}"></script>
<script>
$(document).ready(function(){
$('#dismissButton').click(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 00630cf

Please sign in to comment.