admin编辑角色,项目权限、课程、;竞赛权限分开显示
This commit is contained in:
parent
83c5d5c78d
commit
67162bd8fb
|
@ -18,15 +18,52 @@
|
|||
<div class="box tabular" id="permissions">
|
||||
<% perms_by_module = @role.setable_permissions.group_by {|p| p.project_module.to_s} %>
|
||||
<% perms_by_module.keys.sort.each do |mod| %>
|
||||
<fieldset><legend><%= mod.blank? ? l(:label_project) : l_or_humanize(mod, :prefix => 'project_module_') %></legend>
|
||||
<% perms_by_module[mod].each do |permission| %>
|
||||
<label class="floating">
|
||||
<%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %>
|
||||
<%= l_or_humanize(permission.name, :prefix => 'permission_') %>
|
||||
</label>
|
||||
<% end %>
|
||||
<% if mod.blank? %>
|
||||
<fieldset>
|
||||
<legend><%= l(:label_project) %></legend>
|
||||
<% perms_by_module[mod].each do |permission| %>
|
||||
<% if permission.belong_to_project? %>
|
||||
<label class="floating">
|
||||
<%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %>
|
||||
<%= l_or_humanize(permission.name, :prefix => 'permission_') %>
|
||||
</label>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
<fieldset>
|
||||
<legend><%= l(:label_course) %></legend>
|
||||
<% perms_by_module[mod].each do |permission| %>
|
||||
<% if permission.belong_to_course? %>
|
||||
<label class="floating">
|
||||
<%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %>
|
||||
<%= l_or_humanize(permission.name, :prefix => 'permission_') %>
|
||||
</label>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><%= l(:label_contest) %></legend>
|
||||
<% perms_by_module[mod].each do |permission| %>
|
||||
<% if permission.belong_to_contest? %>
|
||||
<label class="floating">
|
||||
<%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %>
|
||||
<%= l_or_humanize(permission.name, :prefix => 'permission_') %>
|
||||
</label>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
<% else %>
|
||||
<fieldset>
|
||||
<legend><%= l_or_humanize(mod, :prefix => 'project_module_') %></legend>
|
||||
<% perms_by_module[mod].each do |permission| %>
|
||||
<label class="floating">
|
||||
<%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %>
|
||||
<%= l_or_humanize(permission.name, :prefix => 'permission_') %>
|
||||
</label>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<br /><%= check_all_links 'permissions' %>
|
||||
<%= hidden_field_tag 'role[permissions][]', '' %>
|
||||
</div>
|
||||
|
|
|
@ -89,29 +89,28 @@ end
|
|||
Redmine::AccessControl.map do |map|
|
||||
map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true, :read => true
|
||||
map.permission :search_project, {:search => :index}, :public => true, :read => true
|
||||
map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin
|
||||
map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member
|
||||
map.permission :close_project, {:projects => [:close, :reopen]}, :require => :member, :read => true
|
||||
map.permission :select_project_modules, {:projects => :modules}, :require => :member
|
||||
map.permission :select_contest_modules, {:contests => :modules}, :require => :member
|
||||
map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :create, :update, :destroy, :autocomplete]}, :require => :member
|
||||
map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member
|
||||
map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member
|
||||
map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin ,:belong_to_project => true
|
||||
map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member ,:belong_to_project => true
|
||||
map.permission :close_project, {:projects => [:close, :reopen]}, :require => :member, :read => true ,:belong_to_project => true
|
||||
map.permission :select_project_modules, {:projects => :modules}, :require => :member ,:belong_to_project => true
|
||||
map.permission :select_contest_modules, {:contests => :modules}, :require => :member ,:belong_to_contest => true
|
||||
map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :create, :update, :destroy, :autocomplete]}, :require => :member ,:belong_to_project => true
|
||||
map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member ,:belong_to_project => true
|
||||
map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member ,:belong_to_project => true
|
||||
map.permission :view_journals_for_messages, {:gantts => [:show, :update]}, :read => true
|
||||
map.permission :quote_project, {},:require => :member
|
||||
map.permission :is_manager,{},:require => :member
|
||||
map.permission :as_teacher,{},:require => :member
|
||||
map.permission :as_student,{},:require => :member
|
||||
map.permission :quote_project, {},:require => :member,:belong_to_contest => true
|
||||
map.permission :is_manager,{},:require => :member ,:belong_to_project => true
|
||||
map.permission :as_teacher,{},:require => :member ,:belong_to_course => true
|
||||
map.permission :as_student,{},:require => :member ,:belong_to_course => true
|
||||
|
||||
#课程权限模块
|
||||
#added by nwb
|
||||
map.permission :view_course, {:courses => [:show], :activities => [:index]}, :public => true, :read => true
|
||||
map.permission :search_course, {:search => :index}, :public => true, :read => true
|
||||
map.permission :add_course, {:courses => [:new, :create]}, :require => :loggedin
|
||||
map.permission :edit_course, {:courses => [:settings, :edit, :update]}, :require => :member
|
||||
map.permission :close_course, {:courses => [:close, :reopen]}, :require => :member, :read => true
|
||||
map.permission :select_course_modules, {:courses => :modules}, :require => :member
|
||||
map.permission :view_course_journals_for_messages, {:courses => :feedback}, :require => :member,:read => true
|
||||
map.permission :add_course, {:courses => [:new, :create]}, :require => :loggedin ,:belong_to_course => true
|
||||
map.permission :edit_course, {:courses => [:settings, :edit, :update]}, :require => :member ,:belong_to_course => true
|
||||
map.permission :close_course, {:courses => [:close, :reopen]}, :require => :member, :read => true ,:belong_to_course => true
|
||||
map.permission :select_course_modules, {:courses => :modules}, :require => :member ,:belong_to_course => true
|
||||
map.permission :view_course_journals_for_messages, {:courses => :feedback}, :require => :member,:read => true ,:belong_to_course => true
|
||||
|
||||
map.course_module :files do |map|
|
||||
map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin
|
||||
|
|
|
@ -126,7 +126,9 @@ module Redmine
|
|||
@course_module = options[:course_module]
|
||||
@project_module = options[:project_module]
|
||||
@contest_module = options[:contest_module]
|
||||
|
||||
@belong_to_project = options[:belong_to_project] || false
|
||||
@belong_to_course = options[:belong_to_course] || false
|
||||
@belong_to_contest =options[:belong_to_contest] || false
|
||||
hash.each do |controller, actions|
|
||||
if actions.is_a? Array
|
||||
@actions << actions.collect {|action| "#{controller}/#{action}"}
|
||||
|
@ -152,6 +154,19 @@ module Redmine
|
|||
def read?
|
||||
@read
|
||||
end
|
||||
|
||||
def belong_to_project?
|
||||
@belong_to_project
|
||||
end
|
||||
|
||||
def belong_to_course?
|
||||
@belong_to_course
|
||||
end
|
||||
|
||||
def belong_to_contest?
|
||||
@belong_to_contest
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue