當前位置: 首頁>>代碼示例>>Python>>正文


Python CourseInstructorRole.remove_users方法代碼示例

本文整理匯總了Python中student.roles.CourseInstructorRole.remove_users方法的典型用法代碼示例。如果您正苦於以下問題:Python CourseInstructorRole.remove_users方法的具體用法?Python CourseInstructorRole.remove_users怎麽用?Python CourseInstructorRole.remove_users使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在student.roles.CourseInstructorRole的用法示例。


在下文中一共展示了CourseInstructorRole.remove_users方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: delete_course_and_groups

# 需要導入模塊: from student.roles import CourseInstructorRole [as 別名]
# 或者: from student.roles.CourseInstructorRole import remove_users [as 別名]
def delete_course_and_groups(course_id, commit=False):
    """
    This deletes the courseware associated with a course_id as well as cleaning update_item
    the various user table stuff (groups, permissions, etc.)
    """
    module_store = modulestore('direct')
    content_store = contentstore()

    org, course_num, _ = course_id.split("/")
    module_store.ignore_write_events_on_courses.append('{0}/{1}'.format(
        org, course_num))

    loc = CourseDescriptor.id_to_location(course_id)
    if delete_course(module_store, content_store, loc, commit):
        print 'removing forums permissions and roles...'
        unseed_permissions_roles(course_id)

        print 'removing User permissions from course....'
        # in the django layer, we need to remove all the user permissions groups associated with this course
        if commit:
            try:
                staff_role = CourseStaffRole(loc)
                staff_role.remove_users(*staff_role.users_with_role())
                instructor_role = CourseInstructorRole(loc)
                instructor_role.remove_users(
                    *instructor_role.users_with_role())
            except Exception as err:
                log.error(
                    "Error in deleting course groups for {0}: {1}".format(
                        loc, err))
開發者ID:norsecode,項目名稱:edx-platform,代碼行數:32,代碼來源:utils.py

示例2: delete_course_and_groups

# 需要導入模塊: from student.roles import CourseInstructorRole [as 別名]
# 或者: from student.roles.CourseInstructorRole import remove_users [as 別名]
def delete_course_and_groups(course_id, commit=False):
    """
    This deletes the courseware associated with a course_id as well as cleaning update_item
    the various user table stuff (groups, permissions, etc.)
    """
    module_store = modulestore('direct')
    content_store = contentstore()

    course_id_dict = Location.parse_course_id(course_id)
    module_store.ignore_write_events_on_courses.append('{org}/{course}'.format(**course_id_dict))

    loc = CourseDescriptor.id_to_location(course_id)
    if delete_course(module_store, content_store, loc, commit):

        print 'removing User permissions from course....'
        # in the django layer, we need to remove all the user permissions groups associated with this course
        if commit:
            try:
                staff_role = CourseStaffRole(loc)
                staff_role.remove_users(*staff_role.users_with_role())
                instructor_role = CourseInstructorRole(loc)
                instructor_role.remove_users(*instructor_role.users_with_role())
            except Exception as err:
                log.error("Error in deleting course groups for {0}: {1}".format(loc, err))

            # remove location of this course from loc_mapper and cache
            loc_mapper().delete_course_mapping(loc)
開發者ID:DazzaGreenwood,項目名稱:edx-platform,代碼行數:29,代碼來源:utils.py

示例3: remove_all_instructors

# 需要導入模塊: from student.roles import CourseInstructorRole [as 別名]
# 或者: from student.roles.CourseInstructorRole import remove_users [as 別名]
def remove_all_instructors(course_key):
    """
    Removes all instructor and staff users from the given course.
    """
    staff_role = CourseStaffRole(course_key)
    staff_role.remove_users(*staff_role.users_with_role())
    instructor_role = CourseInstructorRole(course_key)
    instructor_role.remove_users(*instructor_role.users_with_role())
開發者ID:Colin-Fredericks,項目名稱:edx-platform,代碼行數:10,代碼來源:utils.py

示例4: remove_all_instructors

# 需要導入模塊: from student.roles import CourseInstructorRole [as 別名]
# 或者: from student.roles.CourseInstructorRole import remove_users [as 別名]
def remove_all_instructors(course_key):
    """
    Removes given user as instructor and staff to the given course,
    after verifying that the requesting_user has permission to do so.
    """
    staff_role = CourseStaffRole(course_key)
    staff_role.remove_users(*staff_role.users_with_role())
    instructor_role = CourseInstructorRole(course_key)
    instructor_role.remove_users(*instructor_role.users_with_role())
開發者ID:HoraceS,項目名稱:edx-platform,代碼行數:11,代碼來源:utils.py

示例5: delete_course_and_groups

# 需要導入模塊: from student.roles import CourseInstructorRole [as 別名]
# 或者: from student.roles.CourseInstructorRole import remove_users [as 別名]
def delete_course_and_groups(course_id, user_id):
    """
    This deletes the courseware associated with a course_id as well as cleaning update_item
    the various user table stuff (groups, permissions, etc.)
    """
    module_store = modulestore()

    with module_store.bulk_write_operations(course_id):
        module_store.delete_course(course_id, user_id)

        print 'removing User permissions from course....'
        # in the django layer, we need to remove all the user permissions groups associated with this course
        try:
            staff_role = CourseStaffRole(course_id)
            staff_role.remove_users(*staff_role.users_with_role())
            instructor_role = CourseInstructorRole(course_id)
            instructor_role.remove_users(*instructor_role.users_with_role())
        except Exception as err:
            log.error("Error in deleting course groups for {0}: {1}".format(course_id, err))
開發者ID:AlexanderFuentes,項目名稱:edx-platform,代碼行數:21,代碼來源:utils.py

示例6: delete_course_and_groups

# 需要導入模塊: from student.roles import CourseInstructorRole [as 別名]
# 或者: from student.roles.CourseInstructorRole import remove_users [as 別名]
def delete_course_and_groups(course_id, commit=False):
    """
    This deletes the courseware associated with a course_id as well as cleaning update_item
    the various user table stuff (groups, permissions, etc.)
    """
    module_store = modulestore('direct')
    content_store = contentstore()

    module_store.ignore_write_events_on_courses.add(course_id)

    if delete_course(module_store, content_store, course_id, commit):

        print 'removing User permissions from course....'
        # in the django layer, we need to remove all the user permissions groups associated with this course
        if commit:
            try:
                staff_role = CourseStaffRole(course_id)
                staff_role.remove_users(*staff_role.users_with_role())
                instructor_role = CourseInstructorRole(course_id)
                instructor_role.remove_users(*instructor_role.users_with_role())
            except Exception as err:
                log.error("Error in deleting course groups for {0}: {1}".format(course_id, err))
開發者ID:LoveCoding,項目名稱:Projects,代碼行數:24,代碼來源:utils.py


注:本文中的student.roles.CourseInstructorRole.remove_users方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。