socialforge/db/migrate/20140606028512_add_course_r...

55 lines
2.1 KiB
Ruby
Raw Normal View History

# -*coding:utf-8 -*-
class AddCourseRoles < ActiveRecord::Migration
def change
# 添加课程权限
Role.all.each do |role|
if role.name == 'Non member'
role.add_permission!(:view_course )
role.add_permission!(:search_course )
role.add_permission!(:add_course )
elsif role.name == 'Anonymous'
role.add_permission!(:view_course )
role.add_permission!(:search_course )
elsif role.name == 'Manager'
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 )
elsif role.name =='Developer'
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 )
elsif role.name == 'Reporter'
role.add_permission!(:view_course )
role.add_permission!(:search_course )
elsif role.name == '助教'
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 )
elsif role.name == '老师'
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 )
elsif role.name == '学生'
role.add_permission!(:view_course )
role.add_permission!(:search_course )
end
role.add_permission!(:view_course_files )
role.add_permission!(:view_course_journals_for_messages )
role.add_permission!(:view_course_messages )
role.save(:validate => false)
end
end
end