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

Refrain from accessing country code if country is None
This commit is contained in:
Renzo Lucioni
2014-09-05 11:44:45 -04:00
2 changed files with 2 additions and 1 deletions

View File

@@ -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 = ""

View File

@@ -219,6 +219,7 @@ class EmbargoMiddlewareTests(ModuleStoreTestCase):
self.assertEqual(response.status_code, 200)
@ddt.data(
(None, False),
("", False),
("us", False),
("CU", True),