@@ -0,0 +1,1 | |||
|
1 | <%= principals_check_box_tags 'membership[user_ids][]', @principals %> |
@@ -1,100 +1,103 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class MembersController < ApplicationController |
|
19 | 19 | model_object Member |
|
20 |
before_filter :find_model_object, :except => [: |
|
|
21 |
before_filter :find_project_from_association, :except => [: |
|
|
22 |
before_filter :find_project, :only => [: |
|
|
20 | before_filter :find_model_object, :except => [:create, :autocomplete] | |
|
21 | before_filter :find_project_from_association, :except => [:create, :autocomplete] | |
|
22 | before_filter :find_project_by_project_id, :only => [:create, :autocomplete] | |
|
23 | 23 | before_filter :authorize |
|
24 | 24 | |
|
25 |
def |
|
|
25 | def create | |
|
26 | 26 | members = [] |
|
27 | if params[:member] && request.post? | |
|
28 | attrs = params[:member].dup | |
|
27 | if params[:membership] && request.post? | |
|
28 | attrs = params[:membership].dup | |
|
29 | 29 | if (user_ids = attrs.delete(:user_ids)) |
|
30 | 30 | user_ids.each do |user_id| |
|
31 | 31 | members << Member.new(attrs.merge(:user_id => user_id)) |
|
32 | 32 | end |
|
33 | 33 | else |
|
34 | 34 | members << Member.new(attrs) |
|
35 | 35 | end |
|
36 | 36 | @project.members << members |
|
37 | 37 | end |
|
38 | 38 | respond_to do |format| |
|
39 | 39 | if members.present? && members.all? {|m| m.valid? } |
|
40 | 40 | |
|
41 | 41 | format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } |
|
42 | 42 | |
|
43 | 43 | format.js { |
|
44 | 44 | render(:update) {|page| |
|
45 | 45 | page.replace_html "tab-content-members", :partial => 'projects/settings/members' |
|
46 | 46 | page << 'hideOnLoad()' |
|
47 | 47 | members.each {|member| page.visual_effect(:highlight, "member-#{member.id}") } |
|
48 | 48 | } |
|
49 | 49 | } |
|
50 | 50 | else |
|
51 | 51 | |
|
52 | 52 | format.js { |
|
53 | 53 | render(:update) {|page| |
|
54 | 54 | errors = members.collect {|m| |
|
55 | 55 | m.errors.full_messages |
|
56 | 56 | }.flatten.uniq |
|
57 | 57 | |
|
58 | 58 | page.alert(l(:notice_failed_to_save_members, :errors => errors.join(', '))) |
|
59 | 59 | } |
|
60 | 60 | } |
|
61 | 61 | |
|
62 | 62 | end |
|
63 | 63 | end |
|
64 | 64 | end |
|
65 | 65 | |
|
66 |
def |
|
|
67 | if request.post? and @member.update_attributes(params[:member]) | |
|
66 | def update | |
|
67 | if params[:membership] | |
|
68 | @member.role_ids = params[:membership][:role_ids] | |
|
69 | end | |
|
70 | if request.put? && @member.save | |
|
68 | 71 | respond_to do |format| |
|
69 | 72 | format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } |
|
70 | 73 | format.js { |
|
71 | 74 | render(:update) {|page| |
|
72 | 75 | page.replace_html "tab-content-members", :partial => 'projects/settings/members' |
|
73 | 76 | page << 'hideOnLoad()' |
|
74 | 77 | page.visual_effect(:highlight, "member-#{@member.id}") |
|
75 | 78 | } |
|
76 | 79 | } |
|
77 | 80 | end |
|
78 | 81 | end |
|
79 | 82 | end |
|
80 | 83 | |
|
81 | 84 | def destroy |
|
82 |
if request. |
|
|
85 | if request.delete? && @member.deletable? | |
|
83 | 86 | @member.destroy |
|
84 | 87 | end |
|
85 | 88 | respond_to do |format| |
|
86 | 89 | format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } |
|
87 | 90 | format.js { render(:update) {|page| |
|
88 | 91 | page.replace_html "tab-content-members", :partial => 'projects/settings/members' |
|
89 | 92 | page << 'hideOnLoad()' |
|
90 | 93 | } |
|
91 | 94 | } |
|
92 | 95 | end |
|
93 | 96 | end |
|
94 | 97 | |
|
95 |
def autocomplete |
|
|
98 | def autocomplete | |
|
96 | 99 | @principals = Principal.active.like(params[:q]).find(:all, :limit => 100) - @project.principals |
|
97 | 100 | render :layout => false |
|
98 | 101 | end |
|
99 | 102 | |
|
100 | 103 | end |
@@ -1,90 +1,89 | |||
|
1 | 1 | <%= error_messages_for 'member' %> |
|
2 | 2 | <% roles = Role.find_all_givable |
|
3 | 3 | members = @project.member_principals.find(:all, :include => [:roles, :principal]).sort %> |
|
4 | 4 | |
|
5 | 5 | <div class="splitcontentleft"> |
|
6 | 6 | <% if members.any? %> |
|
7 | 7 | <table class="list members"> |
|
8 | 8 | <thead><tr> |
|
9 | 9 | <th><%= l(:label_user) %> / <%= l(:label_group) %></th> |
|
10 | 10 | <th><%= l(:label_role_plural) %></th> |
|
11 | 11 | <th style="width:15%"></th> |
|
12 | 12 | <%= call_hook(:view_projects_settings_members_table_header, :project => @project) %> |
|
13 | 13 | </tr></thead> |
|
14 | 14 | <tbody> |
|
15 | 15 | <% members.each do |member| %> |
|
16 | 16 | <% next if member.new_record? %> |
|
17 | 17 | <tr id="member-<%= member.id %>" class="<%= cycle 'odd', 'even' %> member"> |
|
18 | 18 | <td class="<%= member.principal.class.name.downcase %>"><%= link_to_user member.principal %></td> |
|
19 | 19 | <td class="roles"> |
|
20 | 20 | <span id="member-<%= member.id %>-roles"><%=h member.roles.sort.collect(&:to_s).join(', ') %></span> |
|
21 | <% if authorize_for('members', 'edit') %> | |
|
22 | <% remote_form_for(:member, member, :url => {:controller => 'members', :action => 'edit', :id => member}, | |
|
23 | :method => :post, | |
|
21 | <% remote_form_for(:membership, member, :url => membership_path(member), | |
|
22 | :method => :put, | |
|
24 | 23 | :html => { :id => "member-#{member.id}-roles-form", :class => 'hol' }) do |f| %> |
|
25 | 24 | <p><% roles.each do |role| %> |
|
26 | <label><%= check_box_tag 'member[role_ids][]', role.id, member.roles.include?(role), | |
|
25 | <label><%= check_box_tag 'membership[role_ids][]', role.id, member.roles.include?(role), | |
|
27 | 26 | :disabled => member.member_roles.detect {|mr| mr.role_id == role.id && !mr.inherited_from.nil?} %> <%=h role %></label><br /> |
|
28 | 27 | <% end %></p> |
|
29 | <%= hidden_field_tag 'member[role_ids][]', '' %> | |
|
28 | <%= hidden_field_tag 'membership[role_ids][]', '' %> | |
|
30 | 29 | <p><%= submit_tag l(:button_change), :class => "small" %> |
|
31 | 30 | <%= link_to_function l(:button_cancel), |
|
32 | 31 | "$('member-#{member.id}-roles').show(); $('member-#{member.id}-roles-form').hide(); return false;" |
|
33 | 32 | %></p> |
|
34 | 33 | <% end %> |
|
35 | <% end %> | |
|
36 | 34 | </td> |
|
37 | 35 | <td class="buttons"> |
|
38 | 36 | <%= link_to_function l(:button_edit), |
|
39 | 37 | "$('member-#{member.id}-roles').hide(); $('member-#{member.id}-roles-form').show(); return false;", |
|
40 | 38 | :class => 'icon icon-edit' %> |
|
41 | 39 | <%= link_to_remote( |
|
42 | 40 | l(:button_delete), |
|
43 | { :url => {:controller => 'members', :action => 'destroy', :id => member}, | |
|
44 |
:method => : |
|
|
41 | { :url => membership_path(member), | |
|
42 | :method => :delete, | |
|
45 | 43 | :confirm => (!User.current.admin? && member.include?(User.current) ? l(:text_own_membership_delete_confirmation) : nil) }, |
|
46 | 44 | :title => l(:button_delete), |
|
47 | 45 | :class => 'icon icon-del' |
|
48 | 46 | ) if member.deletable? %> |
|
49 | 47 | </td> |
|
50 | 48 | <%= call_hook(:view_projects_settings_members_table_row, { :project => @project, :member => member}) %> |
|
51 | 49 | </tr> |
|
52 | 50 | <% end; reset_cycle %> |
|
53 | 51 | </tbody> |
|
54 | 52 | </table> |
|
55 | 53 | <% else %> |
|
56 | 54 | <p class="nodata"><%= l(:label_no_data) %></p> |
|
57 | 55 | <% end %> |
|
58 | 56 | </div> |
|
59 | 57 | |
|
60 | 58 | <% principals = Principal.active.find(:all, :limit => 100, :order => 'type, login, lastname ASC') - @project.principals %> |
|
61 | 59 | |
|
62 | 60 | <div class="splitcontentright"> |
|
63 | 61 | <% if roles.any? && principals.any? %> |
|
64 |
<% remote_form_for(:member, @member, :url => |
|
|
62 | <% remote_form_for(:membership, @member, :url => project_memberships_path(@project), :method => :post, | |
|
65 | 63 | :loading => '$(\'member-add-submit\').disable();', |
|
66 | 64 | :complete => 'if($(\'member-add-submit\')) $(\'member-add-submit\').enable();') do |f| %> |
|
67 | 65 | <fieldset><legend><%=l(:label_member_new)%></legend> |
|
68 | 66 | |
|
69 | 67 | <p><%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %></p> |
|
70 | 68 | <%= observe_field(:principal_search, |
|
71 | 69 | :frequency => 0.5, |
|
72 | 70 | :update => :principals, |
|
73 |
:url => |
|
|
71 | :url => autocomplete_project_memberships_path(@project), | |
|
72 | :method => :get, | |
|
74 | 73 | :with => 'q') |
|
75 | 74 | %> |
|
76 | 75 | |
|
77 | 76 | <div id="principals"> |
|
78 | <%= principals_check_box_tags 'member[user_ids][]', principals %> | |
|
77 | <%= principals_check_box_tags 'membership[user_ids][]', principals %> | |
|
79 | 78 | </div> |
|
80 | 79 | |
|
81 | 80 | <p><%= l(:label_role_plural) %>: |
|
82 | 81 | <% roles.each do |role| %> |
|
83 | <label><%= check_box_tag 'member[role_ids][]', role.id %> <%=h role %></label> | |
|
82 | <label><%= check_box_tag 'membership[role_ids][]', role.id %> <%=h role %></label> | |
|
84 | 83 | <% end %></p> |
|
85 | 84 | |
|
86 | 85 | <p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p> |
|
87 | 86 | </fieldset> |
|
88 | 87 | <% end %> |
|
89 | 88 | <% end %> |
|
90 | 89 | </div> |
@@ -1,421 +1,415 | |||
|
1 | 1 | ActionController::Routing::Routes.draw do |map| |
|
2 | 2 | # Add your own custom routes here. |
|
3 | 3 | # The priority is based upon order of creation: first created -> highest priority. |
|
4 | 4 | |
|
5 | 5 | # Here's a sample route: |
|
6 | 6 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' |
|
7 | 7 | # Keep in mind you can assign values other than :controller and :action |
|
8 | 8 | |
|
9 | 9 | map.home '', :controller => 'welcome', :conditions => {:method => :get} |
|
10 | 10 | |
|
11 | 11 | map.signin 'login', :controller => 'account', :action => 'login', |
|
12 | 12 | :conditions => {:method => [:get, :post]} |
|
13 | 13 | map.signout 'logout', :controller => 'account', :action => 'logout', |
|
14 | 14 | :conditions => {:method => :get} |
|
15 | 15 | map.connect 'account/register', :controller => 'account', :action => 'register', |
|
16 | 16 | :conditions => {:method => [:get, :post]} |
|
17 | 17 | map.connect 'account/lost_password', :controller => 'account', :action => 'lost_password', |
|
18 | 18 | :conditions => {:method => [:get, :post]} |
|
19 | 19 | map.connect 'account/activate', :controller => 'account', :action => 'activate', |
|
20 | 20 | :conditions => {:method => :get} |
|
21 | 21 | |
|
22 | 22 | map.connect 'projects/:id/wiki', :controller => 'wikis', |
|
23 | 23 | :action => 'edit', :conditions => {:method => :post} |
|
24 | 24 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', |
|
25 | 25 | :action => 'destroy', :conditions => {:method => [:get, :post]} |
|
26 | 26 | |
|
27 | 27 | map.with_options :controller => 'messages' do |messages_routes| |
|
28 | 28 | messages_routes.with_options :conditions => {:method => :get} do |messages_views| |
|
29 | 29 | messages_views.connect 'boards/:board_id/topics/new', :action => 'new' |
|
30 | 30 | messages_views.connect 'boards/:board_id/topics/:id', :action => 'show' |
|
31 | 31 | messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit' |
|
32 | 32 | end |
|
33 | 33 | messages_routes.with_options :conditions => {:method => :post} do |messages_actions| |
|
34 | 34 | messages_actions.connect 'boards/:board_id/topics/new', :action => 'new' |
|
35 | 35 | messages_actions.connect 'boards/:board_id/topics/preview', :action => 'preview' |
|
36 | 36 | messages_actions.connect 'boards/:board_id/topics/quote/:id', :action => 'quote' |
|
37 | 37 | messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply' |
|
38 | 38 | messages_actions.connect 'boards/:board_id/topics/:id/edit', :action => 'edit' |
|
39 | 39 | messages_actions.connect 'boards/:board_id/topics/:id/destroy', :action => 'destroy' |
|
40 | 40 | end |
|
41 | 41 | end |
|
42 | 42 | |
|
43 | 43 | # Misc issue routes. TODO: move into resources |
|
44 | 44 | map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', |
|
45 | 45 | :action => 'issues', :conditions => { :method => :get } |
|
46 | 46 | # TODO: would look nicer as /issues/:id/preview |
|
47 | 47 | map.preview_issue '/issues/preview/:id', :controller => 'previews', |
|
48 | 48 | :action => 'issue' |
|
49 | 49 | map.issues_context_menu '/issues/context_menu', |
|
50 | 50 | :controller => 'context_menus', :action => 'issues' |
|
51 | 51 | |
|
52 | 52 | map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index' |
|
53 | 53 | map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', |
|
54 | 54 | :id => /\d+/, :conditions => { :method => :post } |
|
55 | 55 | |
|
56 | 56 | map.connect '/journals/diff/:id', :controller => 'journals', :action => 'diff', |
|
57 | 57 | :id => /\d+/, :conditions => { :method => :get } |
|
58 | 58 | map.connect '/journals/edit/:id', :controller => 'journals', :action => 'edit', |
|
59 | 59 | :id => /\d+/, :conditions => { :method => [:get, :post] } |
|
60 | 60 | |
|
61 | 61 | map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes| |
|
62 | 62 | gantts_routes.connect '/projects/:project_id/issues/gantt' |
|
63 | 63 | gantts_routes.connect '/projects/:project_id/issues/gantt.:format' |
|
64 | 64 | gantts_routes.connect '/issues/gantt.:format' |
|
65 | 65 | end |
|
66 | 66 | |
|
67 | 67 | map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes| |
|
68 | 68 | calendars_routes.connect '/projects/:project_id/issues/calendar' |
|
69 | 69 | calendars_routes.connect '/issues/calendar' |
|
70 | 70 | end |
|
71 | 71 | |
|
72 | 72 | map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports| |
|
73 | 73 | reports.connect 'projects/:id/issues/report', :action => 'issue_report' |
|
74 | 74 | reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details' |
|
75 | 75 | end |
|
76 | 76 | |
|
77 | 77 | map.connect 'my/account', :controller => 'my', :action => 'account', |
|
78 | 78 | :conditions => {:method => [:get, :post]} |
|
79 | 79 | map.connect 'my/page', :controller => 'my', :action => 'page', |
|
80 | 80 | :conditions => {:method => :get} |
|
81 | 81 | # Redirects to my/page |
|
82 | 82 | map.connect 'my', :controller => 'my', :action => 'index', |
|
83 | 83 | :conditions => {:method => :get} |
|
84 | 84 | map.connect 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', |
|
85 | 85 | :conditions => {:method => :post} |
|
86 | 86 | map.connect 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', |
|
87 | 87 | :conditions => {:method => :post} |
|
88 | 88 | map.connect 'my/password', :controller => 'my', :action => 'password', |
|
89 | 89 | :conditions => {:method => [:get, :post]} |
|
90 | 90 | map.connect 'my/page_layout', :controller => 'my', :action => 'page_layout', |
|
91 | 91 | :conditions => {:method => :get} |
|
92 | 92 | map.connect 'my/add_block', :controller => 'my', :action => 'add_block', |
|
93 | 93 | :conditions => {:method => :post} |
|
94 | 94 | map.connect 'my/remove_block', :controller => 'my', :action => 'remove_block', |
|
95 | 95 | :conditions => {:method => :post} |
|
96 | 96 | map.connect 'my/order_blocks', :controller => 'my', :action => 'order_blocks', |
|
97 | 97 | :conditions => {:method => :post} |
|
98 | 98 | |
|
99 | map.connect 'projects/:id/members/new', :controller => 'members', | |
|
100 | :action => 'new', :conditions => { :method => :post } | |
|
101 | map.connect 'members/edit/:id', :controller => 'members', | |
|
102 | :action => 'edit', :id => /\d+/, :conditions => { :method => :post } | |
|
103 | map.connect 'members/destroy/:id', :controller => 'members', | |
|
104 | :action => 'destroy', :id => /\d+/, :conditions => { :method => :post } | |
|
105 | map.connect 'members/autocomplete_for_member/:id', :controller => 'members', | |
|
106 | :action => 'autocomplete_for_member', :conditions => { :method => :post } | |
|
107 | ||
|
108 | 99 | map.with_options :controller => 'users' do |users| |
|
109 | 100 | users.user_membership 'users/:id/memberships/:membership_id', |
|
110 | 101 | :action => 'edit_membership', |
|
111 | 102 | :conditions => {:method => :put} |
|
112 | 103 | users.connect 'users/:id/memberships/:membership_id', |
|
113 | 104 | :action => 'destroy_membership', |
|
114 | 105 | :conditions => {:method => :delete} |
|
115 | 106 | users.user_memberships 'users/:id/memberships', |
|
116 | 107 | :action => 'edit_membership', |
|
117 | 108 | :conditions => {:method => :post} |
|
118 | 109 | end |
|
119 | 110 | map.resources :users |
|
120 | 111 | |
|
121 | 112 | # For nice "roadmap" in the url for the index action |
|
122 | 113 | map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index' |
|
123 | 114 | |
|
124 | 115 | map.preview_news '/news/preview', :controller => 'previews', :action => 'news' |
|
125 | 116 | map.connect 'news/:id/comments', :controller => 'comments', |
|
126 | 117 | :action => 'create', :conditions => {:method => :post} |
|
127 | 118 | map.connect 'news/:id/comments/:comment_id', :controller => 'comments', |
|
128 | 119 | :action => 'destroy', :conditions => {:method => :delete} |
|
129 | 120 | |
|
130 | 121 | map.connect 'watchers/new', :controller=> 'watchers', :action => 'new', |
|
131 | 122 | :conditions => {:method => :get} |
|
132 | 123 | map.connect 'watchers', :controller=> 'watchers', :action => 'create', |
|
133 | 124 | :conditions => {:method => :post} |
|
134 | 125 | map.connect 'watchers/destroy', :controller=> 'watchers', :action => 'destroy', |
|
135 | 126 | :conditions => {:method => :post} |
|
136 | 127 | map.connect 'watchers/watch', :controller=> 'watchers', :action => 'watch', |
|
137 | 128 | :conditions => {:method => :post} |
|
138 | 129 | map.connect 'watchers/unwatch', :controller=> 'watchers', :action => 'unwatch', |
|
139 | 130 | :conditions => {:method => :post} |
|
140 | 131 | map.connect 'watchers/autocomplete_for_user', :controller=> 'watchers', :action => 'autocomplete_for_user', |
|
141 | 132 | :conditions => {:method => :get} |
|
142 | 133 | |
|
143 | 134 | # TODO: port to be part of the resources route(s) |
|
144 | 135 | map.with_options :conditions => {:method => :get} do |project_views| |
|
145 | 136 | project_views.connect 'projects/:id/settings/:tab', |
|
146 | 137 | :controller => 'projects', :action => 'settings' |
|
147 | 138 | project_views.connect 'projects/:project_id/issues/:copy_from/copy', |
|
148 | 139 | :controller => 'issues', :action => 'new' |
|
149 | 140 | end |
|
150 | 141 | |
|
151 | 142 | map.resources :projects, :member => { |
|
152 | 143 | :copy => [:get, :post], |
|
153 | 144 | :settings => :get, |
|
154 | 145 | :modules => :post, |
|
155 | 146 | :archive => :post, |
|
156 | 147 | :unarchive => :post |
|
157 | 148 | } do |project| |
|
158 | 149 | project.resource :enumerations, :controller => 'project_enumerations', |
|
159 | 150 | :only => [:update, :destroy] |
|
160 | 151 | # issue form update |
|
161 | 152 | project.issue_form 'issues/new', :controller => 'issues', |
|
162 | 153 | :action => 'new', :conditions => {:method => [:post, :put]} |
|
163 | 154 | project.resources :issues, :only => [:index, :new, :create] do |issues| |
|
164 | 155 | issues.resources :time_entries, :controller => 'timelog', |
|
165 | 156 | :collection => {:report => :get} |
|
166 | 157 | end |
|
167 | 158 | |
|
168 | 159 | project.resources :files, :only => [:index, :new, :create] |
|
169 | 160 | project.resources :versions, :shallow => true, |
|
170 | 161 | :collection => {:close_completed => :put}, |
|
171 | 162 | :member => {:status_by => :post} |
|
172 | 163 | project.resources :news, :shallow => true |
|
173 | 164 | project.resources :time_entries, :controller => 'timelog', |
|
174 | 165 | :collection => {:report => :get} |
|
175 | 166 | project.resources :queries, :only => [:new, :create] |
|
176 | 167 | project.resources :issue_categories, :shallow => true |
|
177 | 168 | project.resources :documents, :shallow => true, :member => {:add_attachment => :post} |
|
178 | 169 | project.resources :boards |
|
179 | 170 | project.resources :repositories, :shallow => true, :except => [:index, :show], |
|
180 | 171 | :member => {:committers => [:get, :post]} |
|
172 | project.resources :memberships, :shallow => true, :controller => 'members', | |
|
173 | :only => [:create, :update, :destroy], | |
|
174 | :collection => {:autocomplete => :get} | |
|
181 | 175 | |
|
182 | 176 | project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get} |
|
183 | 177 | project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get} |
|
184 | 178 | project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil |
|
185 | 179 | project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff' |
|
186 | 180 | project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate' |
|
187 | 181 | project.resources :wiki, :except => [:new, :create], :member => { |
|
188 | 182 | :rename => [:get, :post], |
|
189 | 183 | :history => :get, |
|
190 | 184 | :preview => :any, |
|
191 | 185 | :protect => :post, |
|
192 | 186 | :add_attachment => :post |
|
193 | 187 | }, :collection => { |
|
194 | 188 | :export => :get, |
|
195 | 189 | :date_index => :get |
|
196 | 190 | } |
|
197 | 191 | end |
|
198 | 192 | |
|
199 | 193 | map.connect 'news', :controller => 'news', :action => 'index' |
|
200 | 194 | map.connect 'news.:format', :controller => 'news', :action => 'index' |
|
201 | 195 | |
|
202 | 196 | map.resources :queries, :except => [:show] |
|
203 | 197 | map.resources :issues, |
|
204 | 198 | :collection => {:bulk_edit => [:get, :post], :bulk_update => :post} do |issues| |
|
205 | 199 | issues.resources :time_entries, :controller => 'timelog', |
|
206 | 200 | :collection => {:report => :get} |
|
207 | 201 | issues.resources :relations, :shallow => true, |
|
208 | 202 | :controller => 'issue_relations', |
|
209 | 203 | :only => [:index, :show, :create, :destroy] |
|
210 | 204 | end |
|
211 | 205 | # Bulk deletion |
|
212 | 206 | map.connect '/issues', :controller => 'issues', :action => 'destroy', |
|
213 | 207 | :conditions => {:method => :delete} |
|
214 | 208 | |
|
215 | 209 | map.connect '/time_entries/destroy', |
|
216 | 210 | :controller => 'timelog', :action => 'destroy', |
|
217 | 211 | :conditions => { :method => :delete } |
|
218 | 212 | map.time_entries_context_menu '/time_entries/context_menu', |
|
219 | 213 | :controller => 'context_menus', :action => 'time_entries' |
|
220 | 214 | |
|
221 | 215 | map.resources :time_entries, :controller => 'timelog', |
|
222 | 216 | :collection => {:report => :get, :bulk_edit => :get, :bulk_update => :post} |
|
223 | 217 | |
|
224 | 218 | map.with_options :controller => 'activities', :action => 'index', |
|
225 | 219 | :conditions => {:method => :get} do |activity| |
|
226 | 220 | activity.connect 'projects/:id/activity' |
|
227 | 221 | activity.connect 'projects/:id/activity.:format' |
|
228 | 222 | activity.connect 'activity', :id => nil |
|
229 | 223 | activity.connect 'activity.:format', :id => nil |
|
230 | 224 | end |
|
231 | 225 | |
|
232 | 226 | map.with_options :controller => 'repositories' do |repositories| |
|
233 | 227 | repositories.with_options :conditions => {:method => :get} do |repository_views| |
|
234 | 228 | repository_views.connect 'projects/:id/repository', |
|
235 | 229 | :action => 'show' |
|
236 | 230 | |
|
237 | 231 | repository_views.connect 'projects/:id/repository/:repository_id/statistics', |
|
238 | 232 | :action => 'stats' |
|
239 | 233 | repository_views.connect 'projects/:id/repository/:repository_id/graph', |
|
240 | 234 | :action => 'graph' |
|
241 | 235 | |
|
242 | 236 | repository_views.connect 'projects/:id/repository/statistics', |
|
243 | 237 | :action => 'stats' |
|
244 | 238 | repository_views.connect 'projects/:id/repository/graph', |
|
245 | 239 | :action => 'graph' |
|
246 | 240 | |
|
247 | 241 | repository_views.connect 'projects/:id/repository/:repository_id/revisions', |
|
248 | 242 | :action => 'revisions' |
|
249 | 243 | repository_views.connect 'projects/:id/repository/:repository_id/revisions.:format', |
|
250 | 244 | :action => 'revisions' |
|
251 | 245 | repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev', |
|
252 | 246 | :action => 'revision' |
|
253 | 247 | repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues', |
|
254 | 248 | :action => 'add_related_issue', :conditions => {:method => :post} |
|
255 | 249 | repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', |
|
256 | 250 | :action => 'remove_related_issue', :conditions => {:method => :delete} |
|
257 | 251 | repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff', |
|
258 | 252 | :action => 'diff' |
|
259 | 253 | repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff.:format', |
|
260 | 254 | :action => 'diff' |
|
261 | 255 | repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/raw/*path', |
|
262 | 256 | :action => 'entry', :format => 'raw' |
|
263 | 257 | repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/:action/*path', |
|
264 | 258 | :requirements => { |
|
265 | 259 | :action => /(browse|show|entry|changes|annotate|diff)/, |
|
266 | 260 | :rev => /[a-z0-9\.\-_]+/ |
|
267 | 261 | } |
|
268 | 262 | repository_views.connect 'projects/:id/repository/:repository_id/raw/*path', |
|
269 | 263 | :action => 'entry', :format => 'raw' |
|
270 | 264 | repository_views.connect 'projects/:id/repository/:repository_id/:action/*path', |
|
271 | 265 | :requirements => { :action => /(browse|show|entry|changes|annotate|diff)/ } |
|
272 | 266 | |
|
273 | 267 | repository_views.connect 'projects/:id/repository/revisions', |
|
274 | 268 | :action => 'revisions' |
|
275 | 269 | repository_views.connect 'projects/:id/repository/revisions.:format', |
|
276 | 270 | :action => 'revisions' |
|
277 | 271 | repository_views.connect 'projects/:id/repository/revisions/:rev', |
|
278 | 272 | :action => 'revision' |
|
279 | 273 | repository_views.connect 'projects/:id/repository/revisions/:rev/issues', |
|
280 | 274 | :action => 'add_related_issue', :conditions => {:method => :post} |
|
281 | 275 | repository_views.connect 'projects/:id/repository/revisions/:rev/issues/:issue_id', |
|
282 | 276 | :action => 'remove_related_issue', :conditions => {:method => :delete} |
|
283 | 277 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff', |
|
284 | 278 | :action => 'diff' |
|
285 | 279 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', |
|
286 | 280 | :action => 'diff' |
|
287 | 281 | repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', |
|
288 | 282 | :action => 'entry', :format => 'raw' |
|
289 | 283 | repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', |
|
290 | 284 | :requirements => { |
|
291 | 285 | :action => /(browse|show|entry|changes|annotate|diff)/, |
|
292 | 286 | :rev => /[a-z0-9\.\-_]+/ |
|
293 | 287 | } |
|
294 | 288 | repository_views.connect 'projects/:id/repository/raw/*path', |
|
295 | 289 | :action => 'entry', :format => 'raw' |
|
296 | 290 | repository_views.connect 'projects/:id/repository/:action/*path', |
|
297 | 291 | :requirements => { :action => /(browse|show|entry|changes|annotate|diff)/ } |
|
298 | 292 | |
|
299 | 293 | repository_views.connect 'projects/:id/repository/:repository_id', |
|
300 | 294 | :action => 'show' |
|
301 | 295 | end |
|
302 | 296 | |
|
303 | 297 | repositories.connect 'projects/:id/repository/revision', |
|
304 | 298 | :action => 'revision', |
|
305 | 299 | :conditions => {:method => [:get, :post]} |
|
306 | 300 | end |
|
307 | 301 | |
|
308 | 302 | # additional routes for having the file name at the end of url |
|
309 | 303 | map.connect 'attachments/:id/:filename', :controller => 'attachments', |
|
310 | 304 | :action => 'show', :id => /\d+/, :filename => /.*/, |
|
311 | 305 | :conditions => {:method => :get} |
|
312 | 306 | map.connect 'attachments/download/:id/:filename', :controller => 'attachments', |
|
313 | 307 | :action => 'download', :id => /\d+/, :filename => /.*/, |
|
314 | 308 | :conditions => {:method => :get} |
|
315 | 309 | map.connect 'attachments/download/:id', :controller => 'attachments', |
|
316 | 310 | :action => 'download', :id => /\d+/, |
|
317 | 311 | :conditions => {:method => :get} |
|
318 | 312 | map.resources :attachments, :only => [:show, :destroy] |
|
319 | 313 | |
|
320 | 314 | map.resources :groups, :member => {:autocomplete_for_user => :get} |
|
321 | 315 | map.group_users 'groups/:id/users', :controller => 'groups', |
|
322 | 316 | :action => 'add_users', :id => /\d+/, |
|
323 | 317 | :conditions => {:method => :post} |
|
324 | 318 | map.group_user 'groups/:id/users/:user_id', :controller => 'groups', |
|
325 | 319 | :action => 'remove_user', :id => /\d+/, |
|
326 | 320 | :conditions => {:method => :delete} |
|
327 | 321 | map.connect 'groups/destroy_membership/:id', :controller => 'groups', |
|
328 | 322 | :action => 'destroy_membership', :id => /\d+/, |
|
329 | 323 | :conditions => {:method => :post} |
|
330 | 324 | map.connect 'groups/edit_membership/:id', :controller => 'groups', |
|
331 | 325 | :action => 'edit_membership', :id => /\d+/, |
|
332 | 326 | :conditions => {:method => :post} |
|
333 | 327 | |
|
334 | 328 | map.resources :trackers, :except => :show |
|
335 | 329 | map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post} |
|
336 | 330 | map.resources :custom_fields, :except => :show |
|
337 | 331 | map.resources :roles, :except => :show, :collection => {:permissions => [:get, :post]} |
|
338 | 332 | map.resources :enumerations, :except => :show |
|
339 | 333 | |
|
340 | 334 | map.connect 'search', :controller => 'search', :action => 'index', :conditions => {:method => :get} |
|
341 | 335 | |
|
342 | 336 | map.connect 'mail_handler', :controller => 'mail_handler', |
|
343 | 337 | :action => 'index', :conditions => {:method => :post} |
|
344 | 338 | |
|
345 | 339 | map.connect 'admin', :controller => 'admin', :action => 'index', |
|
346 | 340 | :conditions => {:method => :get} |
|
347 | 341 | map.connect 'admin/projects', :controller => 'admin', :action => 'projects', |
|
348 | 342 | :conditions => {:method => :get} |
|
349 | 343 | map.connect 'admin/plugins', :controller => 'admin', :action => 'plugins', |
|
350 | 344 | :conditions => {:method => :get} |
|
351 | 345 | map.connect 'admin/info', :controller => 'admin', :action => 'info', |
|
352 | 346 | :conditions => {:method => :get} |
|
353 | 347 | map.connect 'admin/test_email', :controller => 'admin', :action => 'test_email', |
|
354 | 348 | :conditions => {:method => :get} |
|
355 | 349 | map.connect 'admin/default_configuration', :controller => 'admin', |
|
356 | 350 | :action => 'default_configuration', :conditions => {:method => :post} |
|
357 | 351 | |
|
358 | 352 | # Used by AuthSourcesControllerTest |
|
359 | 353 | # TODO : refactor *AuthSourcesController to remove these routes |
|
360 | 354 | map.connect 'auth_sources', :controller => 'auth_sources', |
|
361 | 355 | :action => 'index', :conditions => {:method => :get} |
|
362 | 356 | map.connect 'auth_sources/new', :controller => 'auth_sources', |
|
363 | 357 | :action => 'new', :conditions => {:method => :get} |
|
364 | 358 | map.connect 'auth_sources/create', :controller => 'auth_sources', |
|
365 | 359 | :action => 'create', :conditions => {:method => :post} |
|
366 | 360 | map.connect 'auth_sources/destroy/:id', :controller => 'auth_sources', |
|
367 | 361 | :action => 'destroy', :id => /\d+/, :conditions => {:method => :post} |
|
368 | 362 | map.connect 'auth_sources/test_connection/:id', :controller => 'auth_sources', |
|
369 | 363 | :action => 'test_connection', :conditions => {:method => :get} |
|
370 | 364 | map.connect 'auth_sources/edit/:id', :controller => 'auth_sources', |
|
371 | 365 | :action => 'edit', :id => /\d+/, :conditions => {:method => :get} |
|
372 | 366 | map.connect 'auth_sources/update/:id', :controller => 'auth_sources', |
|
373 | 367 | :action => 'update', :id => /\d+/, :conditions => {:method => :post} |
|
374 | 368 | |
|
375 | 369 | map.connect 'ldap_auth_sources', :controller => 'ldap_auth_sources', |
|
376 | 370 | :action => 'index', :conditions => {:method => :get} |
|
377 | 371 | map.connect 'ldap_auth_sources/new', :controller => 'ldap_auth_sources', |
|
378 | 372 | :action => 'new', :conditions => {:method => :get} |
|
379 | 373 | map.connect 'ldap_auth_sources/create', :controller => 'ldap_auth_sources', |
|
380 | 374 | :action => 'create', :conditions => {:method => :post} |
|
381 | 375 | map.connect 'ldap_auth_sources/destroy/:id', :controller => 'ldap_auth_sources', |
|
382 | 376 | :action => 'destroy', :id => /\d+/, :conditions => {:method => :post} |
|
383 | 377 | map.connect 'ldap_auth_sources/test_connection/:id', :controller => 'ldap_auth_sources', |
|
384 | 378 | :action => 'test_connection', :conditions => {:method => :get} |
|
385 | 379 | map.connect 'ldap_auth_sources/edit/:id', :controller => 'ldap_auth_sources', |
|
386 | 380 | :action => 'edit', :id => /\d+/, :conditions => {:method => :get} |
|
387 | 381 | map.connect 'ldap_auth_sources/update/:id', :controller => 'ldap_auth_sources', |
|
388 | 382 | :action => 'update', :id => /\d+/, :conditions => {:method => :post} |
|
389 | 383 | |
|
390 | 384 | map.connect 'workflows', :controller => 'workflows', |
|
391 | 385 | :action => 'index', :conditions => {:method => :get} |
|
392 | 386 | map.connect 'workflows/edit', :controller => 'workflows', |
|
393 | 387 | :action => 'edit', :conditions => {:method => [:get, :post]} |
|
394 | 388 | map.connect 'workflows/copy', :controller => 'workflows', |
|
395 | 389 | :action => 'copy', :conditions => {:method => [:get, :post]} |
|
396 | 390 | |
|
397 | 391 | map.connect 'settings', :controller => 'settings', |
|
398 | 392 | :action => 'index', :conditions => {:method => :get} |
|
399 | 393 | map.connect 'settings/edit', :controller => 'settings', |
|
400 | 394 | :action => 'edit', :conditions => {:method => [:get, :post]} |
|
401 | 395 | map.connect 'settings/plugin/:id', :controller => 'settings', |
|
402 | 396 | :action => 'plugin', :conditions => {:method => [:get, :post]} |
|
403 | 397 | |
|
404 | 398 | map.with_options :controller => 'sys' do |sys| |
|
405 | 399 | sys.connect 'sys/projects.:format', |
|
406 | 400 | :action => 'projects', |
|
407 | 401 | :conditions => {:method => :get} |
|
408 | 402 | sys.connect 'sys/projects/:id/repository.:format', |
|
409 | 403 | :action => 'create_project_repository', |
|
410 | 404 | :conditions => {:method => :post} |
|
411 | 405 | sys.connect 'sys/fetch_changesets', |
|
412 | 406 | :action => 'fetch_changesets', |
|
413 | 407 | :conditions => {:method => :get} |
|
414 | 408 | end |
|
415 | 409 | |
|
416 | 410 | map.connect 'robots.txt', :controller => 'welcome', |
|
417 | 411 | :action => 'robots', :conditions => {:method => :get} |
|
418 | 412 | |
|
419 | 413 | # Used for OpenID |
|
420 | 414 | map.root :controller => 'account', :action => 'login' |
|
421 | 415 | end |
@@ -1,238 +1,238 | |||
|
1 | 1 | require 'redmine/access_control' |
|
2 | 2 | require 'redmine/menu_manager' |
|
3 | 3 | require 'redmine/activity' |
|
4 | 4 | require 'redmine/search' |
|
5 | 5 | require 'redmine/custom_field_format' |
|
6 | 6 | require 'redmine/mime_type' |
|
7 | 7 | require 'redmine/core_ext' |
|
8 | 8 | require 'redmine/themes' |
|
9 | 9 | require 'redmine/hook' |
|
10 | 10 | require 'redmine/plugin' |
|
11 | 11 | require 'redmine/notifiable' |
|
12 | 12 | require 'redmine/wiki_formatting' |
|
13 | 13 | require 'redmine/scm/base' |
|
14 | 14 | |
|
15 | 15 | begin |
|
16 | 16 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) |
|
17 | 17 | rescue LoadError |
|
18 | 18 | # RMagick is not available |
|
19 | 19 | end |
|
20 | 20 | |
|
21 | 21 | if RUBY_VERSION < '1.9' |
|
22 | 22 | require 'faster_csv' |
|
23 | 23 | else |
|
24 | 24 | require 'csv' |
|
25 | 25 | FCSV = CSV |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | Redmine::Scm::Base.add "Subversion" |
|
29 | 29 | Redmine::Scm::Base.add "Darcs" |
|
30 | 30 | Redmine::Scm::Base.add "Mercurial" |
|
31 | 31 | Redmine::Scm::Base.add "Cvs" |
|
32 | 32 | Redmine::Scm::Base.add "Bazaar" |
|
33 | 33 | Redmine::Scm::Base.add "Git" |
|
34 | 34 | Redmine::Scm::Base.add "Filesystem" |
|
35 | 35 | |
|
36 | 36 | Redmine::CustomFieldFormat.map do |fields| |
|
37 | 37 | fields.register Redmine::CustomFieldFormat.new('string', :label => :label_string, :order => 1) |
|
38 | 38 | fields.register Redmine::CustomFieldFormat.new('text', :label => :label_text, :order => 2) |
|
39 | 39 | fields.register Redmine::CustomFieldFormat.new('int', :label => :label_integer, :order => 3) |
|
40 | 40 | fields.register Redmine::CustomFieldFormat.new('float', :label => :label_float, :order => 4) |
|
41 | 41 | fields.register Redmine::CustomFieldFormat.new('list', :label => :label_list, :order => 5) |
|
42 | 42 | fields.register Redmine::CustomFieldFormat.new('date', :label => :label_date, :order => 6) |
|
43 | 43 | fields.register Redmine::CustomFieldFormat.new('bool', :label => :label_boolean, :order => 7) |
|
44 | 44 | fields.register Redmine::CustomFieldFormat.new('user', :label => :label_user, :only => %w(Issue TimeEntry Version Project), :edit_as => 'list', :order => 8) |
|
45 | 45 | fields.register Redmine::CustomFieldFormat.new('version', :label => :label_version, :only => %w(Issue TimeEntry Version Project), :edit_as => 'list', :order => 9) |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | # Permissions |
|
49 | 49 | Redmine::AccessControl.map do |map| |
|
50 | 50 | map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true |
|
51 | 51 | map.permission :search_project, {:search => :index}, :public => true |
|
52 | 52 | map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin |
|
53 | 53 | map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member |
|
54 | 54 | map.permission :select_project_modules, {:projects => :modules}, :require => :member |
|
55 |
map.permission :manage_members, {:projects => :settings, :members => [: |
|
|
55 | map.permission :manage_members, {:projects => :settings, :members => [:create, :update, :destroy, :autocomplete]}, :require => :member | |
|
56 | 56 | map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member |
|
57 | 57 | map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member |
|
58 | 58 | |
|
59 | 59 | map.project_module :issue_tracking do |map| |
|
60 | 60 | # Issue categories |
|
61 | 61 | map.permission :manage_categories, {:projects => :settings, :issue_categories => [:index, :show, :new, :create, :edit, :update, :destroy]}, :require => :member |
|
62 | 62 | # Issues |
|
63 | 63 | map.permission :view_issues, {:issues => [:index, :show], |
|
64 | 64 | :auto_complete => [:issues], |
|
65 | 65 | :context_menus => [:issues], |
|
66 | 66 | :versions => [:index, :show, :status_by], |
|
67 | 67 | :journals => [:index, :diff], |
|
68 | 68 | :queries => :index, |
|
69 | 69 | :reports => [:issue_report, :issue_report_details]} |
|
70 | 70 | map.permission :add_issues, {:issues => [:new, :create, :update_form]} |
|
71 | 71 | map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new]} |
|
72 | 72 | map.permission :manage_issue_relations, {:issue_relations => [:index, :show, :create, :destroy]} |
|
73 | 73 | map.permission :manage_subtasks, {} |
|
74 | 74 | map.permission :set_issues_private, {} |
|
75 | 75 | map.permission :set_own_issues_private, {}, :require => :loggedin |
|
76 | 76 | map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]} |
|
77 | 77 | map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin |
|
78 | 78 | map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin |
|
79 | 79 | map.permission :move_issues, {:issues => [:bulk_edit, :bulk_update]}, :require => :loggedin |
|
80 | 80 | map.permission :delete_issues, {:issues => :destroy}, :require => :member |
|
81 | 81 | # Queries |
|
82 | 82 | map.permission :manage_public_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :member |
|
83 | 83 | map.permission :save_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin |
|
84 | 84 | # Watchers |
|
85 | 85 | map.permission :view_issue_watchers, {} |
|
86 | 86 | map.permission :add_issue_watchers, {:watchers => :new} |
|
87 | 87 | map.permission :delete_issue_watchers, {:watchers => :destroy} |
|
88 | 88 | end |
|
89 | 89 | |
|
90 | 90 | map.project_module :time_tracking do |map| |
|
91 | 91 | map.permission :log_time, {:timelog => [:new, :create]}, :require => :loggedin |
|
92 | 92 | map.permission :view_time_entries, :timelog => [:index, :report, :show] |
|
93 | 93 | map.permission :edit_time_entries, {:timelog => [:edit, :update, :destroy, :bulk_edit, :bulk_update]}, :require => :member |
|
94 | 94 | map.permission :edit_own_time_entries, {:timelog => [:edit, :update, :destroy,:bulk_edit, :bulk_update]}, :require => :loggedin |
|
95 | 95 | map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member |
|
96 | 96 | end |
|
97 | 97 | |
|
98 | 98 | map.project_module :news do |map| |
|
99 | 99 | map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member |
|
100 | 100 | map.permission :view_news, {:news => [:index, :show]}, :public => true |
|
101 | 101 | map.permission :comment_news, {:comments => :create} |
|
102 | 102 | end |
|
103 | 103 | |
|
104 | 104 | map.project_module :documents do |map| |
|
105 | 105 | map.permission :manage_documents, {:documents => [:new, :create, :edit, :update, :destroy, :add_attachment]}, :require => :loggedin |
|
106 | 106 | map.permission :view_documents, :documents => [:index, :show, :download] |
|
107 | 107 | end |
|
108 | 108 | |
|
109 | 109 | map.project_module :files do |map| |
|
110 | 110 | map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin |
|
111 | 111 | map.permission :view_files, :files => :index, :versions => :download |
|
112 | 112 | end |
|
113 | 113 | |
|
114 | 114 | map.project_module :wiki do |map| |
|
115 | 115 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member |
|
116 | 116 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member |
|
117 | 117 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member |
|
118 | 118 | map.permission :view_wiki_pages, :wiki => [:index, :show, :special, :date_index] |
|
119 | 119 | map.permission :export_wiki_pages, :wiki => [:export] |
|
120 | 120 | map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] |
|
121 | 121 | map.permission :edit_wiki_pages, :wiki => [:edit, :update, :preview, :add_attachment] |
|
122 | 122 | map.permission :delete_wiki_pages_attachments, {} |
|
123 | 123 | map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member |
|
124 | 124 | end |
|
125 | 125 | |
|
126 | 126 | map.project_module :repository do |map| |
|
127 | 127 | map.permission :manage_repository, {:repositories => [:new, :create, :edit, :update, :committers, :destroy]}, :require => :member |
|
128 | 128 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] |
|
129 | 129 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] |
|
130 | 130 | map.permission :commit_access, {} |
|
131 | 131 | map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]} |
|
132 | 132 | end |
|
133 | 133 | |
|
134 | 134 | map.project_module :boards do |map| |
|
135 | 135 | map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member |
|
136 | 136 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true |
|
137 | 137 | map.permission :add_messages, {:messages => [:new, :reply, :quote]} |
|
138 | 138 | map.permission :edit_messages, {:messages => :edit}, :require => :member |
|
139 | 139 | map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin |
|
140 | 140 | map.permission :delete_messages, {:messages => :destroy}, :require => :member |
|
141 | 141 | map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin |
|
142 | 142 | end |
|
143 | 143 | |
|
144 | 144 | map.project_module :calendar do |map| |
|
145 | 145 | map.permission :view_calendar, :calendars => [:show, :update] |
|
146 | 146 | end |
|
147 | 147 | |
|
148 | 148 | map.project_module :gantt do |map| |
|
149 | 149 | map.permission :view_gantt, :gantts => [:show, :update] |
|
150 | 150 | end |
|
151 | 151 | end |
|
152 | 152 | |
|
153 | 153 | Redmine::MenuManager.map :top_menu do |menu| |
|
154 | 154 | menu.push :home, :home_path |
|
155 | 155 | menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } |
|
156 | 156 | menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural |
|
157 | 157 | menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true |
|
158 | 158 | menu.push :help, Redmine::Info.help_url, :last => true |
|
159 | 159 | end |
|
160 | 160 | |
|
161 | 161 | Redmine::MenuManager.map :account_menu do |menu| |
|
162 | 162 | menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? } |
|
163 | 163 | menu.push :register, { :controller => 'account', :action => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? } |
|
164 | 164 | menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? } |
|
165 | 165 | menu.push :logout, :signout_path, :if => Proc.new { User.current.logged? } |
|
166 | 166 | end |
|
167 | 167 | |
|
168 | 168 | Redmine::MenuManager.map :application_menu do |menu| |
|
169 | 169 | # Empty |
|
170 | 170 | end |
|
171 | 171 | |
|
172 | 172 | Redmine::MenuManager.map :admin_menu do |menu| |
|
173 | 173 | menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural |
|
174 | 174 | menu.push :users, {:controller => 'users'}, :caption => :label_user_plural |
|
175 | 175 | menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural |
|
176 | 176 | menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions |
|
177 | 177 | menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural |
|
178 | 178 | menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural, |
|
179 | 179 | :html => {:class => 'issue_statuses'} |
|
180 | 180 | menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow |
|
181 | 181 | menu.push :custom_fields, {:controller => 'custom_fields'}, :caption => :label_custom_field_plural, |
|
182 | 182 | :html => {:class => 'custom_fields'} |
|
183 | 183 | menu.push :enumerations, {:controller => 'enumerations'} |
|
184 | 184 | menu.push :settings, {:controller => 'settings'} |
|
185 | 185 | menu.push :ldap_authentication, {:controller => 'ldap_auth_sources', :action => 'index'}, |
|
186 | 186 | :html => {:class => 'server_authentication'} |
|
187 | 187 | menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true |
|
188 | 188 | menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true |
|
189 | 189 | end |
|
190 | 190 | |
|
191 | 191 | Redmine::MenuManager.map :project_menu do |menu| |
|
192 | 192 | menu.push :overview, { :controller => 'projects', :action => 'show' } |
|
193 | 193 | menu.push :activity, { :controller => 'activities', :action => 'index' } |
|
194 | 194 | menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id, |
|
195 | 195 | :if => Proc.new { |p| p.shared_versions.any? } |
|
196 | 196 | menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural |
|
197 | 197 | menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new, |
|
198 | 198 | :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } |
|
199 | 199 | menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt |
|
200 | 200 | menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar |
|
201 | 201 | menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural |
|
202 | 202 | menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural |
|
203 | 203 | menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id, |
|
204 | 204 | :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } |
|
205 | 205 | menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, |
|
206 | 206 | :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural |
|
207 | 207 | menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id |
|
208 | 208 | menu.push :repository, { :controller => 'repositories', :action => 'show' }, |
|
209 | 209 | :if => Proc.new { |p| p.repository && !p.repository.new_record? } |
|
210 | 210 | menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true |
|
211 | 211 | end |
|
212 | 212 | |
|
213 | 213 | Redmine::Activity.map do |activity| |
|
214 | 214 | activity.register :issues, :class_name => %w(Issue Journal) |
|
215 | 215 | activity.register :changesets |
|
216 | 216 | activity.register :news |
|
217 | 217 | activity.register :documents, :class_name => %w(Document Attachment) |
|
218 | 218 | activity.register :files, :class_name => 'Attachment' |
|
219 | 219 | activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false |
|
220 | 220 | activity.register :messages, :default => false |
|
221 | 221 | activity.register :time_entries, :default => false |
|
222 | 222 | end |
|
223 | 223 | |
|
224 | 224 | Redmine::Search.map do |search| |
|
225 | 225 | search.register :issues |
|
226 | 226 | search.register :news |
|
227 | 227 | search.register :documents |
|
228 | 228 | search.register :changesets |
|
229 | 229 | search.register :wiki_pages |
|
230 | 230 | search.register :messages |
|
231 | 231 | search.register :projects |
|
232 | 232 | end |
|
233 | 233 | |
|
234 | 234 | Redmine::WikiFormatting.map do |format| |
|
235 | 235 | format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper |
|
236 | 236 | end |
|
237 | 237 | |
|
238 | 238 | ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler |
@@ -1,110 +1,110 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | require 'members_controller' |
|
20 | 20 | |
|
21 | 21 | # Re-raise errors caught by the controller. |
|
22 | 22 | class MembersController; def rescue_action(e) raise e end; end |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | class MembersControllerTest < ActionController::TestCase |
|
26 | 26 | fixtures :projects, :members, :member_roles, :roles, :users |
|
27 | 27 | |
|
28 | 28 | def setup |
|
29 | 29 | @controller = MembersController.new |
|
30 | 30 | @request = ActionController::TestRequest.new |
|
31 | 31 | @response = ActionController::TestResponse.new |
|
32 | 32 | User.current = nil |
|
33 | 33 | @request.session[:user_id] = 2 |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | def test_create |
|
37 | 37 | assert_difference 'Member.count' do |
|
38 |
post : |
|
|
38 | post :create, :project_id => 1, :membership => {:role_ids => [1], :user_id => 7} | |
|
39 | 39 | end |
|
40 | 40 | assert_redirected_to '/projects/ecookbook/settings/members' |
|
41 | 41 | assert User.find(7).member_of?(Project.find(1)) |
|
42 | 42 | end |
|
43 | 43 | |
|
44 | 44 | def test_create_multiple |
|
45 | 45 | assert_difference 'Member.count', 3 do |
|
46 |
post : |
|
|
46 | post :create, :project_id => 1, :membership => {:role_ids => [1], :user_ids => [7, 8, 9]} | |
|
47 | 47 | end |
|
48 | 48 | assert_redirected_to '/projects/ecookbook/settings/members' |
|
49 | 49 | assert User.find(7).member_of?(Project.find(1)) |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | def test_xhr_create |
|
53 | 53 | assert_difference 'Member.count', 3 do |
|
54 |
post : |
|
|
54 | post :create, :project_id => 1, :membership => {:role_ids => [1], :user_ids => [7, 8, 9]}, :format => "js" | |
|
55 | 55 | end |
|
56 | 56 | assert_select_rjs :replace_html, 'tab-content-members' |
|
57 | 57 | assert User.find(7).member_of?(Project.find(1)) |
|
58 | 58 | assert User.find(8).member_of?(Project.find(1)) |
|
59 | 59 | assert User.find(9).member_of?(Project.find(1)) |
|
60 | 60 | end |
|
61 | 61 | |
|
62 | 62 | def test_xhr_create_with_failure |
|
63 | 63 | assert_no_difference 'Member.count' do |
|
64 |
post : |
|
|
64 | post :create, :project_id => 1, :membership => {:role_ids => [], :user_ids => [7, 8, 9]}, :format => "js" | |
|
65 | 65 | end |
|
66 | 66 | assert_select '#tab-content-members', 0 |
|
67 | 67 | assert @response.body.match(/alert/i), "Alert message not sent" |
|
68 | 68 | end |
|
69 | 69 | |
|
70 | 70 | def test_edit |
|
71 | 71 | assert_no_difference 'Member.count' do |
|
72 |
p |
|
|
72 | put :update, :id => 2, :membership => {:role_ids => [1], :user_id => 3} | |
|
73 | 73 | end |
|
74 | 74 | assert_redirected_to '/projects/ecookbook/settings/members' |
|
75 | 75 | end |
|
76 | 76 | |
|
77 | 77 | def test_xhr_edit |
|
78 | 78 | assert_no_difference 'Member.count' do |
|
79 |
xhr :p |
|
|
79 | xhr :put, :update, :id => 2, :membership => {:role_ids => [1], :user_id => 3} | |
|
80 | 80 | end |
|
81 | 81 | assert_select_rjs :replace_html, 'tab-content-members' |
|
82 | 82 | member = Member.find(2) |
|
83 | 83 | assert_equal [1], member.role_ids |
|
84 | 84 | assert_equal 3, member.user_id |
|
85 | 85 | end |
|
86 | 86 | |
|
87 | 87 | def test_destroy |
|
88 | 88 | assert_difference 'Member.count', -1 do |
|
89 |
|
|
|
89 | delete :destroy, :id => 2 | |
|
90 | 90 | end |
|
91 | 91 | assert_redirected_to '/projects/ecookbook/settings/members' |
|
92 | 92 | assert !User.find(3).member_of?(Project.find(1)) |
|
93 | 93 | end |
|
94 | 94 | |
|
95 | 95 | def test_xhr_destroy |
|
96 | 96 | assert_difference 'Member.count', -1 do |
|
97 |
xhr : |
|
|
97 | xhr :delete, :destroy, :id => 2 | |
|
98 | 98 | end |
|
99 | 99 | assert_select_rjs :replace_html, 'tab-content-members' |
|
100 | 100 | end |
|
101 | 101 | |
|
102 |
def test_autocomplete |
|
|
103 |
get :autocomplete |
|
|
102 | def test_autocomplete | |
|
103 | get :autocomplete, :project_id => 1, :q => 'mis' | |
|
104 | 104 | assert_response :success |
|
105 |
assert_template 'autocomplete |
|
|
105 | assert_template 'autocomplete' | |
|
106 | 106 | |
|
107 | 107 | assert_tag :label, :content => /User Misc/, |
|
108 | :child => { :tag => 'input', :attributes => { :name => 'member[user_ids][]', :value => '8' } } | |
|
108 | :child => { :tag => 'input', :attributes => { :name => 'membership[user_ids][]', :value => '8' } } | |
|
109 | 109 | end |
|
110 | 110 | end |
@@ -1,39 +1,39 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class RoutingMembersTest < ActionController::IntegrationTest |
|
21 | 21 | def test_members |
|
22 | 22 | assert_routing( |
|
23 |
{ :method => 'post', :path => "/projects/5234/members |
|
|
24 |
{ :controller => 'members', :action => ' |
|
|
23 | { :method => 'post', :path => "/projects/5234/memberships" }, | |
|
24 | { :controller => 'members', :action => 'create', :project_id => '5234' } | |
|
25 | 25 | ) |
|
26 | 26 | assert_routing( |
|
27 |
{ :method => 'p |
|
|
28 |
{ :controller => 'members', :action => ' |
|
|
27 | { :method => 'put', :path => "/memberships/5234" }, | |
|
28 | { :controller => 'members', :action => 'update', :id => '5234' } | |
|
29 | 29 | ) |
|
30 | 30 | assert_routing( |
|
31 |
{ :method => ' |
|
|
31 | { :method => 'delete', :path => "/memberships/5234" }, | |
|
32 | 32 | { :controller => 'members', :action => 'destroy', :id => '5234' } |
|
33 | 33 | ) |
|
34 | 34 | assert_routing( |
|
35 |
{ :method => ' |
|
|
36 |
{ :controller => 'members', :action => 'autocomplete |
|
|
35 | { :method => 'get', :path => "/projects/5234/memberships/autocomplete" }, | |
|
36 | { :controller => 'members', :action => 'autocomplete', :project_id => '5234' } | |
|
37 | 37 | ) |
|
38 | 38 | end |
|
39 | 39 | end |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now