Merge pull request #5526 from edx/sanchez/style-donation-button
Adding new styles to the new donation button.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user