Skip to content

Commit

Permalink
YONK-1535 - Updated code for edx-platform ironwood release compatibil…
Browse files Browse the repository at this point in the history
…ity (#62)
  • Loading branch information
shafqatfarhan authored and xitij2000 committed Dec 10, 2019
1 parent d7dc4e1 commit ceb678e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion completion_aggregator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 10 additions & 6 deletions completion_aggregator/api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion completion_aggregator/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ceb678e

Please sign in to comment.