forked from openedx-unsupported/ecommerce
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restricted paid mode courses options for honor mode only customers (#57)
- Loading branch information
Muhammad Haseeb
authored
Oct 28, 2020
1 parent
f02c97d
commit 82c9ae6
Showing
7 changed files
with
77 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = 'ecommerce.extensions.edly_ecommerce_app.apps.EdlyEcommerceAppConfig' # pragma: no cover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
20 changes: 20 additions & 0 deletions
20
ecommerce/extensions/edly_ecommerce_app/templatetags/edly_extras.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from django import template | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag(takes_context=True) | ||
def site_configuration_value(context, name): | ||
""" | ||
Retrieve Configuration value for the key specified as name argument. | ||
Arguments: | ||
context (dict): Context of current request. | ||
name (str): Name of the key for which to return configuration value. | ||
Returns: | ||
Configuration value for the given key or returns `None` if default is not available. | ||
""" | ||
request = context['request'] | ||
site_configuration = request.site.siteconfiguration | ||
return site_configuration.get_edly_configuration_value(name) |
26 changes: 26 additions & 0 deletions
26
ecommerce/extensions/edly_ecommerce_app/tests/test_templatetags.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from django.template import Context, Template | ||
|
||
from ecommerce.tests.testcases import TestCase | ||
|
||
|
||
class EdlyExtrasTests(TestCase): | ||
|
||
def setUp(self): | ||
super(EdlyExtrasTests, self).setUp() | ||
|
||
def test_site_configuration_value(self): | ||
""" | ||
Verify site configuration template tag returns correct value. | ||
""" | ||
expected_configuration_value = 'FAKE_VALUE' | ||
self.site.siteconfiguration.edly_client_theme_branding_settings['FAKE_KEY'] = expected_configuration_value | ||
self.site.siteconfiguration.save() | ||
|
||
template = Template( | ||
"{% load edly_extras %}" | ||
"{% site_configuration_value \"FAKE_KEY\" %}" | ||
) | ||
context = Context({'request': self.request}) | ||
assert template.render(context) == expected_configuration_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters