A project module (eg. issue tracking, news, wiki,...) is a set of permissions that can enabled/disabled at project level. For each project, modules can be enabled on the project settings view ('Modules' tab). This requires a specific permission: 'Select project modules' (if this permission is turned off, only Redmine administrators can choose which modules a project uses). When applying this migration, all modules are enabled for all existing projects. git-svn-id: http://redmine.rubyforge.org/svn/trunk@725 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/0.6.0
@@ -17,13 +17,23 @@ | |||
class MembersController < ApplicationController | |||
layout 'base' | |||
before_filter :find_project, :authorize | |||
before_filter :find_member, :except => :new | |||
before_filter :find_project, :only => :new | |||
before_filter :authorize | |||
def new | |||
@project.members << Member.new(params[:member]) if request.post? | |||
respond_to do |format| | |||
format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project } | |||
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/settings/members'} } | |||
end | |||
end | |||
def edit | |||
if request.post? and @member.update_attributes(params[:member]) | |||
respond_to do |format| | |||
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } | |||
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/members'} } | |||
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/settings/members'} } | |||
end | |||
end | |||
end | |||
@@ -32,12 +42,18 @@ class MembersController < ApplicationController | |||
@member.destroy | |||
respond_to do |format| | |||
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } | |||
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/members'} } | |||
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/settings/members'} } | |||
end | |||
end | |||
private | |||
def find_project | |||
@project = Project.find(params[:id]) | |||
rescue ActiveRecord::RecordNotFound | |||
render_404 | |||
end | |||
def find_member | |||
@member = Member.find(params[:id]) | |||
@project = @member.project | |||
rescue ActiveRecord::RecordNotFound |
@@ -73,16 +73,9 @@ class ProjectsController < ApplicationController | |||
else | |||
@project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] | |||
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) } | |||
@project.custom_values = @custom_values | |||
if params[:repository_enabled] && params[:repository_enabled] == "1" | |||
@project.repository = Repository.factory(params[:repository_scm]) | |||
@project.repository.attributes = params[:repository] | |||
end | |||
if "1" == params[:wiki_enabled] | |||
@project.wiki = Wiki.new | |||
@project.wiki.attributes = params[:wiki] | |||
end | |||
@project.custom_values = @custom_values | |||
if @project.save | |||
@project.enabled_module_names = params[:enabled_modules] | |||
flash[:notice] = l(:notice_successful_create) | |||
redirect_to :controller => 'admin', :action => 'projects' | |||
end | |||
@@ -107,6 +100,8 @@ class ProjectsController < ApplicationController | |||
@issue_category ||= IssueCategory.new | |||
@member ||= @project.members.new | |||
@custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } | |||
@repository ||= @project.repository | |||
@wiki ||= @project.wiki | |||
end | |||
# Edit @project | |||
@@ -117,24 +112,6 @@ class ProjectsController < ApplicationController | |||
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } | |||
@project.custom_values = @custom_values | |||
end | |||
if params[:repository_enabled] | |||
case params[:repository_enabled] | |||
when "0" | |||
@project.repository = nil | |||
when "1" | |||
@project.repository ||= Repository.factory(params[:repository_scm]) | |||
@project.repository.update_attributes params[:repository] if @project.repository | |||
end | |||
end | |||
if params[:wiki_enabled] | |||
case params[:wiki_enabled] | |||
when "0" | |||
@project.wiki.destroy if @project.wiki | |||
when "1" | |||
@project.wiki ||= Wiki.new | |||
@project.wiki.update_attributes params[:wiki] | |||
end | |||
end | |||
@project.attributes = params[:project] | |||
if @project.save | |||
flash[:notice] = l(:notice_successful_update) | |||
@@ -145,6 +122,11 @@ class ProjectsController < ApplicationController | |||
end | |||
end | |||
end | |||
def modules | |||
@project.enabled_module_names = params[:enabled_modules] | |||
redirect_to :action => 'settings', :id => @project, :tab => 'modules' | |||
end | |||
def archive | |||
@project.archive if request.post? && @project.active? | |||
@@ -195,25 +177,6 @@ class ProjectsController < ApplicationController | |||
end | |||
end | |||
# Add a new member to @project | |||
def add_member | |||
@member = @project.members.build(params[:member]) | |||
if request.post? && @member.save | |||
respond_to do |format| | |||
format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project } | |||
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'members'} } | |||
end | |||
else | |||
settings | |||
render :action => 'settings' | |||
end | |||
end | |||
# Show members list of @project | |||
def list_members | |||
@members = @project.members.find(:all) | |||
end | |||
# Add a new document to @project | |||
def add_document | |||
@categories = Enumeration::get_values('DCAT') |
@@ -21,10 +21,29 @@ require 'digest/sha1' | |||
class RepositoriesController < ApplicationController | |||
layout 'base' | |||
before_filter :find_project, :except => [:update_form] | |||
before_filter :authorize, :except => [:update_form] | |||
before_filter :find_repository, :except => :edit | |||
before_filter :find_project, :only => :edit | |||
before_filter :authorize | |||
accept_key_auth :revisions | |||
def edit | |||
@repository = @project.repository | |||
if !@repository | |||
@repository = Repository.factory(params[:repository_scm]) | |||
@repository.project = @project | |||
end | |||
if request.post? | |||
@repository.attributes = params[:repository] | |||
@repository.save | |||
end | |||
render(:update) {|page| page.replace_html "tab-content-repository", :partial => 'projects/settings/repository'} | |||
end | |||
def destroy | |||
@repository.destroy | |||
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'repository' | |||
end | |||
def show | |||
# check if new revisions have been committed in the repository | |||
@repository.fetch_changesets if Setting.autofetch_changesets? | |||
@@ -113,14 +132,15 @@ class RepositoriesController < ApplicationController | |||
end | |||
end | |||
def update_form | |||
@repository = Repository.factory(params[:repository_scm]) | |||
render :partial => 'projects/repository', :locals => {:repository => @repository} | |||
end | |||
private | |||
def find_project | |||
@project = Project.find(params[:id]) | |||
rescue ActiveRecord::RecordNotFound | |||
render_404 | |||
end | |||
def find_repository | |||
@project = Project.find(params[:id]) | |||
@repository = @project.repository | |||
render_404 and return false unless @repository | |||
@path = params[:path].squeeze('/') if params[:path] |
@@ -0,0 +1,44 @@ | |||
# redMine - project management software | |||
# Copyright (C) 2006-2007 Jean-Philippe Lang | |||
# | |||
# This program is free software; you can redistribute it and/or | |||
# modify it under the terms of the GNU General Public License | |||
# as published by the Free Software Foundation; either version 2 | |||
# of the License, or (at your option) any later version. | |||
# | |||
# This program is distributed in the hope that it will be useful, | |||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
# GNU General Public License for more details. | |||
# | |||
# You should have received a copy of the GNU General Public License | |||
# along with this program; if not, write to the Free Software | |||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
class WikisController < ApplicationController | |||
layout 'base' | |||
before_filter :find_project, :authorize | |||
# Create or update a project's wiki | |||
def edit | |||
@wiki = @project.wiki || Wiki.new(:project => @project) | |||
@wiki.attributes = params[:wiki] | |||
@wiki.save if @request.post? | |||
render(:update) {|page| page.replace_html "tab-content-wiki", :partial => 'projects/settings/wiki'} | |||
end | |||
# Delete a project's wiki | |||
def destroy | |||
if request.post? && params[:confirm] && @project.wiki | |||
@project.wiki.destroy | |||
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'wiki' | |||
end | |||
end | |||
private | |||
def find_project | |||
@project = Project.find(params[:id]) | |||
rescue ActiveRecord::RecordNotFound | |||
render_404 | |||
end | |||
end |
@@ -26,6 +26,19 @@ module ProjectsHelper | |||
}, options | |||
end | |||
def project_settings_tabs | |||
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural}, | |||
{:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural}, | |||
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}, | |||
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural}, | |||
{:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural}, | |||
{:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki}, | |||
{:name => 'repository', :action => :manage_repository, :partial => 'projects/settings/repository', :label => :label_repository}, | |||
{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural} | |||
] | |||
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} | |||
end | |||
# Generates a gantt image | |||
# Only defined if RMagick is avalaible | |||
def gantt_image(events, date_from, months, zoom) |
@@ -29,13 +29,13 @@ module RepositoriesHelper | |||
send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) | |||
end | |||
def scm_select_tag | |||
def scm_select_tag(repository) | |||
container = [[]] | |||
REDMINE_SUPPORTED_SCM.each {|scm| container << ["Repository::#{scm}".constantize.scm_name, scm]} | |||
select_tag('repository_scm', | |||
options_for_select(container, @project.repository.class.name.demodulize), | |||
:disabled => (@project.repository && !@project.repository.new_record?), | |||
:onchange => remote_function(:update => "repository_fields", :url => { :controller => 'repositories', :action => 'update_form', :id => @project }, :with => "Form.serialize(this.form)") | |||
options_for_select(container, repository.class.name.demodulize), | |||
:disabled => (repository && !repository.new_record?), | |||
:onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)") | |||
) | |||
end | |||
@@ -0,0 +1,23 @@ | |||
# redMine - project management software | |||
# Copyright (C) 2006-2007 Jean-Philippe Lang | |||
# | |||
# This program is free software; you can redistribute it and/or | |||
# modify it under the terms of the GNU General Public License | |||
# as published by the Free Software Foundation; either version 2 | |||
# of the License, or (at your option) any later version. | |||
# | |||
# This program is distributed in the hope that it will be useful, | |||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
# GNU General Public License for more details. | |||
# | |||
# You should have received a copy of the GNU General Public License | |||
# along with this program; if not, write to the Free Software | |||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
class EnabledModule < ActiveRecord::Base | |||
belongs_to :project | |||
validates_presence_of :name | |||
validates_uniqueness_of :name, :scope => :project_id | |||
end |
@@ -23,6 +23,7 @@ class Project < ActiveRecord::Base | |||
has_many :members, :dependent => :delete_all, :include => :user, :conditions => "#{User.table_name}.status=#{User::STATUS_ACTIVE}" | |||
has_many :users, :through => :members | |||
has_many :custom_values, :dependent => :delete_all, :as => :customized | |||
has_many :enabled_modules, :dependent => :delete_all | |||
has_many :issues, :dependent => :destroy, :order => "#{Issue.table_name}.created_on DESC", :include => [:status, :tracker] | |||
has_many :issue_changes, :through => :issues, :source => :journals | |||
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC" | |||
@@ -38,7 +39,7 @@ class Project < ActiveRecord::Base | |||
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", :association_foreign_key => 'custom_field_id' | |||
acts_as_tree :order => "name", :counter_cache => true | |||
attr_protected :status | |||
attr_protected :status, :enabled_module_names | |||
validates_presence_of :name, :description, :identifier | |||
validates_uniqueness_of :name, :identifier | |||
@@ -121,10 +122,43 @@ class Project < ActiveRecord::Base | |||
def <=>(project) | |||
name <=> project.name | |||
end | |||
def allows_to?(action) | |||
if action.is_a? Hash | |||
allowed_actions.include? "#{action[:controller]}/#{action[:action]}" | |||
else | |||
allowed_permissions.include? action | |||
end | |||
end | |||
def module_enabled?(module_name) | |||
module_name = module_name.to_s | |||
enabled_modules.detect {|m| m.name == module_name} | |||
end | |||
def enabled_module_names=(module_names) | |||
enabled_modules.clear | |||
module_names = [] unless module_names && module_names.is_a?(Array) | |||
module_names.each do |name| | |||
enabled_modules << EnabledModule.new(:name => name.to_s) | |||
end | |||
end | |||
protected | |||
def validate | |||
errors.add(parent_id, " must be a root project") if parent and parent.parent | |||
errors.add_to_base("A project with subprojects can't be a subproject") if parent and children.size > 0 | |||
end | |||
private | |||
def allowed_permissions | |||
@allowed_permissions ||= begin | |||
module_names = enabled_modules.collect {|m| m.name} | |||
Redmine::AccessControl.modules_permissions(module_names).collect {|p| p.name} | |||
end | |||
end | |||
def allowed_actions | |||
@actions_allowed ||= allowed_permissions.inject([]) { |actions, permission| actions += Redmine::AccessControl.allowed_actions(permission) }.flatten | |||
end | |||
end |
@@ -178,8 +178,13 @@ class User < ActiveRecord::Base | |||
# * a parameter-like Hash (eg. :controller => 'projects', :action => 'edit') | |||
# * a permission Symbol (eg. :edit_project) | |||
def allowed_to?(action, project) | |||
# No action allowed on archived projects | |||
return false unless project.active? | |||
# No action allowed on disabled modules | |||
return false unless project.allows_to?(action) | |||
# Admin users are authorized for anything else | |||
return true if admin? | |||
role = role_for_project(project) | |||
return false unless role | |||
role.allowed_to?(action) && (project.is_public? || role.member?) |
@@ -2,5 +2,5 @@ | |||
<% labelled_tabular_form_for :category, @category, :url => { :action => 'edit', :id => @category } do |f| %> | |||
<%= render :partial => 'issue_categories/form', :locals => { :f => f } %> | |||
<%= submit_tag l(:button_create) %> | |||
<%= submit_tag l(:button_save) %> | |||
<% end %> |
@@ -71,7 +71,7 @@ | |||
<% if @project && !@project.new_record? %> | |||
<h2><%= @project.name %></h2> | |||
<ul class="menublock"> | |||
<% Redmine::MenuManager.allowed_items(:project_menu, current_role).each do |item| %> | |||
<% Redmine::MenuManager.allowed_items(:project_menu, User.current, @project).each do |item| %> | |||
<% unless item.condition && !item.condition.call(@project) %> | |||
<li><%= link_to l(item.name), {item.param => @project}.merge(item.url) %></li> | |||
<% end %> |
@@ -0,0 +1,4 @@ | |||
<% labelled_tabular_form_for :project, @project, :url => { :action => "edit", :id => @project } do |f| %> | |||
<%= render :partial => 'form', :locals => { :f => f } %> | |||
<%= submit_tag l(:button_save) %> | |||
<% end %> |
@@ -28,32 +28,6 @@ | |||
<!--[eoform:project]--> | |||
</div> | |||
<div class="box"> | |||
<h3><%= check_box_tag "repository_enabled", 1, !@project.repository.nil?, :onclick => "Element.toggle('repository');" %> <%= l(:label_repository) %></h3> | |||
<%= hidden_field_tag "repository_enabled", 0 %> | |||
<div id="repository"> | |||
<p class="tabular"><label>SCM</label><%= scm_select_tag %></p> | |||
<div id="repository_fields"> | |||
<%= render :partial => 'projects/repository', :locals => {:repository => @project.repository} if @project.repository %> | |||
</div> | |||
</div> | |||
</div> | |||
<%= javascript_tag "Element.hide('repository');" if @project.repository.nil? %> | |||
<div class="box"> | |||
<h3><%= check_box_tag "wiki_enabled", 1, !@project.wiki.nil?, :onclick => "Element.toggle('wiki');" %> <%= l(:label_wiki) %></h3> | |||
<%= hidden_field_tag "wiki_enabled", 0 %> | |||
<div id="wiki"> | |||
<% fields_for :wiki, @project.wiki, { :builder => TabularFormBuilder, :lang => current_language} do |wiki| %> | |||
<p><%= wiki.text_field :start_page, :size => 60, :required => true %><br /><em><%= l(:text_unallowed_characters) %>: , . / ? ; : |</em></p> | |||
<% # content_tag("div", "", :id => "wiki_start_page_auto_complete", :class => "auto_complete") + | |||
# auto_complete_field("wiki_start_page", { :url => { :controller => 'wiki', :action => 'auto_complete_for_wiki_page', :id => @project } }) | |||
%> | |||
<% end %> | |||
</div> | |||
<%= javascript_tag "Element.hide('wiki');" if @project.wiki.nil? %> | |||
</div> | |||
<% content_for :header_tags do %> | |||
<%= javascript_include_tag 'calendar/calendar' %> | |||
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %> |
@@ -1,3 +0,0 @@ | |||
<% fields_for :repository, repository, { :builder => TabularFormBuilder, :lang => current_language} do |f| %> | |||
<%= repository_field_tags(f, repository) %> | |||
<% end %> |
@@ -2,5 +2,14 @@ | |||
<% labelled_tabular_form_for :project, @project, :url => { :action => "add" } do |f| %> | |||
<%= render :partial => 'form', :locals => { :f => f } %> | |||
<div class="box"> | |||
<p><label><%= l(:label_module_plural) %></label> | |||
<% Redmine::AccessControl.available_project_modules.each do |m| %> | |||
<%= check_box_tag 'enabled_modules[]', m, @project.module_enabled?(m) %> <%= m.to_s.humanize %> | |||
<% end %></p> | |||
</div> | |||
<%= submit_tag l(:button_save) %> | |||
<% end %> | |||
<% end %> |
@@ -2,83 +2,15 @@ | |||
<div class="tabs"> | |||
<ul> | |||
<li><%= link_to l(:label_information_plural), {}, :id=> "tab-info", :onclick => "showTab('info'); this.blur(); return false;" %></li> | |||
<li><%= link_to l(:label_member_plural), {}, :id=> "tab-members", :onclick => "showTab('members'); this.blur(); return false;" %></li> | |||
<li><%= link_to l(:label_version_plural), {}, :id=> "tab-versions", :onclick => "showTab('versions'); this.blur(); return false;" %></li> | |||
<li><%= link_to l(:label_issue_category_plural), {}, :id=> "tab-categories", :onclick => "showTab('categories'); this.blur(); return false;" %></li> | |||
<li><%= link_to l(:label_board_plural), {}, :id=> "tab-boards", :onclick => "showTab('boards'); this.blur(); return false;" %></li> | |||
</ul> | |||
</div> | |||
<div id="tab-content-info" class="tab-content"> | |||
<% if authorize_for('projects', 'edit') %> | |||
<% labelled_tabular_form_for :project, @project, :url => { :action => "edit", :id => @project } do |f| %> | |||
<%= render :partial => 'form', :locals => { :f => f } %> | |||
<%= submit_tag l(:button_save) %> | |||
<% end %> | |||
<% project_settings_tabs.each do |tab| %> | |||
<li><%= link_to l(tab[:label]), {}, :id => "tab-#{tab[:name]}", :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li> | |||
<% end %> | |||
</ul> | |||
</div> | |||
<div id="tab-content-members" class="tab-content" style="display:none;"> | |||
<%= render :partial => 'members' %> | |||
</div> | |||
<div id="tab-content-versions" class="tab-content" style="display:none;"> | |||
<table class="list"> | |||
<thead> | |||
<th><%= l(:label_version) %></th> | |||
<th><%= l(:field_effective_date) %></th> | |||
<th><%= l(:field_description) %></th> | |||
<th><%= l(:label_wiki_page) unless @project.wiki.nil? %></th> | |||
<th style="width:15%"></th> | |||
<th style="width:15%"></th> | |||
</thead> | |||
<tbody> | |||
<% for version in @project.versions.sort %> | |||
<tr class="<%= cycle 'odd', 'even' %>"> | |||
<td><%=h version.name %></td> | |||
<td align="center"><%= format_date(version.effective_date) %></td> | |||
<td><%=h version.description %></td> | |||
<td><%= link_to(version.wiki_page_title, :controller => 'wiki', :page => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %></td> | |||
<td align="center"><small><%= link_to_if_authorized l(:button_edit), { :controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %></small></td> | |||
<td align="center"><small><%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small></td> | |||
</td> | |||
</tr> | |||
<% end; reset_cycle %> | |||
</tbody> | |||
</table> | |||
| |||
<p><%= link_to_if_authorized l(:label_version_new), :controller => 'projects', :action => 'add_version', :id => @project %></p> | |||
</div> | |||
<div id="tab-content-categories" class="tab-content" style="display:none;"> | |||
<table class="list"> | |||
<thead> | |||
<th><%= l(:label_issue_category) %></th> | |||
<th><%= l(:field_assigned_to) %></th> | |||
<th style="width:15%"></th> | |||
<th style="width:15%"></th> | |||
</thead> | |||
<tbody> | |||
<% for category in @project.issue_categories %> | |||
<% unless category.new_record? %> | |||
<tr class="<%= cycle 'odd', 'even' %>"> | |||
<td><%=h(category.name) %></td> | |||
<td><%=h(category.assigned_to.name) if category.assigned_to %></td> | |||
<td align="center"><small><%= link_to_if_authorized l(:button_edit), { :controller => 'issue_categories', :action => 'edit', :id => category }, :class => 'icon icon-edit' %></small></td> | |||
<td align="center"><small><%= link_to_if_authorized l(:button_delete), {:controller => 'issue_categories', :action => 'destroy', :id => category}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small></td> | |||
</tr> | |||
<% end %> | |||
<% project_settings_tabs.each do |tab| %> | |||
<%= content_tag('div', render(:partial => tab[:partial]), :id => "tab-content-#{tab[:name]}", :class => 'tab-content') %> | |||
<% end %> | |||
</tbody> | |||
</table> | |||
| |||
<p><%= link_to_if_authorized l(:label_issue_category_new), :controller => 'projects', :action => 'add_issue_category', :id => @project %></p> | |||
</div> | |||
<div id="tab-content-boards" class="tab-content" style="display:none;"> | |||
<%= render :partial => 'boards' %> | |||
</div> | |||
<%= tab = params[:tab] ? h(params[:tab]) : 'info' | |||
javascript_tag "showTab('#{tab}');" %> | |||
<%= tab = params[:tab] ? h(params[:tab]) : project_settings_tabs.first[:name] | |||
javascript_tag "showTab('#{tab}');" %> |
@@ -0,0 +1,22 @@ | |||
<table class="list"> | |||
<thead> | |||
<th><%= l(:label_issue_category) %></th> | |||
<th><%= l(:field_assigned_to) %></th> | |||
<th style="width:15%"></th> | |||
<th style="width:15%"></th> | |||
</thead> | |||
<tbody> | |||
<% for category in @project.issue_categories %> | |||
<% unless category.new_record? %> | |||
<tr class="<%= cycle 'odd', 'even' %>"> | |||
<td><%=h(category.name) %></td> | |||
<td><%=h(category.assigned_to.name) if category.assigned_to %></td> | |||
<td align="center"><small><%= link_to_if_authorized l(:button_edit), { :controller => 'issue_categories', :action => 'edit', :id => category }, :class => 'icon icon-edit' %></small></td> | |||
<td align="center"><small><%= link_to_if_authorized l(:button_delete), {:controller => 'issue_categories', :action => 'destroy', :id => category}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small></td> | |||
</tr> | |||
<% end %> | |||
<% end %> | |||
</tbody> | |||
</table> | |||
| |||
<p><%= link_to_if_authorized l(:label_issue_category_new), :controller => 'projects', :action => 'add_issue_category', :id => @project %></p> |
@@ -33,8 +33,8 @@ | |||
</table> | |||
| |||
<% if authorize_for('projects', 'add_member') && !users.empty? %> | |||
<% remote_form_for(:member, @member, :url => {:controller => 'projects', :action => 'add_member', :tab => 'members', :id => @project}, :method => :post) do |f| %> | |||
<% if authorize_for('members', 'new') && !users.empty? %> | |||
<% remote_form_for(:member, @member, :url => {:controller => 'members', :action => 'new', :id => @project}, :method => :post) do |f| %> | |||
<p><label for="member_user_id"><%=l(:label_member_new)%></label><br /> | |||
<%= f.select :user_id, users.collect{|user| [user.name, user.id]} %> | |||
<%= l(:label_role) %>: <%= f.select :role_id, roles.collect{|role| [role.name, role.id]}, :selected => nil %> |
@@ -0,0 +1,14 @@ | |||
<% form_for :project, @project, | |||
:url => { :action => 'modules', :id => @project }, | |||
:html => {:id => 'modules-form'} do |f| %> | |||
<div class=box> | |||
<% Redmine::AccessControl.available_project_modules.each do |m| %> | |||
<p><label><%= check_box_tag 'enabled_modules[]', m, @project.module_enabled?(m) %> <%= m.to_s.humanize %></label></p> | |||
<% end %> | |||
</div> | |||
<p><%= check_all_links 'modules-form' %></p> | |||
<p><%= submit_tag l(:button_save) %></p> | |||
<% end %> |
@@ -0,0 +1,20 @@ | |||
<% remote_form_for :repository, @repository, | |||
:url => { :controller => 'repositories', :action => 'edit', :id => @project }, | |||
:builder => TabularFormBuilder do |f| %> | |||
<%= error_messages_for 'repository' %> | |||
<div class="box tabular"> | |||
<p><label>SCM</label><%= scm_select_tag(@repository) %></p> | |||
<%= repository_field_tags(f, @repository) if @repository %> | |||
</div> | |||
<div class="contextual"> | |||
<%= link_to(l(:button_delete), {:controller => 'repositories', :action => 'destroy', :id => @project}, | |||
:confirm => l(:text_are_you_sure), | |||
:method => :post, | |||
:class => 'icon icon-del') if @repository && !@repository.new_record? %> | |||
</div> | |||
<%= submit_tag((@repository.nil? || @repository.new_record?) ? l(:button_create) : l(:button_save)) %> | |||
<% end %> |
@@ -0,0 +1,25 @@ | |||
<table class="list"> | |||
<thead> | |||
<th><%= l(:label_version) %></th> | |||
<th><%= l(:field_effective_date) %></th> | |||
<th><%= l(:field_description) %></th> | |||
<th><%= l(:label_wiki_page) unless @project.wiki.nil? %></th> | |||
<th style="width:15%"></th> | |||
<th style="width:15%"></th> | |||
</thead> | |||
<tbody> | |||
<% for version in @project.versions.sort %> | |||
<tr class="<%= cycle 'odd', 'even' %>"> | |||
<td><%=h version.name %></td> | |||
<td align="center"><%= format_date(version.effective_date) %></td> | |||
<td><%=h version.description %></td> | |||
<td><%= link_to(version.wiki_page_title, :controller => 'wiki', :page => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %></td> | |||
<td align="center"><small><%= link_to_if_authorized l(:button_edit), { :controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %></small></td> | |||
<td align="center"><small><%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small></td> | |||
</td> | |||
</tr> | |||
<% end; reset_cycle %> | |||
</tbody> | |||
</table> | |||
| |||
<p><%= link_to_if_authorized l(:label_version_new), :controller => 'projects', :action => 'add_version', :id => @project %></p> |
@@ -0,0 +1,18 @@ | |||
<% remote_form_for :wiki, @wiki, | |||
:url => { :controller => 'wikis', :action => 'edit', :id => @project }, | |||
:builder => TabularFormBuilder do |f| %> | |||
<%= error_messages_for 'wiki' %> | |||
<div class="box tabular"> | |||
<p><%= f.text_field :start_page, :size => 60, :required => true %><br /> | |||
<em><%= l(:text_unallowed_characters) %>: , . / ? ; : |</em></p> | |||
</div> | |||
<div class="contextual"> | |||
<%= link_to(l(:button_delete), {:controller => 'wikis', :action => 'destroy', :id => @project}, | |||
:class => 'icon icon-del') if @wiki && !@wiki.new_record? %> | |||
</div> | |||
<%= submit_tag((@wiki.nil? || @wiki.new_record?) ? l(:button_create) : l(:button_save)) %> | |||
<% end %> |
@@ -19,6 +19,7 @@ | |||
<% end %> | |||
</ul> | |||
<% if User.current.allowed_to?(:view_issues, @project) %> | |||
<div class="box"> | |||
<div class="contextual"><% if authorize_for('projects', 'add_issue') %><%= l(:label_issue_new) %>: <%= new_issue_selector %><% end %></div> | |||
<h3 class="icon22 icon22-tracker"><%=l(:label_issue_tracking)%></h3> | |||
@@ -33,6 +34,7 @@ | |||
</ul> | |||
<p class="textcenter"><small><%= link_to l(:label_issue_view_all), :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 %></small></p> | |||
</div> | |||
<% end %> | |||
</div> | |||
<div class="splitcontentright"> |
@@ -2,19 +2,23 @@ | |||
<div class="box"> | |||
<p><%= f.text_field :name, :required => true, :disabled => @role.builtin? %></p> | |||
</div> | |||
<p><%= f.check_box :assignable %></p> | |||
<div class="clear"></div> | |||
</div> | |||
<fieldset class="box"><legend><%=l(:label_permissions)%></legend> | |||
<% @permissions.each do |permission| %> | |||
<div style="width:220px;float:left;"> | |||
<%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %> | |||
<%= permission.name.to_s.humanize %> | |||
</div> | |||
<div class="box"> | |||
<h3><%= l(:label_permissions) %></h3> | |||
<% perms_by_module = @permissions.group_by {|p| p.project_module.to_s} %> | |||
<% perms_by_module.keys.sort.each do |mod| %> | |||
<fieldset><legend><%= mod.blank? ? l(:label_project) : mod.humanize %></legend> | |||
<% perms_by_module[mod].each do |permission| %> | |||
<div style="width:220px;float:left;"> | |||
<%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %> | |||
<%= permission.name.to_s.humanize %> | |||
</div> | |||
<% end %> | |||
</fieldset> | |||
<% end %> | |||
<br /><%= check_all_links 'role_form' %> | |||
<%= hidden_field_tag 'role[permissions][]', '' %> | |||
<div class="clear"></div> | |||
<br /> | |||
<%= check_all_links 'role_form' %> | |||
</fieldset> | |||
</div> |
@@ -12,17 +12,23 @@ | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<% @permissions.each do |permission| %> | |||
<tr class="<%= cycle('odd', 'even') %>"> | |||
<td><%= permission.name.to_s.humanize %></td> | |||
<% @roles.each do |role| %> | |||
<td align="center"> | |||
<% if role.setable_permissions.include? permission %> | |||
<%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name) %> | |||
<% perms_by_module = @permissions.group_by {|p| p.project_module.to_s} %> | |||
<% perms_by_module.keys.sort.each do |mod| %> | |||
<% unless mod.blank? %> | |||
<tr><%= content_tag('th', mod.humanize, :colspan => (@roles.size + 1)) %></th></tr> | |||
<% end %> | |||
</td> | |||
<% perms_by_module[mod].each do |permission| %> | |||
<tr class="<%= cycle('odd', 'even') %>"> | |||
<td><%= permission.name.to_s.humanize %></td> | |||
<% @roles.each do |role| %> | |||
<td align="center"> | |||
<% if role.setable_permissions.include? permission %> | |||
<%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name) %> | |||
<% end %> | |||
</td> | |||
<% end %> | |||
</tr> | |||
<% end %> | |||
</tr> | |||
<% end %> | |||
</tbody> | |||
</table> |
@@ -0,0 +1,10 @@ | |||
<h2><%=l(:label_confirmation)%></h2> | |||
<div class="box"><center> | |||
<p><strong><%= @project.name %></strong><br /><%=l(:text_wiki_destroy_confirmation)%></p> | |||
<% form_tag({:controller => 'wikis', :action => 'destroy', :id => @project}) do %> | |||
<%= hidden_field_tag "confirm", 1 %> | |||
<%= submit_tag l(:button_delete) %> | |||
<% end %> | |||
</center></div> |
@@ -0,0 +1,18 @@ | |||
class CreateEnabledModules < ActiveRecord::Migration | |||
def self.up | |||
create_table :enabled_modules do |t| | |||
t.column :project_id, :integer | |||
t.column :name, :string, :null => false | |||
end | |||
add_index :enabled_modules, [:project_id], :name => :enabled_modules_project_id | |||
# Enable all modules for existing projects | |||
Project.find(:all).each do |project| | |||
project.enabled_module_names = Redmine::AccessControl.available_project_modules | |||
end | |||
end | |||
def self.down | |||
drop_table :enabled_modules | |||
end | |||
end |
@@ -415,6 +415,7 @@ label_language_based: Language based | |||
label_sort_by: Sort by "%s" | |||
label_send_test_email: Send a test email | |||
label_feeds_access_key_created_on: RSS access key created %s ago | |||
label_module_plural: Modules | |||
button_login: Вход | |||
button_submit: Изпращане | |||
@@ -474,6 +475,7 @@ text_comma_separated: Позволено е изброяване (с разде | |||
text_issues_ref_in_commit_messages: Отбелязване и приключване на задачи от commit съобщения | |||
text_issue_added: Публикувана е нова задача с номер %s. | |||
text_issue_updated: Задача %s е обновена. | |||
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content ? | |||
default_role_manager: Мениджър | |||
default_role_developper: Разработчик |
@@ -415,6 +415,7 @@ label_language_based: Language based | |||
label_sort_by: Sort by "%s" | |||
label_send_test_email: Send a test email | |||
label_feeds_access_key_created_on: RSS access key created %s ago | |||
label_module_plural: Modules | |||
button_login: Einloggen | |||
button_submit: OK | |||
@@ -474,6 +475,7 @@ text_comma_separated: Multiple values allowed (comma separated). | |||
text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages | |||
text_issue_added: Ticket %s wurde erstellt. | |||
text_issue_updated: Ticket %s wurde aktualisiert. | |||
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content ? | |||
default_role_manager: Manager | |||
default_role_developper: Developer |
@@ -415,6 +415,7 @@ label_language_based: Language based | |||
label_sort_by: Sort by "%s" | |||
label_send_test_email: Send a test email | |||
label_feeds_access_key_created_on: RSS access key created %s ago | |||
label_module_plural: Modules | |||
button_login: Login | |||
button_submit: Submit | |||
@@ -474,6 +475,7 @@ text_comma_separated: Multiple values allowed (comma separated). | |||
text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages | |||
text_issue_added: Issue %s has been reported. | |||
text_issue_updated: Issue %s has been updated. | |||
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content ? | |||
default_role_manager: Manager | |||
default_role_developper: Developer |
@@ -415,6 +415,7 @@ label_language_based: Language based | |||
label_sort_by: Sort by "%s" | |||
label_send_test_email: Send a test email | |||
label_feeds_access_key_created_on: RSS access key created %s ago | |||
label_module_plural: Modules | |||
button_login: Conexión | |||
button_submit: Someter | |||
@@ -474,6 +475,7 @@ text_comma_separated: Multiple values allowed (comma separated). | |||
text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages | |||
text_issue_added: Issue %s has been reported. | |||
text_issue_updated: Issue %s has been updated. | |||
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content ? | |||
default_role_manager: Manager | |||
default_role_developper: Desarrollador |
@@ -415,6 +415,7 @@ label_language_based: Basé sur la langue | |||
label_sort_by: Trier par "%s" | |||
label_send_test_email: Envoyer un email de test | |||
label_feeds_access_key_created_on: Clé d'accès RSS créée il y a %s | |||
label_module_plural: Modules | |||
button_login: Connexion | |||
button_submit: Soumettre | |||
@@ -474,6 +475,7 @@ text_comma_separated: Plusieurs valeurs possibles (séparées par des virgules). | |||
text_issues_ref_in_commit_messages: Référencement et résolution des demandes dans les commentaires de commits | |||
text_issue_added: La demande %s a été soumise. | |||
text_issue_updated: La demande %s a été mise à jour. | |||
text_wiki_destroy_confirmation: Etes-vous sûr de vouloir supprimer ce wiki et tout son contenu ? | |||
default_role_manager: Manager | |||
default_role_developper: Développeur |
@@ -415,6 +415,7 @@ label_language_based: Language based | |||
label_sort_by: Sort by "%s" | |||
label_send_test_email: Send a test email | |||
label_feeds_access_key_created_on: RSS access key created %s ago | |||
label_module_plural: Modules | |||
button_login: Login | |||
button_submit: Invia | |||
@@ -474,6 +475,7 @@ text_comma_separated: Multiple values allowed (comma separated). | |||
text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages | |||
text_issue_added: "E' stata segnalata l'anomalia %s." | |||
text_issue_updated: "L'anomalia %s e' stata aggiornata." | |||
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content ? | |||
default_role_manager: Manager | |||
default_role_developper: Sviluppatore |
@@ -416,6 +416,7 @@ label_language_based: Language based | |||
label_sort_by: Sort by "%s" | |||
label_send_test_email: Send a test email | |||
label_feeds_access_key_created_on: RSS access key created %s ago | |||
label_module_plural: Modules | |||
button_login: ログイン | |||
button_submit: 変更 | |||
@@ -475,6 +476,7 @@ text_comma_separated: (カンマで区切った)複数の値が使えます | |||
text_issues_ref_in_commit_messages: コミットメッセージ内で問題の参照/修正 | |||
text_issue_added: 問題 %s が報告されました。 | |||
text_issue_updated: 問題 %s が更新されました。 | |||
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content ? | |||
default_role_manager: 管理者 | |||
default_role_developper: 開発者 |
@@ -415,6 +415,7 @@ label_language_based: Language based | |||
label_sort_by: Sort by "%s" | |||
label_send_test_email: Send a test email | |||
label_feeds_access_key_created_on: RSS access key created %s ago | |||
label_module_plural: Modules | |||
button_login: Inloggen | |||
button_submit: Toevoegen | |||
@@ -474,6 +475,7 @@ text_coma_separated: Meerdere waarden toegestaan (door komma's gescheiden). | |||
text_issues_ref_in_commit_messages: Opzoeken en aanpassen van issues in commit berichten | |||
text_issue_added: Issue %s is gerapporteerd. | |||
text_issue_updated: Issue %s is gewijzigd. | |||
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content ? | |||
default_role_manager: Manager | |||
default_role_developper: Ontwikkelaar |
@@ -415,6 +415,7 @@ label_language_based: Language based | |||
label_sort_by: Sort by "%s" | |||
label_send_test_email: Send a test email | |||
label_feeds_access_key_created_on: RSS access key created %s ago | |||
label_module_plural: Modules | |||
button_login: Login | |||
button_submit: Enviar | |||
@@ -474,6 +475,7 @@ text_comma_separated: Multiple values allowed (comma separated). | |||
text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages | |||
text_issue_added: Tarefa %s foi incluída. | |||
text_issue_updated: Tarefa %s foi alterada. | |||
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content ? | |||
default_role_manager: Analista de Negocio ou Gerente de Projeto | |||
default_role_developper: Desenvolvedor |
@@ -415,6 +415,7 @@ label_language_based: Language based | |||
label_sort_by: Sort by "%s" | |||
label_send_test_email: Send a test email | |||
label_feeds_access_key_created_on: RSS access key created %s ago | |||
label_module_plural: Modules | |||
button_login: Login | |||
button_submit: Enviar | |||
@@ -474,6 +475,7 @@ text_comma_separated: Permitido múltiplos valores (separados por vírgula). | |||
text_issues_ref_in_commit_messages: Referenciando e arrumando tarefas nas mensagens de commit | |||
text_issue_added: Tarefa %s foi incluída. | |||
text_issue_updated: Tarefa %s foi alterada. | |||
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content ? | |||
default_role_manager: Analista de Negócio ou Gerente de Projeto | |||
default_role_developper: Desenvolvedor |
@@ -415,6 +415,7 @@ label_language_based: Language based | |||
label_sort_by: Sort by "%s" | |||
label_send_test_email: Send a test email | |||
label_feeds_access_key_created_on: RSS access key created %s ago | |||
label_module_plural: Modules | |||
button_login: Logga in | |||
button_submit: Skicka | |||
@@ -474,6 +475,7 @@ text_comma_separated: Multiple values allowed (comma separated). | |||
text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages | |||
text_issue_added: Brist %s har rapporterats. | |||
text_issue_updated: Brist %s har uppdaterats. | |||
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content ? | |||
default_role_manager: Förvaltare | |||
default_role_developper: Utvecklare |
@@ -417,6 +417,7 @@ label_language_based: Language based | |||
label_sort_by: Sort by "%s" | |||
label_send_test_email: Send a test email | |||
label_feeds_access_key_created_on: RSS access key created %s ago | |||
label_module_plural: Modules | |||
button_login: 登录 | |||
button_submit: 提交 | |||
@@ -476,6 +477,7 @@ text_comma_separated: Multiple values allowed (comma separated). | |||
text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages | |||
text_issue_added: %s ѱ | |||
text_issue_updated: %s Ѹ | |||
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content ? | |||
default_role_manager: 管理员 | |||
default_role_developper: 开发人员 |
@@ -14,57 +14,76 @@ REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs ) | |||
# Permissions | |||
Redmine::AccessControl.map do |map| | |||
# Project | |||
map.permission :view_project, {:projects => [:show, :activity, :changelog, :roadmap, :feeds]}, :public => true | |||
map.permission :view_project, {:projects => [:show, :activity, :feeds]}, :public => true | |||
map.permission :search_project, {:search => :index}, :public => true | |||
map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member | |||
map.permission :manage_members, {:projects => [:settings, :add_member], :members => [:edit, :destroy]}, :require => :member | |||
map.permission :select_project_modules, {:projects => :modules}, :require => :member | |||
map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy]}, :require => :member | |||
map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member | |||
map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member | |||
# Issues | |||
map.permission :view_issues, {:projects => [:list_issues, :export_issues_csv, :export_issues_pdf], | |||
:issues => [:show, :export_pdf], | |||
:queries => :index, | |||
:reports => :issue_report}, :public => true | |||
map.permission :add_issues, {:projects => :add_issue}, :require => :loggedin | |||
map.permission :edit_issues, {:issues => [:edit, :destroy_attachment]}, :require => :loggedin | |||
map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}, :require => :loggedin | |||
map.permission :add_issue_notes, {:issues => :add_note}, :require => :loggedin | |||
map.permission :change_issue_status, {:issues => :change_status}, :require => :loggedin | |||
map.permission :move_issues, {:projects => :move_issues}, :require => :loggedin | |||
map.permission :delete_issues, {:issues => :destroy}, :require => :member | |||
# Queries | |||
map.permission :manage_pulic_queries, {:queries => [:new, :edit, :destroy]}, :require => :member | |||
map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin | |||
# Gantt & calendar | |||
map.permission :view_gantt, :projects => :gantt | |||
map.permission :view_calendar, :projects => :calendar | |||
# Time tracking | |||
map.permission :log_time, {:timelog => :edit}, :require => :loggedin | |||
map.permission :view_time_entries, :timelog => [:details, :report] | |||
# News | |||
map.permission :view_news, {:projects => :list_news, :news => :show}, :public => true | |||
map.permission :manage_news, {:projects => :add_news, :news => [:edit, :destroy, :destroy_comment]}, :require => :member | |||
map.permission :comment_news, {:news => :add_comment}, :require => :loggedin | |||
# Documents | |||
map.permission :view_documents, :projects => :list_documents, :documents => [:show, :download] | |||
map.permission :manage_documents, {:projects => :add_document, :documents => [:edit, :destroy, :add_attachment, :destroy_attachment]}, :require => :loggedin | |||
# Wiki | |||
map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :special] | |||
map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment] | |||
map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member | |||
map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member | |||
# Message boards | |||
map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true | |||
map.permission :add_messages, {:messages => [:new, :reply]}, :require => :loggedin | |||
map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member | |||
# Files | |||
map.permission :view_files, :projects => :list_files, :versions => :download | |||
map.permission :manage_files, {:projects => :add_file, :versions => :destroy_file}, :require => :loggedin | |||
# Repository | |||
map.permission :browse_repository, :repositories => [:show, :browse, :entry, :changes, :diff, :stats, :graph] | |||
map.permission :view_changesets, :repositories => [:show, :revisions, :revision] | |||
map.project_module :issue_tracking do |map| | |||
# Issue categories | |||
map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member | |||
# Issues | |||
map.permission :view_issues, {:projects => [:list_issues, :export_issues_csv, :export_issues_pdf, :changelog, :roadmap], | |||
:issues => [:show, :export_pdf], | |||
:queries => :index, | |||
:reports => :issue_report}, :public => true | |||
map.permission :add_issues, {:projects => :add_issue}, :require => :loggedin | |||
map.permission :edit_issues, {:issues => [:edit, :destroy_attachment]}, :require => :loggedin | |||
map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}, :require => :loggedin | |||
map.permission :add_issue_notes, {:issues => :add_note}, :require => :loggedin | |||
map.permission :change_issue_status, {:issues => :change_status}, :require => :loggedin | |||
map.permission :move_issues, {:projects => :move_issues}, :require => :loggedin | |||
map.permission :delete_issues, {:issues => :destroy}, :require => :member | |||
# Queries | |||
map.permission :manage_pulic_queries, {:queries => [:new, :edit, :destroy]}, :require => :member | |||
map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin | |||
# Gantt & calendar | |||
map.permission :view_gantt, :projects => :gantt | |||
map.permission :view_calendar, :projects => :calendar | |||
end | |||
map.project_module :time_tracking do |map| | |||
map.permission :log_time, {:timelog => :edit}, :require => :loggedin | |||
map.permission :view_time_entries, :timelog => [:details, :report] | |||
end | |||
map.project_module :news do |map| | |||
map.permission :manage_news, {:projects => :add_news, :news => [:edit, :destroy, :destroy_comment]}, :require => :member | |||
map.permission :view_news, {:projects => :list_news, :news => :show}, :public => true | |||
map.permission :comment_news, {:news => :add_comment}, :require => :loggedin | |||
end | |||
map.project_module :documents do |map| | |||
map.permission :manage_documents, {:projects => :add_document, :documents => [:edit, :destroy, :add_attachment, :destroy_attachment]}, :require => :loggedin | |||
map.permission :view_documents, :projects => :list_documents, :documents => [:show, :download] | |||
end | |||
map.project_module :files do |map| | |||
map.permission :manage_files, {:projects => :add_file, :versions => :destroy_file}, :require => :loggedin | |||
map.permission :view_files, :projects => :list_files, :versions => :download | |||
end | |||
map.project_module :wiki do |map| | |||
map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member | |||
map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member | |||
map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member | |||
map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :special] | |||
map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment] | |||
end | |||
map.project_module :repository do |map| | |||
map.permission :manage_repository, :repositories => [:edit, :destroy] | |||
map.permission :browse_repository, :repositories => [:show, :browse, :entry, :changes, :diff, :stats, :graph] | |||
map.permission :view_changesets, :repositories => [:show, :revisions, :revision] | |||
end | |||
map.project_module :boards do |map| | |||
map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member | |||
map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true | |||
map.permission :add_messages, {:messages => [:new, :reply]}, :require => :loggedin | |||
end | |||
end | |||
# Project menu configuration |
@@ -46,27 +46,47 @@ module Redmine | |||
def loggedin_only_permissions | |||
@loggedin_only_permissions ||= @permissions.select {|p| p.require_loggedin?} | |||
end | |||
def available_project_modules | |||
@available_project_modules ||= @permissions.collect(&:project_module).uniq.compact | |||
end | |||
def modules_permissions(modules) | |||
@permissions.select {|p| p.project_module.nil? || modules.include?(p.project_module.to_s)} | |||
end | |||
end | |||
class Mapper | |||
def initialize | |||
@project_module = nil | |||
end | |||
def permission(name, hash, options={}) | |||
@permissions ||= [] | |||
options.merge!(:project_module => @project_module) | |||
@permissions << Permission.new(name, hash, options) | |||
end | |||
def project_module(name, options={}) | |||
@project_module = name | |||
yield self | |||
@project_module = nil | |||
end | |||
def mapped_permissions | |||
@permissions | |||
end | |||
end | |||
class Permission | |||
attr_reader :name, :actions | |||
attr_reader :name, :actions, :project_module | |||
def initialize(name, hash, options) | |||
@name = name | |||
@actions = [] | |||
@public = options[:public] || false | |||
@require = options[:require] | |||
@project_module = options[:project_module] | |||
hash.each do |controller, actions| | |||
if actions.is_a? Array | |||
@actions << actions.collect {|action| "#{controller}/#{action}"} |
@@ -31,8 +31,8 @@ module Redmine | |||
@items[menu_name.to_sym] || [] | |||
end | |||
def allowed_items(menu_name, role) | |||
items(menu_name).select {|item| role && role.allowed_to?(item.url)} | |||
def allowed_items(menu_name, user, project) | |||
items(menu_name).select {|item| user && user.allowed_to?(item.url, project)} | |||
end | |||
end | |||
@@ -0,0 +1,33 @@ | |||
--- | |||
enabled_modules_001: | |||
name: issue_tracking | |||
project_id: 1 | |||
id: 1 | |||
enabled_modules_002: | |||
name: time_tracking | |||
project_id: 1 | |||
id: 2 | |||
enabled_modules_003: | |||
name: news | |||
project_id: 1 | |||
id: 3 | |||
enabled_modules_004: | |||
name: documents | |||
project_id: 1 | |||
id: 4 | |||
enabled_modules_005: | |||
name: files | |||
project_id: 1 | |||
id: 5 | |||
enabled_modules_006: | |||
name: wiki | |||
project_id: 1 | |||
id: 6 | |||
enabled_modules_007: | |||
name: repository | |||
project_id: 1 | |||
id: 7 | |||
enabled_modules_008: | |||
name: boards | |||
project_id: 1 | |||
id: 8 |
@@ -22,7 +22,7 @@ require 'projects_controller' | |||
class ProjectsController; def rescue_action(e) raise e end; end | |||
class ProjectsControllerTest < Test::Unit::TestCase | |||
fixtures :projects, :users, :roles | |||
fixtures :projects, :users, :roles, :enabled_modules | |||
def setup | |||
@controller = ProjectsController.new |
@@ -18,7 +18,7 @@ | |||
require File.dirname(__FILE__) + '/../test_helper' | |||
class MailHandlerTest < Test::Unit::TestCase | |||
fixtures :users, :projects, :roles, :members, :issues, :trackers, :enumerations | |||
fixtures :users, :projects, :enabled_modules, :roles, :members, :issues, :trackers, :enumerations | |||
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures' | |||
CHARSET = "utf-8" |
@@ -58,7 +58,7 @@ class WatcherTest < Test::Unit::TestCase | |||
@user.mail_notification = false | |||
@user.save | |||
@issue.reload | |||
assert !@issue.watcher_recipients.include?(@user.mail) | |||
assert @issue.watcher_recipients.include?(@user.mail) | |||
end | |||
def test_unwatch |