Commit 7802c1ed by Stephen Sanchez

Merge pull request #5526 from edx/sanchez/style-donation-button

Adding new styles to the new donation button.
parents 5f73c178 12ffe180
......@@ -9,6 +9,7 @@ from opaque_keys.edx import locator
from pytz import UTC
import unittest
import ddt
from shoppingcart.models import DonationConfiguration
from student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
......@@ -124,7 +125,7 @@ class TestRecentEnrollments(ModuleStoreTestCase):
self._configure_message_timeout(600)
self.client.login(username=self.student.username, password=self.PASSWORD)
response = self.client.get(reverse("dashboard"))
self.assertContains(response, "You have successfully enrolled in")
self.assertContains(response, "Thank you for enrolling in")
@ddt.data(
(['audit', 'honor', 'verified'], False),
......@@ -139,6 +140,9 @@ class TestRecentEnrollments(ModuleStoreTestCase):
# Enable the enrollment success message
self._configure_message_timeout(10000)
# Enable donations
DonationConfiguration(enabled=True).save()
# Create the course mode(s)
for mode in course_modes:
CourseModeFactory(mode_slug=mode, course_id=self.course.id)
......
......@@ -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
......
......@@ -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 = $(".action-donate", 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.
*
......
......@@ -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;
}
&.has-actions {
.donate-content {
width: flex-grid(8, 12);
}
.donate-actions {
width: flex-grid(4, 12);
vertical-align: bottom;
display: inline-block;
// Overriding Platform h2 styles
text-transform: none;
letter-spacing: 0;
.monetary-symbol {
vertical-align: middle;
color: $white;
font-weight: 600;
}
.amount {
height: 40px;
width: 80px;
vertical-align: middle;
text-align: left;
border: 2px solid $white;
&.validation-error {
border: 2px solid $error-color;
}
}
.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;
}
}
}
}
}
}
......
......@@ -9,7 +9,7 @@
<h2 class="title">${_("You need to re-verify to continue")}</h2>
<div class="copy">
<p class="activation-message">
${_("To continue in the ID Verified track in the following courses, you need to re-verify your identity:")}
${_("People change, and each year we ask you to re-verify your identity for our verified certificates. Take a minute now to help us renew your identity.")}
</p>
<ul class="reverify-list">
% for item in reverifications["must_reverify"]:
......
<form class="donate-form">
<input type="text" name="amount" value="25.00" />
<input type="submit" name="Donate" value="<%- gettext('Donate') %>" />
<div class="donation-error-msg" />
<div class="donation-error-msg" />
<form class="nav-item donate-form">
<span class="monetary-symbol">$</span>
<input class="amount" type="text" name="amount" value="25" />
<button class="btn action-primary action-donate" type="submit" name="Donate"><%- gettext('Donate') %></button>
</form>
<form class="payment-form"></form>
\ No newline at end of file
<form class="payment-form"></form>
<%! from django.utils.translation import ugettext as _ %>
% for course_msg in course_enrollment_messages:
<div class="wrapper-msg urgency-high">
<div class="msg">
<div class="msg-content">
<div class="msg has-actions">
<div class="msg-content donate-content">
<h2 class="sr">${_("Enrollment Successful")}</h2>
<div class="copy">
<p>${_("You have successfully enrolled in {enrolled_course}.").format(enrolled_course=course_msg["course_name"])}</p>
<p>${_("Thank you for enrolling in {enrolled_course}. We hope you enjoy the course.").format(enrolled_course=course_msg["course_name"])}</p>
% if course_msg["allow_donation"]:
<div class="donate-container" data-course="${ course_msg['course_id'] }" />
<p>
${_("{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)}
</p>
% endif
</div>
</div>
% if course_msg["allow_donation"]:
<div class="nav-actions donate-actions">
<h3 class="sr">${_('Donation Actions')}</h3>
<div class="donate-container" data-course="${ course_msg['course_id'] }"></div>
</div>
% endif
</div>
</div>
% endfor
\ No newline at end of file
% endfor
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment