mattdrayer: Add microsite settings overrides

This commit is contained in:
Matt Drayer
2016-04-25 17:09:11 -04:00
parent f53b900f06
commit fdd045b108

View File

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