diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index 89dd470440..34d3d4c9b1 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -72,6 +72,7 @@ import external_auth.views from bulk_email.models import Optout, CourseAuthorization import shoppingcart +from shoppingcart.models import DonationConfiguration from user_api.models import UserPreference from lang_pref import LANGUAGE_KEY @@ -645,14 +646,14 @@ def _create_recent_enrollment_message(course_enrollment_pairs, course_modes): { "course_id": course.id, "course_name": course.display_name, - "allow_donation": not CourseMode.has_verified_mode(course_modes[course.id]) + "allow_donation": _allow_donation(course_modes, course.id) } for course in recently_enrolled_courses ] return render_to_string( 'enrollment/course_enrollment_message.html', - {'course_enrollment_messages': messages} + {'course_enrollment_messages': messages, 'platform_name': settings.PLATFORM_NAME} ) @@ -678,6 +679,22 @@ def _get_recently_enrolled_courses(course_enrollment_pairs): ] +def _allow_donation(course_modes, course_id): + """Determines if the dashboard will request donations for the given course. + + Check if donations are configured for the platform, and if the current course is accepting donations. + + Args: + course_modes (dict): Mapping of course ID's to course mode dictionaries. + course_id (str): The unique identifier for the course. + + Returns: + True if the course is allowing donations. + + """ + return DonationConfiguration.current().enabled and not CourseMode.has_verified_mode(course_modes[course_id]) + + def try_change_enrollment(request): """ This method calls change_enrollment if the necessary POST diff --git a/lms/static/js/dashboard/donation.js b/lms/static/js/dashboard/donation.js index d4f25c38ac..1613bcc9cf 100644 --- a/lms/static/js/dashboard/donation.js +++ b/lms/static/js/dashboard/donation.js @@ -100,8 +100,8 @@ var edx = edx || {}; var html = _.template($("#donation-tpl").html(), {}); this.$el.html(html); this.$amount = $("input[name=\"amount\"]", this.$el); - this.$submit = $("input[type=\"submit\"]", this.$el); - this.$errorMsg = $(".payment-form", this.$el); + this.$submit = $("button[type=\"submit\"]", this.$el); + this.$errorMsg = $(".donation-error-msg", this.$el); this.$paymentForm = $(".payment-form", this.$el); this.$submit.click(this.donate); return this; @@ -179,6 +179,7 @@ var edx = edx || {}; return isValid; }, + /** * Validate that the given amount is a valid currency string. * diff --git a/lms/static/sass/multicourse/_dashboard.scss b/lms/static/sass/multicourse/_dashboard.scss index f669f65966..adcbf7fdbe 100644 --- a/lms/static/sass/multicourse/_dashboard.scss +++ b/lms/static/sass/multicourse/_dashboard.scss @@ -1153,22 +1153,69 @@ .wrapper-msg { padding-bottom: 0; - } - .msg { - @include clearfix(); - font-family: $sans-serif; - padding-bottom: $baseline; - border-bottom: thin solid $gray; + .msg { + @include clearfix(); + font-family: $sans-serif; + padding-bottom: $baseline; + border-bottom: thin solid $gray; - &.title { - @extend %t-title5; - @extend %t-weight4; - font-family: $f-sans-serif; + &.title { + @extend %t-title5; + @extend %t-weight4; + font-family: $f-sans-serif; - // Overriding Platform h2 styles - text-transform: none; - letter-spacing: 0; + // Overriding Platform h2 styles + text-transform: none; + letter-spacing: 0; + } + + &.has-actions { + + .donate-content { + width: flex-grid(8, 12); + } + + .donate-actions { + width: flex-grid(4, 12); + vertical-align: bottom; + display: inline-block; + + .monetary-symbol { + vertical-align: middle; + color: $white; + font-weight: 600; + } + + .amount { + padding: $baseline ($baseline/2); + width: 80px; + vertical-align: middle; + text-align: left; + border: 2px; + + &.validation-error { + border: 2px solid $pink; + } + } + + .action-donate { + @extend %btn-primary-blue; + vertical-align: middle; + padding-top: ($baseline/2); + padding-bottom: ($baseline/2); + text-shadow: none; + text-transform: none; + letter-spacing: 0; + color: $white; + font-weight: 600; + } + + .donation-error-msg { + padding: ($baseline/2) 0; + } + } + } } } } diff --git a/lms/templates/dashboard/_dashboard_prompt_midcourse_reverify.html b/lms/templates/dashboard/_dashboard_prompt_midcourse_reverify.html index 9a28db1b7c..ae56569a26 100644 --- a/lms/templates/dashboard/_dashboard_prompt_midcourse_reverify.html +++ b/lms/templates/dashboard/_dashboard_prompt_midcourse_reverify.html @@ -9,7 +9,7 @@
${_("You have successfully enrolled in {enrolled_course}.").format(enrolled_course=course_msg["course_name"])}
- +${_("Thank you for enrolling in {enrolled_course}. We hope you enjoy the course.").format(enrolled_course=course_msg["course_name"])}
% if course_msg["allow_donation"]: - ++ ${_("{platform_name} is a nonprofit bringing high-quality education to everyone, everywhere. " + "Your help allows us to continuously improve the learning experience for millions and " + "make a better future one learner at a time.").format(platform_name=platform_name)} +
% endif