def dashboard_account(request):
    custom_canvas_account_sis_id = request.LTI['custom_canvas_account_sis_id']
    custom_canvas_membership_roles = request.LTI['custom_canvas_membership_roles']
    conclude_courses = settings.CONCLUDE_COURSES_URL

    """
    Verify that the curernt user has permission to see the cross listing button
    on the dashboard TLT-2569
    """
    cross_listing_is_allowed = is_allowed(custom_canvas_membership_roles,
                                          settings.PERMISSION_XLIST_TOOL,
                                          canvas_account_sis_id=custom_canvas_account_sis_id)

    """
    verify that user has permissions to view the People tool
    """
    people_tool_is_allowed = is_allowed(custom_canvas_membership_roles,
                                          settings.PERMISSION_PEOPLE_TOOL,
                                          canvas_account_sis_id=custom_canvas_account_sis_id)

    """
    verify that user has permissions to view the People tool
    """
    site_creator_is_allowed = is_allowed(custom_canvas_membership_roles,
                                          settings.PERMISSION_SITE_CREATOR,
                                          canvas_account_sis_id=custom_canvas_account_sis_id)

    return render(request, 'canvas_account_admin_tools/dashboard_account.html', {
        'conclude_courses': conclude_courses,
        'cross_listing_allowed': cross_listing_is_allowed,
        'people_tool_allowed': people_tool_is_allowed,
        'site_creator_is_allowed':site_creator_is_allowed,

    })
Example #2
0
def get_teaching_staff_enrollments(canvas_course_id):
    users = get_users_in_course(canvas_course_id)
    enrollments = []
    for user in users:
        for enrollment in user['enrollments']:
            if is_allowed([enrollment['role']], settings.PERMISSION_LTI_EMAILER_SEND_ALL, canvas_course_id):
                _copy_user_attributes_to_enrollment(user, enrollment)
                enrollments.append(enrollment)
    return enrollments
Example #3
0
def dashboard_account(request):
    custom_canvas_account_sis_id = request.LTI['custom_canvas_account_sis_id']
    custom_canvas_membership_roles = request.LTI[
        'custom_canvas_membership_roles']
    """
    Verify that the curernt user has permission to see the cross listing button
    on the dashboard TLT-2569
    """
    cross_listing_is_allowed = is_allowed(
        custom_canvas_membership_roles,
        settings.PERMISSION_XLIST_TOOL,
        canvas_account_sis_id=custom_canvas_account_sis_id)
    """
    verify that user has permissions to view the People tool
    """
    people_tool_is_allowed = is_allowed(
        custom_canvas_membership_roles,
        settings.PERMISSION_PEOPLE_TOOL,
        canvas_account_sis_id=custom_canvas_account_sis_id)
    """
    verify that user has permissions to view the canvas site creator tool
    """
    site_creator_is_allowed = is_allowed(
        custom_canvas_membership_roles,
        settings.PERMISSION_SITE_CREATOR,
        canvas_account_sis_id=custom_canvas_account_sis_id)
    """
    verify that user has permissions to view the publish courses tool
    """
    publish_courses_allowed = is_allowed(
        custom_canvas_membership_roles,
        settings.PERMISSION_PUBLISH_COURSES,
        canvas_account_sis_id=custom_canvas_account_sis_id)
    """
    verify that user has permissions to view the bulk course settings tool
    """
    bulk_course_settings_is_allowed = is_allowed(
        custom_canvas_membership_roles,
        settings.PERMISSION_BULK_COURSE_SETTING,
        canvas_account_sis_id=custom_canvas_account_sis_id)
    """
       verify that user has permissions to view the Canvas Site deletion tool
       """
    canvas_site_deletion_is_allowed = is_allowed(
        custom_canvas_membership_roles,
        settings.PERMISSION_CANVAS_SITE_DELETION,
        canvas_account_sis_id=custom_canvas_account_sis_id)

    return render(
        request, 'canvas_account_admin_tools/dashboard_account.html', {
            'cross_listing_allowed': cross_listing_is_allowed,
            'people_tool_allowed': people_tool_is_allowed,
            'site_creator_is_allowed': site_creator_is_allowed,
            'publish_courses_allowed': publish_courses_allowed,
            'bulk_course_settings_is_allowed': bulk_course_settings_is_allowed,
            'canvas_site_deletion_is_allowed': canvas_site_deletion_is_allowed,
        })
Example #4
0
def get_teaching_staff_enrollments(canvas_course_id):
    users = get_users_in_course(canvas_course_id)
    enrollments = []
    roles_allowed = {}
    for user in users:
        for enrollment in user['enrollments']:
            role = enrollment['role']
            if role not in roles_allowed:
                roles_allowed[enrollment['role']] = is_allowed(
                    [role],
                    settings.PERMISSION_LTI_EMAILER_SEND_ALL,
                    canvas_course_id
                )
            if roles_allowed[role]:
                _copy_user_attributes_to_enrollment(user, enrollment)
                enrollments.append(enrollment)
    return enrollments