Example #1
0
    def list_current_user_admin_roles_for_course(self):
        """
        Make an API call to Canvas that returns the list of account admins associated with the course's
        school.  Limit result set to the currently logged in user.  The list can be used for truth testing
        conditions.

        :return: Canvas account admin information (response of admin request), limited to current user
        :rtype: list of account admin Python objects (converted from return value of SDK call)
        :raises: Exception from SDK
        """
        if not self.object:  # Make sure we have the course data
            logger.debug(
                'getting object in list_current_user_admin_roles_for_course')
            self.object = self.get_object()

        # List account admins for school associated with course. TLT-382 specified that only school-level admins
        # will have access to the course creation process for now, so using school_code in combination with school:
        # subaccount (instead of using sis_account_id, which would cover cases for dept: and coursegroup: as well).
        user_account_admin_list = admins.list_account_admins(
            request_ctx=SDK_CONTEXT,
            account_id='sis_account_id:school:%s' % self.object.school_code,
            user_id='sis_user_id:%s' % self.request.user.username).json()
        logger.debug("Admin list for %s in sis_account_id:school:%s is %s" %
                     (self.request.user.username, self.object.school_code,
                      user_account_admin_list))

        return user_account_admin_list
    def list_current_user_admin_roles_for_course(self):
        """
        Make an API call to Canvas that returns the list of account admins associated with the course's
        school.  Limit result set to the currently logged in user.  The list can be used for truth testing
        conditions.

        :return: Canvas account admin information (response of admin request), limited to current user
        :rtype: list of account admin Python objects (converted from return value of SDK call)
        :raises: Exception from SDK
        """
        if not self.object:  # Make sure we have the course data
            logger.debug('getting object in list_current_user_admin_roles_for_course')
            self.object = self.get_object()

        # List account admins for school associated with course. TLT-382 specified that only school-level admins
        # will have access to the course creation process for now, so using school_code in combination with school:
        # subaccount (instead of using sis_account_id, which would cover cases for dept: and coursegroup: as well).
        user_account_admin_list = admins.list_account_admins(
            request_ctx=SDK_CONTEXT,
            account_id='sis_account_id:school:%s' % self.object.school_code,
            user_id='sis_user_id:%s' % self.request.user.username
        ).json()
        logger.debug("Admin list for %s in sis_account_id:school:%s is %s"
                     % (self.request.user.username, self.object.school_code,
                        user_account_admin_list))

        return user_account_admin_list
Example #3
0
    def list_current_user_admin_roles_for_course(self):
        """
        Make an API call to Canvas that returns the list of account admins associated with the course's
        school.  Limit result set to the currently logged in user.  The list can be used for truth testing
        conditions.

        :return: Canvas account admin information (response of admin request), limited to current user
        :rtype: list of account admin Python objects (converted from return value of SDK call)
        :raises: Exception from SDK
        """
        if not self.object:  # Make sure we have the term data
            logger.debug(
                'getting object in list_current_user_admin_roles_for_course')
            self.object = self.get_object()

        # List account admins for school associated with term. TLT-1132 specified that only school-level admins
        # will have access to the bulk course creation process for now,

        # todo remove this after verification
        print('%s' % self.object.school_id)
        user_account_admin_list = admins.list_account_admins(
            request_ctx=SDK_CONTEXT,
            account_id='sis_account_id:school:%s' % self.object.school_id,
            user_id='sis_user_id:%s' % self.request.user.username).json()
        logger.debug("Admin list for %s in sis_account_id:school:%s is %s" %
                     (self.request.user.username, self.object.school_id,
                      user_account_admin_list))

        return user_account_admin_list
    def list_current_user_admin_roles_for_course(self):
        """
        Make an API call to Canvas that returns the list of account admins associated with the course's
        school.  Limit result set to the currently logged in user.  The list can be used for truth testing
        conditions.

        :return: Canvas account admin information (response of admin request), limited to current user
        :rtype: list of account admin Python objects (converted from return value of SDK call)
        :raises: Exception from SDK
        """
        if not self.object:  # Make sure we have the term data
            logger.debug('getting object in list_current_user_admin_roles_for_course')
            self.object = self.get_object()

        # List account admins for school associated with term. TLT-1132 specified that only school-level admins
        # will have access to the bulk course creation process for now,

        # todo remove this after verification
        print '%s' % self.object.school_id
        user_account_admin_list = admins.list_account_admins(
            request_ctx=SDK_CONTEXT,
            account_id='sis_account_id:school:%s' % self.object.school_id,
            user_id='sis_user_id:%s' % self.request.user.username
        ).json()
        logger.debug("Admin list for %s in sis_account_id:school:%s is %s"
                     % (self.request.user.username, self.object.school_id,
                        user_account_admin_list))

        return user_account_admin_list