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 ...@@ -9,6 +9,7 @@ from opaque_keys.edx import locator
from pytz import UTC from pytz import UTC
import unittest import unittest
import ddt import ddt
from shoppingcart.models import DonationConfiguration
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
...@@ -124,7 +125,7 @@ class TestRecentEnrollments(ModuleStoreTestCase): ...@@ -124,7 +125,7 @@ class TestRecentEnrollments(ModuleStoreTestCase):
self._configure_message_timeout(600) self._configure_message_timeout(600)
self.client.login(username=self.student.username, password=self.PASSWORD) self.client.login(username=self.student.username, password=self.PASSWORD)
response = self.client.get(reverse("dashboard")) response = self.client.get(reverse("dashboard"))
self.assertContains(response, "You have successfully enrolled in") self.assertContains(response, "Thank you for enrolling in")
@ddt.data( @ddt.data(
(['audit', 'honor', 'verified'], False), (['audit', 'honor', 'verified'], False),
...@@ -139,6 +140,9 @@ class TestRecentEnrollments(ModuleStoreTestCase): ...@@ -139,6 +140,9 @@ class TestRecentEnrollments(ModuleStoreTestCase):
# Enable the enrollment success message # Enable the enrollment success message
self._configure_message_timeout(10000) self._configure_message_timeout(10000)
# Enable donations
DonationConfiguration(enabled=True).save()
# Create the course mode(s) # Create the course mode(s)
for mode in course_modes: for mode in course_modes:
CourseModeFactory(mode_slug=mode, course_id=self.course.id) CourseModeFactory(mode_slug=mode, course_id=self.course.id)
......
...@@ -72,6 +72,7 @@ import external_auth.views ...@@ -72,6 +72,7 @@ import external_auth.views
from bulk_email.models import Optout, CourseAuthorization from bulk_email.models import Optout, CourseAuthorization
import shoppingcart import shoppingcart
from shoppingcart.models import DonationConfiguration
from user_api.models import UserPreference from user_api.models import UserPreference
from lang_pref import LANGUAGE_KEY from lang_pref import LANGUAGE_KEY
...@@ -645,14 +646,14 @@ def _create_recent_enrollment_message(course_enrollment_pairs, course_modes): ...@@ -645,14 +646,14 @@ def _create_recent_enrollment_message(course_enrollment_pairs, course_modes):
{ {
"course_id": course.id, "course_id": course.id,
"course_name": course.display_name, "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 for course in recently_enrolled_courses
] ]
return render_to_string( return render_to_string(
'enrollment/course_enrollment_message.html', '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): ...@@ -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): def try_change_enrollment(request):
""" """
This method calls change_enrollment if the necessary POST This method calls change_enrollment if the necessary POST
......
...@@ -100,8 +100,8 @@ var edx = edx || {}; ...@@ -100,8 +100,8 @@ var edx = edx || {};
var html = _.template($("#donation-tpl").html(), {}); var html = _.template($("#donation-tpl").html(), {});
this.$el.html(html); this.$el.html(html);
this.$amount = $("input[name=\"amount\"]", this.$el); this.$amount = $("input[name=\"amount\"]", this.$el);
this.$submit = $("input[type=\"submit\"]", this.$el); this.$submit = $(".action-donate", this.$el);
this.$errorMsg = $(".payment-form", this.$el); this.$errorMsg = $(".donation-error-msg", this.$el);
this.$paymentForm = $(".payment-form", this.$el); this.$paymentForm = $(".payment-form", this.$el);
this.$submit.click(this.donate); this.$submit.click(this.donate);
return this; return this;
...@@ -179,6 +179,7 @@ var edx = edx || {}; ...@@ -179,6 +179,7 @@ var edx = edx || {};
return isValid; return isValid;
}, },
/** /**
* Validate that the given amount is a valid currency string. * Validate that the given amount is a valid currency string.
* *
......
...@@ -1153,7 +1153,6 @@ ...@@ -1153,7 +1153,6 @@
.wrapper-msg { .wrapper-msg {
padding-bottom: 0; padding-bottom: 0;
}
.msg { .msg {
@include clearfix(); @include clearfix();
...@@ -1170,6 +1169,54 @@ ...@@ -1170,6 +1169,54 @@
text-transform: none; text-transform: none;
letter-spacing: 0; 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 {
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 @@ ...@@ -9,7 +9,7 @@
<h2 class="title">${_("You need to re-verify to continue")}</h2> <h2 class="title">${_("You need to re-verify to continue")}</h2>
<div class="copy"> <div class="copy">
<p class="activation-message"> <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> </p>
<ul class="reverify-list"> <ul class="reverify-list">
% for item in reverifications["must_reverify"]: % for item in reverifications["must_reverify"]:
......
<form class="donate-form"> <div class="donation-error-msg" />
<input type="text" name="amount" value="25.00" /> <form class="nav-item donate-form">
<input type="submit" name="Donate" value="<%- gettext('Donate') %>" /> <span class="monetary-symbol">$</span>
<div class="donation-error-msg" /> <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>
<form class="payment-form"></form> <form class="payment-form"></form>
<%! from django.utils.translation import ugettext as _ %> <%! from django.utils.translation import ugettext as _ %>
% for course_msg in course_enrollment_messages: % for course_msg in course_enrollment_messages:
<div class="wrapper-msg urgency-high"> <div class="wrapper-msg urgency-high">
<div class="msg"> <div class="msg has-actions">
<div class="msg-content"> <div class="msg-content donate-content">
<h2 class="sr">${_("Enrollment Successful")}</h2> <h2 class="sr">${_("Enrollment Successful")}</h2>
<div class="copy"> <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"]: % 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 % endif
</div> </div>
</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>
</div> </div>
% endfor % 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