Esempio n. 1
0
def add_missing_price_information_message(request, item):
    """
    Add a message to the Django messages store indicating that we failed to retrieve price information about an item.

    :param request: The current request.
    :param item: The item for which price information is missing. Example: a program title, or a course.
    """
    messages.warning(
        request,
        _(
            '{strong_start}We could not gather price information for {em_start}{item}{em_end}.{strong_end} '
            '{span_start}If you continue to have these issues, please contact '
            '{link_start}{platform_name} support{link_end}.{span_end}'
        ).format(
            item=item,
            em_start='<em>',
            em_end='</em>',
            link_start='<a href="{support_link}" target="_blank">'.format(
                support_link=get_configuration_value(
                    'ENTERPRISE_SUPPORT_URL',
                    getattr(settings, 'ENTERPRISE_SUPPORT_URL', '')  # Remove the `getattr` when setting is upstreamed.
                ),
            ),
            platform_name=get_configuration_value('PLATFORM_NAME', settings.PLATFORM_NAME),
            link_end='</a>',
            span_start='<span>',
            span_end='</span>',
            strong_start='<strong>',
            strong_end='</strong>',
        )
    )
Esempio n. 2
0
def add_consent_declined_message(request, enterprise_customer, item):
    """
    Add a message to the Django messages store indicating that the user has declined data sharing consent.

    Arguments:
        request (HttpRequest): The current request.
        enterprise_customer (EnterpriseCustomer): The EnterpriseCustomer associated with this request.
        item (str): A string containing information about the item for which consent was declined.
    """
    messages.warning(
        request,
        _(
            '{strong_start}We could not enroll you in {em_start}{item}{em_end}.{strong_end} '
            '{span_start}If you have questions or concerns about sharing your data, please contact your learning '
            'manager at {enterprise_customer_name}, or contact {link_start}{platform_name} support{link_end}.{span_end}'
        ).format(
            item=item,
            em_start='<em>',
            em_end='</em>',
            enterprise_customer_name=enterprise_customer.name,
            link_start='<a href="{support_link}" target="_blank">'.format(
                support_link=get_configuration_value(
                    'ENTERPRISE_SUPPORT_URL',
                    getattr(settings, 'ENTERPRISE_SUPPORT_URL', '')  # Remove the `getattr` when setting is upstreamed.
                ),
            ),
            platform_name=get_configuration_value('PLATFORM_NAME', settings.PLATFORM_NAME),
            link_end='</a>',
            span_start='<span>',
            span_end='</span>',
            strong_start='<strong>',
            strong_end='</strong>',
        )
    )
Esempio n. 3
0
 def test_get_configuration_value_with_openedx(self, config_mock):
     """
     ``get_configuration_value`` returns the appropriate non-default value when connected to Open edX.
     """
     config_mock.get_value.return_value = 'value'
     assert utils.get_configuration_value('value',
                                          default='default') == 'value'
Esempio n. 4
0
 def test_get_configuration_value_url_type(self, get_url_mock):
     """
     ``get_configuration_value`` returns the appropriate non-default value for URL types when in Open edX.
     """
     get_url_mock.return_value = 'value'
     assert utils.get_configuration_value('value',
                                          default='default',
                                          type='url') == 'value'
Esempio n. 5
0
 def test_get_configuration_value_without_openedx(self):
     """
     ``get_configuration_value`` returns a default value of 'default' when not connected to Open edX.
     """
     assert utils.get_configuration_value('value',
                                          default='default') == 'default'