2014-06-06 13:56:48 +08:00
|
|
|
# -*coding:utf-8 -*-
|
|
|
|
class AddCourseRoles < ActiveRecord::Migration
|
|
|
|
def change
|
|
|
|
# 添加课程权限
|
|
|
|
Role.all.each do |role|
|
|
|
|
if role.name == 'Non member'
|
2014-07-31 13:40:02 +08:00
|
|
|
role.add_permission!(:view_course )
|
|
|
|
role.add_permission!(:search_course )
|
|
|
|
role.add_permission!(:add_course )
|
2014-06-06 13:56:48 +08:00
|
|
|
elsif role.name == 'Anonymous'
|
2014-07-31 13:40:02 +08:00
|
|
|
role.add_permission!(:view_course )
|
|
|
|
role.add_permission!(:search_course )
|
2014-06-06 13:56:48 +08:00
|
|
|
elsif role.name == 'Manager'
|
2014-07-31 13:40:02 +08:00
|
|
|
role.add_permission!(:view_course )
|
|
|
|
role.add_permission!(:search_course )
|
|
|
|
role.add_permission!(:add_course )
|
|
|
|
role.add_permission!(:close_course )
|
|
|
|
role.add_permission!(:select_course_modules )
|
|
|
|
role.add_permission!(:edit_course )
|
2014-06-06 13:56:48 +08:00
|
|
|
elsif role.name =='Developer'
|
2014-07-31 13:40:02 +08:00
|
|
|
role.add_permission!(:view_course )
|
|
|
|
role.add_permission!(:search_course )
|
|
|
|
role.add_permission!(:add_course )
|
|
|
|
role.add_permission!(:close_course )
|
|
|
|
role.add_permission!(:select_course_modules )
|
|
|
|
role.add_permission!(:edit_course )
|
2014-06-06 13:56:48 +08:00
|
|
|
elsif role.name == 'Reporter'
|
2014-07-31 13:40:02 +08:00
|
|
|
role.add_permission!(:view_course )
|
|
|
|
role.add_permission!(:search_course )
|
2014-06-06 13:56:48 +08:00
|
|
|
elsif role.name == '助教'
|
2014-07-31 13:40:02 +08:00
|
|
|
role.add_permission!(:view_course )
|
|
|
|
role.add_permission!(:search_course )
|
|
|
|
role.add_permission!(:add_course )
|
|
|
|
role.add_permission!(:select_course_modules )
|
|
|
|
role.add_permission!(:edit_course )
|
2014-06-06 13:56:48 +08:00
|
|
|
elsif role.name == '老师'
|
2014-07-31 13:40:02 +08:00
|
|
|
role.add_permission!(:view_course )
|
|
|
|
role.add_permission!(:search_course )
|
|
|
|
role.add_permission!(:add_course )
|
|
|
|
role.add_permission!(:close_course )
|
|
|
|
role.add_permission!(:select_course_modules )
|
|
|
|
role.add_permission!(:edit_course )
|
2014-06-06 13:56:48 +08:00
|
|
|
elsif role.name == '学生'
|
2014-07-31 13:40:02 +08:00
|
|
|
role.add_permission!(:view_course )
|
|
|
|
role.add_permission!(:search_course )
|
2014-06-06 13:56:48 +08:00
|
|
|
end
|
2014-07-31 13:40:02 +08:00
|
|
|
role.add_permission!(:view_course_files )
|
|
|
|
role.add_permission!(:view_course_journals_for_messages )
|
|
|
|
role.add_permission!(:view_course_messages )
|
2014-07-01 15:29:16 +08:00
|
|
|
role.save(:validate => false)
|
2014-06-06 13:56:48 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|