Commit f572bd9c by Matt Drayer Committed by Clinton Blackburn

mattdrayer: Add microsite settings overrides

parent 0f901857
...@@ -3,6 +3,8 @@ from django.conf import settings ...@@ -3,6 +3,8 @@ from django.conf import settings
from edx_rest_api_client.client import EdxRestApiClient from edx_rest_api_client.client import EdxRestApiClient
from eventtracking import tracker from eventtracking import tracker
from openedx.core.djangoapps.theming import helpers
ECOMMERCE_DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ" ECOMMERCE_DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
...@@ -23,14 +25,16 @@ def is_commerce_service_configured(): ...@@ -23,14 +25,16 @@ def is_commerce_service_configured():
Return a Boolean indicating whether or not configuration is present to use Return a Boolean indicating whether or not configuration is present to use
the external commerce service. the external commerce service.
""" """
return bool(settings.ECOMMERCE_API_URL and settings.ECOMMERCE_API_SIGNING_KEY) ecommerce_api_url = helpers.get_value("ECOMMERCE_API_URL", settings.ECOMMERCE_API_URL)
ecommerce_api_signing_key = helpers.get_value("ECOMMERCE_API_SIGNING_KEY", settings.ECOMMERCE_API_SIGNING_KEY)
return bool(ecommerce_api_url and ecommerce_api_signing_key)
def ecommerce_api_client(user): def ecommerce_api_client(user):
""" Returns an E-Commerce API client setup with authentication for the specified user. """ """ Returns an E-Commerce API client setup with authentication for the specified user. """
return EdxRestApiClient( return EdxRestApiClient(
settings.ECOMMERCE_API_URL, helpers.get_value("ECOMMERCE_API_URL", settings.ECOMMERCE_API_URL),
settings.ECOMMERCE_API_SIGNING_KEY, helpers.get_value("ECOMMERCE_API_SIGNING_KEY", settings.ECOMMERCE_API_SIGNING_KEY),
user.username, user.username,
user.profile.name if hasattr(user, 'profile') else None, user.profile.name if hasattr(user, 'profile') else None,
user.email, user.email,
......
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