diff --git a/completion_aggregator/__init__.py b/completion_aggregator/__init__.py index 9da95ec3..e79ccd6a 100644 --- a/completion_aggregator/__init__.py +++ b/completion_aggregator/__init__.py @@ -4,6 +4,6 @@ from __future__ import absolute_import, unicode_literals -__version__ = '1.5.24' +__version__ = '2.0.0' default_app_config = 'completion_aggregator.apps.CompletionAggregatorAppConfig' # pylint: disable=invalid-name diff --git a/completion_aggregator/api/common.py b/completion_aggregator/api/common.py index 2a10d6b7..d61d47ef 100644 --- a/completion_aggregator/api/common.py +++ b/completion_aggregator/api/common.py @@ -86,21 +86,25 @@ class CompletionViewMixin(object): course_completion_serializer = None block_completion_serializer = None - @property - def authentication_classes(self): # pragma: no cover + def get_authenticators(self): # pragma: no cover """ Allow users authenticated via OAuth2 or normal session authentication. """ - from openedx.core.lib.api import authentication # pylint: disable=import-error + try: + from openedx.core.lib.api.authentication import OAuth2AuthenticationAllowInactiveUser # pylint: disable=import-error + from openedx.core.lib.api.authentication import SessionAuthenticationAllowInactiveUser # pylint: disable=import-error + except ImportError: + from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser # pylint: disable=import-error + try: from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication # pylint: disable=import-error except ImportError: from edx_rest_framework_extensions.authentication import JwtAuthentication # pylint: disable=import-error return [ - JwtAuthentication, - authentication.OAuth2AuthenticationAllowInactiveUser, - authentication.SessionAuthenticationAllowInactiveUser, + JwtAuthentication(), + OAuth2AuthenticationAllowInactiveUser(), + SessionAuthenticationAllowInactiveUser(), ] @property diff --git a/completion_aggregator/compat.py b/completion_aggregator/compat.py index 65619a3e..a311393c 100644 --- a/completion_aggregator/compat.py +++ b/completion_aggregator/compat.py @@ -69,7 +69,7 @@ def init_course_blocks(user, root_block_key): from openedx.core.djangoapps.content.block_structure.transformers import BlockStructureTransformers # pylint: disable=import-error transformers = BlockStructureTransformers( - get_course_block_access_transformers() + [AggregatorAnnotationTransformer()] + get_course_block_access_transformers(user) + [AggregatorAnnotationTransformer()] ) return get_course_blocks(user, root_block_key, transformers) diff --git a/tests/test_views.py b/tests/test_views.py index 1a11a83e..783e2939 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -200,9 +200,8 @@ def setUp(self): self.patch_object( CompletionViewMixin, - 'authentication_classes', - new_callable=PropertyMock, - return_value=[OAuth2Authentication, SessionAuthentication] + 'get_authenticators', + return_value=[OAuth2Authentication(), SessionAuthentication()] ) self.patch_object( CompletionViewMixin, @@ -1087,9 +1086,8 @@ def setUp(self): self.patch_object( CompletionViewMixin, - 'authentication_classes', - new_callable=PropertyMock, - return_value=[OAuth2Authentication, SessionAuthentication] + 'get_authenticators', + return_value=[OAuth2Authentication(), SessionAuthentication()] ) self.patch_object( CompletionViewMixin,