diff --git a/cms/envs/common.py b/cms/envs/common.py index 58909c024a48946989aba75e47826513c8c862e2..858de4e03cf4741e7502ffacdd1e2539f652a5be 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -85,10 +85,10 @@ FEATURES = { # Hide any Personally Identifiable Information from application logs 'SQUELCH_PII_IN_LOGS': False, - # Toggles embargo functionality + # Toggles the embargo functionality, which enable embargoing for particular courses 'EMBARGO': False, - # Toggle embargo site functionality + # Toggles the embargo site functionality, which enable embargoing for the whole site 'SITE_EMBARGOED': False, # Turn on/off Microsites feature @@ -305,6 +305,9 @@ LOCALE_PATHS = (REPO_ROOT + '/conf/locale',) # edx-platform/conf/locale/ # Messages MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage' +##### EMBARGO ##### +EMBARGO_SITE_REDIRECT_URL = None + ############################### Pipeline ####################################### STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' diff --git a/common/djangoapps/embargo/middleware.py b/common/djangoapps/embargo/middleware.py index 6eb9af373a3e3cc01a01f9e0d4cf51aaa978b9ac..052c04bdbce29eb4820b95e66484f86ccf4b1057 100644 --- a/common/djangoapps/embargo/middleware.py +++ b/common/djangoapps/embargo/middleware.py @@ -18,13 +18,13 @@ Usage: # Enable the middleware in your settings -# To enable Embargoing by courses, add: +# To enable Embargo for particular courses, set: FEATURES['EMBARGO'] = True # blocked ip will be redirected to /embargo -# To enable Embargoing site: +# To enable the Embargo feature for the whole site, set: FEATURES['SITE_EMBARGOED'] = True -# With SITE_EMBARGOED, you can define an external to redirect with: +# With SITE_EMBARGOED, you can define an external url to redirect with: EMBARGO_SITE_REDIRECT_URL = 'https://www.edx.org/' # if EMBARGO_SITE_REDIRECT_URL is missing, a HttpResponseForbidden is returned. diff --git a/common/djangoapps/embargo/models.py b/common/djangoapps/embargo/models.py index a48e39f1f24629ed4414026165ee327065435d9c..677d174ccb7a560475341666b6b94ef43e994563 100644 --- a/common/djangoapps/embargo/models.py +++ b/common/djangoapps/embargo/models.py @@ -92,7 +92,7 @@ class IPFilter(ConfigurationModel): def __iter__(self): for network in self.networks: - yield network + yield network def __contains__(self, ip): try: diff --git a/common/djangoapps/embargo/tests/test_forms.py b/common/djangoapps/embargo/tests/test_forms.py index dc14515474ea5e94c92cf36f5ee6a4b659bbc7aa..21a6c37054d56f5390b45ddaee066dbbd8c5f5c2 100644 --- a/common/djangoapps/embargo/tests/test_forms.py +++ b/common/djangoapps/embargo/tests/test_forms.py @@ -171,16 +171,16 @@ class IPFilterFormTest(TestCase): # Network tests # ips not in whitelist network - for addr in '1.1.0.2, 1.0.1.0'.split(','): + for addr in ['1.1.0.2', '1.0.1.0']: self.assertNotIn(addr.strip(), whitelist) # ips in whitelist network - for addr in '1.1.0.1, 1.0.0.100'.split(','): + for addr in ['1.1.0.1', '1.0.0.100']: self.assertIn(addr.strip(), whitelist) # ips not in blacklist network - for addr in '2.0.0.0, 1.1.0.0'.split(','): + for addr in ['2.0.0.0', '1.1.0.0']: self.assertNotIn(addr.strip(), blacklist) # ips in blacklist network - for addr in '1.0.100.0, 1.0.0.10'.split(','): + for addr in ['1.0.100.0', '1.0.0.10']: self.assertIn(addr.strip(), blacklist) # Test clearing by adding an empty list is OK too diff --git a/common/djangoapps/embargo/tests/test_models.py b/common/djangoapps/embargo/tests/test_models.py index fb2e4c89c28ae7ae04c90c2178804e11678358c3..8f9dc5d9300ccea6a83f950e2e30ea7008b84c0e 100644 --- a/common/djangoapps/embargo/tests/test_models.py +++ b/common/djangoapps/embargo/tests/test_models.py @@ -79,7 +79,7 @@ class EmbargoModelsTest(TestCase): cblacklist = IPFilter.current().blacklist_ips self.assertTrue(blacklist in cblacklist) - # network tests + def test_ip_network_blocking(self): whitelist = '1.0.0.0/24' blacklist = '1.1.0.0/16' diff --git a/lms/envs/common.py b/lms/envs/common.py index 24eafabc66a0d52e0e11eee2fe1149828e7b551f..9e6bf06714bca561717708b3e4246a3084a89094 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -225,10 +225,10 @@ FEATURES = { # Hide any Personally Identifiable Information from application logs 'SQUELCH_PII_IN_LOGS': False, - # Toggle embargo functionality + # Toggles the embargo functionality, which enable embargoing for particular courses 'EMBARGO': False, - # Toggle embargo site functionality + # Toggles the embargo site functionality, which enable embargoing for the whole site 'SITE_EMBARGOED': False, # Whether the Wiki subsystem should be accessible via the direct /wiki/ paths. Setting this to True means @@ -680,6 +680,9 @@ ZENDESK_URL = None ZENDESK_USER = None ZENDESK_API_KEY = None +##### EMBARGO ##### +EMBARGO_SITE_REDIRECT_URL = None + ##### shoppingcart Payment ##### PAYMENT_SUPPORT_EMAIL = 'payment@example.com' ##### Using cybersource by default #####