Commit a741e6a3 by Renzo Lucioni

Merge pull request #5086 from edx/renzo/fix-embargo-middleware

Refrain from accessing country code if country is None
parents f50b2a7b c3359135
...@@ -166,7 +166,7 @@ class EmbargoMiddleware(object): ...@@ -166,7 +166,7 @@ class EmbargoMiddleware(object):
profile_country = cache.get(cache_key) profile_country = cache.get(cache_key)
if profile_country is None: if profile_country is None:
profile = getattr(user, 'profile', None) profile = getattr(user, 'profile', None)
if profile is not None: if profile is not None and profile.country is not None:
profile_country = profile.country.code.upper() profile_country = profile.country.code.upper()
else: else:
profile_country = "" profile_country = ""
......
...@@ -219,6 +219,7 @@ class EmbargoMiddlewareTests(ModuleStoreTestCase): ...@@ -219,6 +219,7 @@ class EmbargoMiddlewareTests(ModuleStoreTestCase):
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
@ddt.data( @ddt.data(
(None, False),
("", False), ("", False),
("us", False), ("us", False),
("CU", True), ("CU", True),
......
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