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'
|
|
|
|
role.permissions.append(:view_course )
|
|
|
|
role.permissions.append(:search_course )
|
2014-06-10 17:03:02 +08:00
|
|
|
role.permissions.append(:add_course )
|
2014-06-06 13:56:48 +08:00
|
|
|
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
|
2014-06-11 11:04:38 +08:00
|
|
|
role.permissions.append(:view_course_files )
|
2014-06-16 10:38:38 +08:00
|
|
|
role.permissions.append(:view_course_journals_for_messages )
|
|
|
|
role.permissions.append(:view_course_messages )
|
2014-06-06 13:56:48 +08:00
|
|
|
role.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|