Commit 877ec3f9 by Alan Boudreault

some minor improvements to embargo

parent db161543
...@@ -85,10 +85,10 @@ FEATURES = { ...@@ -85,10 +85,10 @@ FEATURES = {
# Hide any Personally Identifiable Information from application logs # Hide any Personally Identifiable Information from application logs
'SQUELCH_PII_IN_LOGS': False, 'SQUELCH_PII_IN_LOGS': False,
# Toggles embargo functionality # Toggles the embargo functionality, which enable embargoing for particular courses
'EMBARGO': False, 'EMBARGO': False,
# Toggle embargo site functionality # Toggles the embargo site functionality, which enable embargoing for the whole site
'SITE_EMBARGOED': False, 'SITE_EMBARGOED': False,
# Turn on/off Microsites feature # Turn on/off Microsites feature
...@@ -305,6 +305,9 @@ LOCALE_PATHS = (REPO_ROOT + '/conf/locale',) # edx-platform/conf/locale/ ...@@ -305,6 +305,9 @@ LOCALE_PATHS = (REPO_ROOT + '/conf/locale',) # edx-platform/conf/locale/
# Messages # Messages
MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage' MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
##### EMBARGO #####
EMBARGO_SITE_REDIRECT_URL = None
############################### Pipeline ####################################### ############################### Pipeline #######################################
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
......
...@@ -18,13 +18,13 @@ Usage: ...@@ -18,13 +18,13 @@ Usage:
# Enable the middleware in your settings # 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 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 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/' EMBARGO_SITE_REDIRECT_URL = 'https://www.edx.org/'
# if EMBARGO_SITE_REDIRECT_URL is missing, a HttpResponseForbidden is returned. # if EMBARGO_SITE_REDIRECT_URL is missing, a HttpResponseForbidden is returned.
......
...@@ -92,7 +92,7 @@ class IPFilter(ConfigurationModel): ...@@ -92,7 +92,7 @@ class IPFilter(ConfigurationModel):
def __iter__(self): def __iter__(self):
for network in self.networks: for network in self.networks:
yield network yield network
def __contains__(self, ip): def __contains__(self, ip):
try: try:
......
...@@ -171,16 +171,16 @@ class IPFilterFormTest(TestCase): ...@@ -171,16 +171,16 @@ class IPFilterFormTest(TestCase):
# Network tests # Network tests
# ips not in whitelist network # 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) self.assertNotIn(addr.strip(), whitelist)
# ips in whitelist network # 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) self.assertIn(addr.strip(), whitelist)
# ips not in blacklist network # 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) self.assertNotIn(addr.strip(), blacklist)
# ips in blacklist network # 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) self.assertIn(addr.strip(), blacklist)
# Test clearing by adding an empty list is OK too # Test clearing by adding an empty list is OK too
......
...@@ -79,7 +79,7 @@ class EmbargoModelsTest(TestCase): ...@@ -79,7 +79,7 @@ class EmbargoModelsTest(TestCase):
cblacklist = IPFilter.current().blacklist_ips cblacklist = IPFilter.current().blacklist_ips
self.assertTrue(blacklist in cblacklist) self.assertTrue(blacklist in cblacklist)
# network tests def test_ip_network_blocking(self):
whitelist = '1.0.0.0/24' whitelist = '1.0.0.0/24'
blacklist = '1.1.0.0/16' blacklist = '1.1.0.0/16'
......
...@@ -225,10 +225,10 @@ FEATURES = { ...@@ -225,10 +225,10 @@ FEATURES = {
# Hide any Personally Identifiable Information from application logs # Hide any Personally Identifiable Information from application logs
'SQUELCH_PII_IN_LOGS': False, 'SQUELCH_PII_IN_LOGS': False,
# Toggle embargo functionality # Toggles the embargo functionality, which enable embargoing for particular courses
'EMBARGO': False, 'EMBARGO': False,
# Toggle embargo site functionality # Toggles the embargo site functionality, which enable embargoing for the whole site
'SITE_EMBARGOED': False, 'SITE_EMBARGOED': False,
# Whether the Wiki subsystem should be accessible via the direct /wiki/ paths. Setting this to True means # Whether the Wiki subsystem should be accessible via the direct /wiki/ paths. Setting this to True means
...@@ -680,6 +680,9 @@ ZENDESK_URL = None ...@@ -680,6 +680,9 @@ ZENDESK_URL = None
ZENDESK_USER = None ZENDESK_USER = None
ZENDESK_API_KEY = None ZENDESK_API_KEY = None
##### EMBARGO #####
EMBARGO_SITE_REDIRECT_URL = None
##### shoppingcart Payment ##### ##### shoppingcart Payment #####
PAYMENT_SUPPORT_EMAIL = 'payment@example.com' PAYMENT_SUPPORT_EMAIL = 'payment@example.com'
##### Using cybersource by default ##### ##### Using cybersource by default #####
......
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