55 lines
2.2 KiB
Ruby
55 lines
2.2 KiB
Ruby
# -*coding:utf-8 -*-
|
|
class AddCourseRoles < ActiveRecord::Migration
|
|
def change
|
|
# 添加课程权限
|
|
Role.all.each do |role|
|
|
if role.name == 'Non member'
|
|
role.permissions.append(:view_course )
|
|
role.permissions.append(:search_course )
|
|
role.permissions.append(:add_course )
|
|
elsif role.name == 'Anonymous'
|
|
role.permissions.append(:view_course )
|
|
role.permissions.append(:search_course )
|
|
elsif role.name == 'Manager'
|
|
role.permissions.append(:view_course )
|
|
role.permissions.append(:search_course )
|
|
role.permissions.append(:add_course )
|
|
role.permissions.append(:close_course )
|
|
role.permissions.append(:select_course_modules )
|
|
role.permissions.append(:edit_course )
|
|
elsif role.name =='Developer'
|
|
role.permissions.append(:view_course )
|
|
role.permissions.append(:search_course )
|
|
role.permissions.append(:add_course )
|
|
role.permissions.append(:close_course )
|
|
role.permissions.append(:select_course_modules )
|
|
role.permissions.append(:edit_course )
|
|
elsif role.name == 'Reporter'
|
|
role.permissions.append(:view_course )
|
|
role.permissions.append(:search_course )
|
|
elsif role.name == '助教'
|
|
role.permissions.append(:view_course )
|
|
role.permissions.append(:search_course )
|
|
role.permissions.append(:add_course )
|
|
role.permissions.append(:select_course_modules )
|
|
role.permissions.append(:edit_course )
|
|
elsif role.name == '老师'
|
|
role.permissions.append(:view_course )
|
|
role.permissions.append(:search_course )
|
|
role.permissions.append(:add_course )
|
|
role.permissions.append(:close_course )
|
|
role.permissions.append(:select_course_modules )
|
|
role.permissions.append(:edit_course )
|
|
elsif role.name == '学生'
|
|
role.permissions.append(:view_course )
|
|
role.permissions.append(:search_course )
|
|
end
|
|
role.permissions.append(:view_course_files )
|
|
role.permissions.append(:view_course_journals_for_messages )
|
|
role.permissions.append(:view_course_messages )
|
|
role.save(:validate => false)
|
|
end
|
|
end
|
|
|
|
end
|