diff --git a/api/waffle/utils.py b/api/waffle/utils.py index 9b6236e9a2e0..cf6c5a23bf0a 100644 --- a/api/waffle/utils.py +++ b/api/waffle/utils.py @@ -2,7 +2,7 @@ from framework.auth.core import _get_current_user from osf import features -from flask import request +import flask class MockUser(object): @@ -14,17 +14,19 @@ def flag_is_active(request, flag_name): This function changes the typical flask request object so it can be used by django-waffle. Other modifications for django-waffle can be found in the __call__ method of OsfWebRenderer. :param flask request object: - :return flask request object: + :param flag name string: + :return bool: """ - # Waffle does not enjoy NoneTypes as user values. - request.user = _get_current_user() or MockUser() - request.COOKIES = getattr(request, 'cookies', None) + if isinstance(request, flask.Request): + # Waffle does not enjoy NoneTypes as user values. + request.user = _get_current_user() or MockUser() + request.COOKIES = getattr(request, 'cookies', None) return waffle.flag_is_active(request, flag_name) def storage_i18n_flag_active(): - return flag_is_active(request, features.STORAGE_I18N) + return flag_is_active(flask.request, features.STORAGE_I18N) def storage_usage_flag_active(): - return flag_is_active(request, features.STORAGE_USAGE) + return flag_is_active(flask.request, features.STORAGE_USAGE)