Add convenience functions for Entitlement Support Tool

Adds getter for ecommerce order dashboard url and for getting
the entitlement support details reasons.

Learner-3925
This commit is contained in:
Michael LoTurco
2018-02-28 10:45:43 -05:00
parent 229d3b81cb
commit a4f294b441
4 changed files with 30 additions and 0 deletions

View File

@@ -464,3 +464,17 @@ class CourseEntitlementSupportDetail(TimeStampedModel):
self.support_user,
self.reason,
)
@classmethod
def get_support_actions_list(cls):
"""
Method for retrieving a serializable version of the entitlement support reasons
Returns
list: Containing the possible support actions
"""
return [
action[0] # get just the action code, not the human readable description.
for action
in cls.ENTITLEMENT_SUPPORT_ACTIONS
]

View File

@@ -15,6 +15,7 @@ class CommerceConfiguration(ConfigurationModel):
API_NAME = 'commerce'
CACHE_KEY = 'commerce.api.data'
DEFAULT_RECEIPT_PAGE_URL = '/checkout/receipt/?order_number='
DEFAULT_ORDER_DASHBOARD_URL = '/dashboard/orders/'
MULTIPLE_ITEMS_BASKET_PAGE_URL = '/basket/add/'
checkout_on_ecommerce_service = models.BooleanField(

View File

@@ -102,6 +102,13 @@ class EcommerceServiceTests(TestCase):
expected_url = 'http://ecommerce_url/checkout/receipt/?order_number={}'.format(order_number)
self.assertEqual(url, expected_url)
@override_settings(ECOMMERCE_PUBLIC_URL_ROOT='http://ecommerce_url')
def test_get_order_dashboard_url(self):
"""Verify that the proper order dashboard url is returned."""
url = EcommerceService().get_order_dashboard_url()
expected_url = 'http://ecommerce_url/dashboard/orders/'
self.assertEqual(url, expected_url)
@override_settings(ECOMMERCE_PUBLIC_URL_ROOT='http://ecommerce_url')
@ddt.data(['TESTSKU'], ['TESTSKU1', 'TESTSKU2', 'TESTSKU3'])
def test_get_checkout_page_url(self, skus):

View File

@@ -55,6 +55,14 @@ class EcommerceService(object):
"""
return urljoin(self.ecommerce_url_root, ecommerce_page_url)
def get_order_dashboard_url(self):
""" Return the URL to the ecommerce dashboard orders page.
Returns:
String: order dashboard url.
"""
return self.get_absolute_ecommerce_url(CommerceConfiguration.DEFAULT_ORDER_DASHBOARD_URL)
def get_receipt_page_url(self, order_number):
"""
Gets the URL for the Order Receipt page hosted by the ecommerce service.