Commit c3359135 by Renzo Lucioni

Refrain from accessing country code if country is None

parent e0c3234f
......@@ -166,7 +166,7 @@ class EmbargoMiddleware(object):
profile_country = cache.get(cache_key)
if profile_country is 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()
else:
profile_country = ""
......
......@@ -219,6 +219,7 @@ class EmbargoMiddlewareTests(ModuleStoreTestCase):
self.assertEqual(response.status_code, 200)
@ddt.data(
(None, False),
("", False),
("us", False),
("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