Skip to content

Commit

Permalink
Merge pull request #385 from ccnmtl/default-ta-access
Browse files Browse the repository at this point in the history
Provide default settings value
  • Loading branch information
ndittren authored Oct 1, 2021
2 parents 0a702cb + 45760da commit bc0388b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lti_provider/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def join_groups(self, request, lti, ctx):
request.user.groups.add(ctx.faculty_group)
break

if settings.LTI_TOOL_CONFIGURATION['allow_ta_access']:
if settings.LTI_TOOL_CONFIGURATION.get('allow_ta_access', False):
if 'teachingassistant' in role:
request.user.groups.add(ctx.faculty_group)
break
Expand Down
16 changes: 16 additions & 0 deletions lti_provider/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ def test_join_groups_teachingassistant_true(self):
self.assertTrue(user in ctx.group.user_set.all())
self.assertTrue(user in ctx.faculty_group.user_set.all())

def test_missing_configuration(self):
mixin = LTIAuthMixin()
ctx = LTICourseContextFactory()
user = UserFactory()
self.request.user = user
lti_tool_config2 = TEST_LTI_TOOL_CONFIGURATION.copy()
del lti_tool_config2['allow_ta_access']

with self.settings(
LTI_TOOL_CONFIGURATION=lti_tool_config2):
self.request.session['roles'] = \
u'urn:lti:role:ims/lis/TeachingAssistant'
mixin.join_groups(self.request, self.lti, ctx)
self.assertTrue(user in ctx.group.user_set.all())
self.assertFalse(user in ctx.faculty_group.user_set.all())

def test_launch_invalid_user(self):
request = generate_lti_request()

Expand Down
2 changes: 1 addition & 1 deletion lti_provider/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def get_context_data(self, **kwargs):
url = settings.LTI_TOOL_CONFIGURATION['landing_url'].format(
self.request.scheme, domain, self.lti.course_context(self.request))
is_auth_ta = None
if settings.LTI_TOOL_CONFIGURATION['allow_ta_access']:
if settings.LTI_TOOL_CONFIGURATION.get('allow_ta_access', False):
role = self.request.session.get('roles', '').lower()
is_auth_ta = 'teachingassistant' in role

Expand Down

0 comments on commit bc0388b

Please sign in to comment.