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