Ejemplo n.º 1
0
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context.update(self.get_default_data())

        user = self.request.user
        context['js_data'] = context.get('js_data', {})
        context['js_data'].update({
            'course': {
                'courseId': self.course_id,
                'org': CourseKey.from_string(self.course_id).org
            },
            'user': {
                'username':
                user.get_username(),
                'userTrackingID':
                permissions.get_user_tracking_id(self.request.user),
                'name':
                user.get_full_name(),
                'email':
                user.email,
                'ignoreInReporting':
                self._ignore_in_reporting(user)
            },
        })

        return context
Ejemplo n.º 2
0
 def test_get_user_tracking_id_from_oauth2_provider(self):
     expected_tracking_id = 56789
     G(UserSocialAuth, user=self.user, provider='edx-oauth2', extra_data={'user_id': expected_tracking_id})
     actual_tracking_id = permissions.get_user_tracking_id(self.user)
     self.assertEqual(actual_tracking_id, expected_tracking_id)
     # make sure tracking ID is cached
     self.assertEqual(cache.get('user_tracking_id_{}'.format(self.user.id)), expected_tracking_id)
Ejemplo n.º 3
0
 def test_user_tracking_settings_with_no_user(self):
     tracking_id = permissions.get_user_tracking_id(self.user)
     self.assertEqual(tracking_id, None)