@@ -1,81 +1,81 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 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 QueriesController < ApplicationController |
|
19 | 19 | layout 'base' |
|
20 | 20 | before_filter :find_project, :authorize |
|
21 | 21 | |
|
22 | 22 | def index |
|
23 | 23 | @queries = @project.queries.find(:all, |
|
24 | 24 | :order => "name ASC", |
|
25 | 25 | :conditions => ["is_public = ? or user_id = ?", true, (logged_in_user ? logged_in_user.id : 0)]) |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | def new |
|
29 | 29 | @query = Query.new(params[:query]) |
|
30 | 30 | @query.project = @project |
|
31 | 31 | @query.user = logged_in_user |
|
32 | 32 | @query.executed_by = logged_in_user |
|
33 | @query.is_public = false unless current_role.allowed_to?(:manage_pulic_queries) | |
|
33 | @query.is_public = false unless current_role.allowed_to?(:manage_public_queries) | |
|
34 | 34 | |
|
35 | 35 | params[:fields].each do |field| |
|
36 | 36 | @query.add_filter(field, params[:operators][field], params[:values][field]) |
|
37 | 37 | end if params[:fields] |
|
38 | 38 | |
|
39 | 39 | if request.post? and @query.save |
|
40 | 40 | flash[:notice] = l(:notice_successful_create) |
|
41 | 41 | redirect_to :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => @query |
|
42 | 42 | return |
|
43 | 43 | end |
|
44 | 44 | render :layout => false if request.xhr? |
|
45 | 45 | end |
|
46 | 46 | |
|
47 | 47 | def edit |
|
48 | 48 | if request.post? |
|
49 | 49 | @query.filters = {} |
|
50 | 50 | params[:fields].each do |field| |
|
51 | 51 | @query.add_filter(field, params[:operators][field], params[:values][field]) |
|
52 | 52 | end if params[:fields] |
|
53 | 53 | @query.attributes = params[:query] |
|
54 | @query.is_public = false unless current_role.allowed_to?(:manage_pulic_queries) | |
|
54 | @query.is_public = false unless current_role.allowed_to?(:manage_public_queries) | |
|
55 | 55 | |
|
56 | 56 | if @query.save |
|
57 | 57 | flash[:notice] = l(:notice_successful_update) |
|
58 | 58 | redirect_to :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => @query |
|
59 | 59 | end |
|
60 | 60 | end |
|
61 | 61 | end |
|
62 | 62 | |
|
63 | 63 | def destroy |
|
64 | 64 | @query.destroy if request.post? |
|
65 | 65 | redirect_to :controller => 'queries', :project_id => @project |
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | private |
|
69 | 69 | def find_project |
|
70 | 70 | if params[:id] |
|
71 | 71 | @query = Query.find(params[:id]) |
|
72 | 72 | @query.executed_by = logged_in_user |
|
73 | 73 | @project = @query.project |
|
74 | 74 | render_403 unless @query.editable_by?(logged_in_user) |
|
75 | 75 | else |
|
76 | 76 | @project = Project.find(params[:project_id]) |
|
77 | 77 | end |
|
78 | 78 | rescue ActiveRecord::RecordNotFound |
|
79 | 79 | render_404 |
|
80 | 80 | end |
|
81 | 81 | end |
@@ -1,265 +1,265 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 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 Query < ActiveRecord::Base |
|
19 | 19 | belongs_to :project |
|
20 | 20 | belongs_to :user |
|
21 | 21 | serialize :filters |
|
22 | 22 | |
|
23 | 23 | attr_protected :project, :user |
|
24 | 24 | attr_accessor :executed_by |
|
25 | 25 | |
|
26 | 26 | validates_presence_of :name, :on => :save |
|
27 | 27 | validates_length_of :name, :maximum => 255 |
|
28 | 28 | |
|
29 | 29 | @@operators = { "=" => :label_equals, |
|
30 | 30 | "!" => :label_not_equals, |
|
31 | 31 | "o" => :label_open_issues, |
|
32 | 32 | "c" => :label_closed_issues, |
|
33 | 33 | "!*" => :label_none, |
|
34 | 34 | "*" => :label_all, |
|
35 | 35 | ">=" => '>=', |
|
36 | 36 | "<=" => '<=', |
|
37 | 37 | "<t+" => :label_in_less_than, |
|
38 | 38 | ">t+" => :label_in_more_than, |
|
39 | 39 | "t+" => :label_in, |
|
40 | 40 | "t" => :label_today, |
|
41 | 41 | "w" => :label_this_week, |
|
42 | 42 | ">t-" => :label_less_than_ago, |
|
43 | 43 | "<t-" => :label_more_than_ago, |
|
44 | 44 | "t-" => :label_ago, |
|
45 | 45 | "~" => :label_contains, |
|
46 | 46 | "!~" => :label_not_contains } |
|
47 | 47 | |
|
48 | 48 | cattr_reader :operators |
|
49 | 49 | |
|
50 | 50 | @@operators_by_filter_type = { :list => [ "=", "!" ], |
|
51 | 51 | :list_status => [ "o", "=", "!", "c", "*" ], |
|
52 | 52 | :list_optional => [ "=", "!", "!*", "*" ], |
|
53 | 53 | :list_one_or_more => [ "*", "=" ], |
|
54 | 54 | :date => [ "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-" ], |
|
55 | 55 | :date_past => [ ">t-", "<t-", "t-", "t", "w" ], |
|
56 | 56 | :string => [ "=", "~", "!", "!~" ], |
|
57 | 57 | :text => [ "~", "!~" ], |
|
58 | 58 | :integer => [ "=", ">=", "<=" ] } |
|
59 | 59 | |
|
60 | 60 | cattr_reader :operators_by_filter_type |
|
61 | 61 | |
|
62 | 62 | def initialize(attributes = nil) |
|
63 | 63 | super attributes |
|
64 | 64 | self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} } |
|
65 | 65 | end |
|
66 | 66 | |
|
67 | 67 | def executed_by=(user) |
|
68 | 68 | @executed_by = user |
|
69 | 69 | set_language_if_valid(user.language) if user |
|
70 | 70 | end |
|
71 | 71 | |
|
72 | 72 | def validate |
|
73 | 73 | filters.each_key do |field| |
|
74 | 74 | errors.add label_for(field), :activerecord_error_blank unless |
|
75 | 75 | # filter requires one or more values |
|
76 | 76 | (values_for(field) and !values_for(field).first.empty?) or |
|
77 | 77 | # filter doesn't require any value |
|
78 | 78 | ["o", "c", "!*", "*", "t", "w"].include? operator_for(field) |
|
79 | 79 | end if filters |
|
80 | 80 | end |
|
81 | 81 | |
|
82 | 82 | def editable_by?(user) |
|
83 | 83 | return false unless user |
|
84 | 84 | return true if !is_public && self.user_id == user.id |
|
85 | is_public && user.allowed_to?(:manage_pulic_queries, project) | |
|
85 | is_public && user.allowed_to?(:manage_public_queries, project) | |
|
86 | 86 | end |
|
87 | 87 | |
|
88 | 88 | def available_filters |
|
89 | 89 | return @available_filters if @available_filters |
|
90 | 90 | @available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } }, |
|
91 | 91 | "tracker_id" => { :type => :list, :order => 2, :values => Tracker.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } }, |
|
92 | 92 | "priority_id" => { :type => :list, :order => 3, :values => Enumeration.find(:all, :conditions => ['opt=?','IPRI']).collect{|s| [s.name, s.id.to_s] } }, |
|
93 | 93 | "subject" => { :type => :text, :order => 8 }, |
|
94 | 94 | "created_on" => { :type => :date_past, :order => 9 }, |
|
95 | 95 | "updated_on" => { :type => :date_past, :order => 10 }, |
|
96 | 96 | "start_date" => { :type => :date, :order => 11 }, |
|
97 | 97 | "due_date" => { :type => :date, :order => 12 }, |
|
98 | 98 | "done_ratio" => { :type => :integer, :order => 13 }} |
|
99 | 99 | |
|
100 | 100 | user_values = [] |
|
101 | 101 | if project |
|
102 | 102 | user_values += project.users.collect{|s| [s.name, s.id.to_s] } |
|
103 | 103 | elsif executed_by |
|
104 | 104 | user_values << ["<< #{l(:label_me)} >>", "me"] if executed_by |
|
105 | 105 | # members of the user's projects |
|
106 | 106 | user_values += executed_by.projects.collect(&:users).flatten.uniq.sort.collect{|s| [s.name, s.id.to_s] } |
|
107 | 107 | end |
|
108 | 108 | @available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty? |
|
109 | 109 | @available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty? |
|
110 | 110 | |
|
111 | 111 | if project |
|
112 | 112 | # project specific filters |
|
113 | 113 | @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } } |
|
114 | 114 | @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } } |
|
115 | 115 | unless @project.active_children.empty? |
|
116 | 116 | @available_filters["subproject_id"] = { :type => :list_one_or_more, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } } |
|
117 | 117 | end |
|
118 | 118 | @project.all_custom_fields.select(&:is_filter?).each do |field| |
|
119 | 119 | case field.field_format |
|
120 | 120 | when "string", "int" |
|
121 | 121 | options = { :type => :string, :order => 20 } |
|
122 | 122 | when "text" |
|
123 | 123 | options = { :type => :text, :order => 20 } |
|
124 | 124 | when "list" |
|
125 | 125 | options = { :type => :list_optional, :values => field.possible_values, :order => 20} |
|
126 | 126 | when "date" |
|
127 | 127 | options = { :type => :date, :order => 20 } |
|
128 | 128 | when "bool" |
|
129 | 129 | options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 } |
|
130 | 130 | end |
|
131 | 131 | @available_filters["cf_#{field.id}"] = options.merge({ :name => field.name }) |
|
132 | 132 | end |
|
133 | 133 | # remove category filter if no category defined |
|
134 | 134 | @available_filters.delete "category_id" if @available_filters["category_id"][:values].empty? |
|
135 | 135 | end |
|
136 | 136 | @available_filters |
|
137 | 137 | end |
|
138 | 138 | |
|
139 | 139 | def add_filter(field, operator, values) |
|
140 | 140 | # values must be an array |
|
141 | 141 | return unless values and values.is_a? Array # and !values.first.empty? |
|
142 | 142 | # check if field is defined as an available filter |
|
143 | 143 | if available_filters.has_key? field |
|
144 | 144 | filter_options = available_filters[field] |
|
145 | 145 | # check if operator is allowed for that filter |
|
146 | 146 | #if @@operators_by_filter_type[filter_options[:type]].include? operator |
|
147 | 147 | # allowed_values = values & ([""] + (filter_options[:values] || []).collect {|val| val[1]}) |
|
148 | 148 | # filters[field] = {:operator => operator, :values => allowed_values } if (allowed_values.first and !allowed_values.first.empty?) or ["o", "c", "!*", "*", "t"].include? operator |
|
149 | 149 | #end |
|
150 | 150 | filters[field] = {:operator => operator, :values => values } |
|
151 | 151 | end |
|
152 | 152 | end |
|
153 | 153 | |
|
154 | 154 | def add_short_filter(field, expression) |
|
155 | 155 | return unless expression |
|
156 | 156 | parms = expression.scan(/^(o|c|\!|\*)?(.*)$/).first |
|
157 | 157 | add_filter field, (parms[0] || "="), [parms[1] || ""] |
|
158 | 158 | end |
|
159 | 159 | |
|
160 | 160 | def has_filter?(field) |
|
161 | 161 | filters and filters[field] |
|
162 | 162 | end |
|
163 | 163 | |
|
164 | 164 | def operator_for(field) |
|
165 | 165 | has_filter?(field) ? filters[field][:operator] : nil |
|
166 | 166 | end |
|
167 | 167 | |
|
168 | 168 | def values_for(field) |
|
169 | 169 | has_filter?(field) ? filters[field][:values] : nil |
|
170 | 170 | end |
|
171 | 171 | |
|
172 | 172 | def label_for(field) |
|
173 | 173 | label = @available_filters[field][:name] if @available_filters.has_key?(field) |
|
174 | 174 | label ||= field.gsub(/\_id$/, "") |
|
175 | 175 | end |
|
176 | 176 | |
|
177 | 177 | def statement |
|
178 | 178 | # project/subprojects clause |
|
179 | 179 | clause = '' |
|
180 | 180 | if project && has_filter?("subproject_id") |
|
181 | 181 | subproject_ids = [] |
|
182 | 182 | if operator_for("subproject_id") == "=" |
|
183 | 183 | subproject_ids = values_for("subproject_id").each(&:to_i) |
|
184 | 184 | else |
|
185 | 185 | subproject_ids = project.active_children.collect{|p| p.id} |
|
186 | 186 | end |
|
187 | 187 | clause << "#{Issue.table_name}.project_id IN (%d,%s)" % [project.id, subproject_ids.join(",")] if project |
|
188 | 188 | elsif project |
|
189 | 189 | clause << "#{Issue.table_name}.project_id=%d" % project.id |
|
190 | 190 | else |
|
191 | 191 | clause << Project.visible_by(executed_by) |
|
192 | 192 | end |
|
193 | 193 | |
|
194 | 194 | # filters clauses |
|
195 | 195 | filters_clauses = [] |
|
196 | 196 | filters.each_key do |field| |
|
197 | 197 | next if field == "subproject_id" |
|
198 | 198 | v = values_for(field).clone |
|
199 | 199 | next unless v and !v.empty? |
|
200 | 200 | |
|
201 | 201 | sql = '' |
|
202 | 202 | if field =~ /^cf_(\d+)$/ |
|
203 | 203 | # custom field |
|
204 | 204 | db_table = CustomValue.table_name |
|
205 | 205 | db_field = 'value' |
|
206 | 206 | sql << "#{Issue.table_name}.id IN (SELECT #{db_table}.customized_id FROM #{db_table} where #{db_table}.customized_type='Issue' AND #{db_table}.customized_id=#{Issue.table_name}.id AND #{db_table}.custom_field_id=#{$1} AND " |
|
207 | 207 | else |
|
208 | 208 | # regular field |
|
209 | 209 | db_table = Issue.table_name |
|
210 | 210 | db_field = field |
|
211 | 211 | sql << '(' |
|
212 | 212 | end |
|
213 | 213 | |
|
214 | 214 | # "me" value subsitution |
|
215 | 215 | if %w(assigned_to_id author_id).include?(field) |
|
216 | 216 | v.push(executed_by ? executed_by.id.to_s : "0") if v.delete("me") |
|
217 | 217 | end |
|
218 | 218 | |
|
219 | 219 | case operator_for field |
|
220 | 220 | when "=" |
|
221 | 221 | sql = sql + "#{db_table}.#{db_field} IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" |
|
222 | 222 | when "!" |
|
223 | 223 | sql = sql + "#{db_table}.#{db_field} NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" |
|
224 | 224 | when "!*" |
|
225 | 225 | sql = sql + "#{db_table}.#{db_field} IS NULL" |
|
226 | 226 | when "*" |
|
227 | 227 | sql = sql + "#{db_table}.#{db_field} IS NOT NULL" |
|
228 | 228 | when ">=" |
|
229 | 229 | sql = sql + "#{db_table}.#{db_field} >= #{v.first.to_i}" |
|
230 | 230 | when "<=" |
|
231 | 231 | sql = sql + "#{db_table}.#{db_field} <= #{v.first.to_i}" |
|
232 | 232 | when "o" |
|
233 | 233 | sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id" |
|
234 | 234 | when "c" |
|
235 | 235 | sql = sql + "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id" |
|
236 | 236 | when ">t-" |
|
237 | 237 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today + 1).to_time)] |
|
238 | 238 | when "<t-" |
|
239 | 239 | sql = sql + "#{db_table}.#{db_field} <= '%s'" % connection.quoted_date((Date.today - v.first.to_i).to_time) |
|
240 | 240 | when "t-" |
|
241 | 241 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today - v.first.to_i).to_time), connection.quoted_date((Date.today - v.first.to_i + 1).to_time)] |
|
242 | 242 | when ">t+" |
|
243 | 243 | sql = sql + "#{db_table}.#{db_field} >= '%s'" % connection.quoted_date((Date.today + v.first.to_i).to_time) |
|
244 | 244 | when "<t+" |
|
245 | 245 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)] |
|
246 | 246 | when "t+" |
|
247 | 247 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date((Date.today + v.first.to_i).to_time), connection.quoted_date((Date.today + v.first.to_i + 1).to_time)] |
|
248 | 248 | when "t" |
|
249 | 249 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Date.today.to_time), connection.quoted_date((Date.today+1).to_time)] |
|
250 | 250 | when "w" |
|
251 | 251 | sql = sql + "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(Time.now.at_beginning_of_week), connection.quoted_date(Time.now.next_week.yesterday)] |
|
252 | 252 | when "~" |
|
253 | 253 | sql = sql + "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(v.first)}%'" |
|
254 | 254 | when "!~" |
|
255 | 255 | sql = sql + "#{db_table}.#{db_field} NOT LIKE '%#{connection.quote_string(v.first)}%'" |
|
256 | 256 | end |
|
257 | 257 | sql << ')' |
|
258 | 258 | filters_clauses << sql |
|
259 | 259 | end if filters and valid? |
|
260 | 260 | |
|
261 | 261 | clause << ' AND ' unless clause.empty? |
|
262 | 262 | clause << filters_clauses.join(' AND ') unless filters_clauses.empty? |
|
263 | 263 | clause |
|
264 | 264 | end |
|
265 | 265 | end |
@@ -1,15 +1,15 | |||
|
1 | 1 | <%= error_messages_for 'query' %> |
|
2 | 2 | |
|
3 | 3 | <div class="box"> |
|
4 | 4 | <div class="tabular"> |
|
5 | 5 | <p><label for="query_name"><%=l(:field_name)%></label> |
|
6 | 6 | <%= text_field 'query', 'name', :size => 80 %></p> |
|
7 | 7 | |
|
8 | <% if current_role.allowed_to?(:manage_pulic_queries) %> | |
|
8 | <% if current_role.allowed_to?(:manage_public_queries) %> | |
|
9 | 9 | <p><label for="query_is_public"><%=l(:field_is_public)%></label> |
|
10 | 10 | <%= check_box 'query', 'is_public' %></p> |
|
11 | 11 | <% end %> |
|
12 | 12 | </div> |
|
13 | 13 | |
|
14 | 14 | <%= render :partial => 'queries/filters', :locals => {:query => query}%> |
|
15 | 15 | </div> |
@@ -1,101 +1,101 | |||
|
1 | 1 | require 'redmine/access_control' |
|
2 | 2 | require 'redmine/menu_manager' |
|
3 | 3 | require 'redmine/mime_type' |
|
4 | 4 | require 'redmine/plugin' |
|
5 | 5 | |
|
6 | 6 | begin |
|
7 | 7 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) |
|
8 | 8 | rescue LoadError |
|
9 | 9 | # RMagick is not available |
|
10 | 10 | end |
|
11 | 11 | |
|
12 | 12 | REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs ) |
|
13 | 13 | |
|
14 | 14 | # Permissions |
|
15 | 15 | Redmine::AccessControl.map do |map| |
|
16 | 16 | map.permission :view_project, {:projects => [:show, :activity, :feeds]}, :public => true |
|
17 | 17 | map.permission :search_project, {:search => :index}, :public => true |
|
18 | 18 | map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member |
|
19 | 19 | map.permission :select_project_modules, {:projects => :modules}, :require => :member |
|
20 | 20 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy]}, :require => :member |
|
21 | 21 | map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member |
|
22 | 22 | |
|
23 | 23 | map.project_module :issue_tracking do |map| |
|
24 | 24 | # Issue categories |
|
25 | 25 | map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member |
|
26 | 26 | # Issues |
|
27 | 27 | map.permission :view_issues, {:projects => [:list_issues, :export_issues_csv, :export_issues_pdf, :changelog, :roadmap], |
|
28 | 28 | :issues => [:show, :export_pdf], |
|
29 | 29 | :queries => :index, |
|
30 | 30 | :reports => :issue_report}, :public => true |
|
31 | 31 | map.permission :add_issues, {:projects => :add_issue}, :require => :loggedin |
|
32 | 32 | map.permission :edit_issues, {:issues => [:edit, :destroy_attachment]}, :require => :loggedin |
|
33 | 33 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}, :require => :loggedin |
|
34 | 34 | map.permission :add_issue_notes, {:issues => :add_note}, :require => :loggedin |
|
35 | 35 | map.permission :change_issue_status, {:issues => :change_status}, :require => :loggedin |
|
36 | 36 | map.permission :move_issues, {:projects => :move_issues}, :require => :loggedin |
|
37 | 37 | map.permission :delete_issues, {:issues => :destroy}, :require => :member |
|
38 | 38 | # Queries |
|
39 | map.permission :manage_pulic_queries, {:queries => [:new, :edit, :destroy]}, :require => :member | |
|
39 | map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member | |
|
40 | 40 | map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin |
|
41 | 41 | # Gantt & calendar |
|
42 | 42 | map.permission :view_gantt, :projects => :gantt |
|
43 | 43 | map.permission :view_calendar, :projects => :calendar |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | map.project_module :time_tracking do |map| |
|
47 | 47 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin |
|
48 | 48 | map.permission :view_time_entries, :timelog => [:details, :report] |
|
49 | 49 | end |
|
50 | 50 | |
|
51 | 51 | map.project_module :news do |map| |
|
52 | 52 | map.permission :manage_news, {:projects => :add_news, :news => [:edit, :destroy, :destroy_comment]}, :require => :member |
|
53 | 53 | map.permission :view_news, {:projects => :list_news, :news => :show}, :public => true |
|
54 | 54 | map.permission :comment_news, {:news => :add_comment}, :require => :loggedin |
|
55 | 55 | end |
|
56 | 56 | |
|
57 | 57 | map.project_module :documents do |map| |
|
58 | 58 | map.permission :manage_documents, {:projects => :add_document, :documents => [:edit, :destroy, :add_attachment, :destroy_attachment]}, :require => :loggedin |
|
59 | 59 | map.permission :view_documents, :projects => :list_documents, :documents => [:show, :download] |
|
60 | 60 | end |
|
61 | 61 | |
|
62 | 62 | map.project_module :files do |map| |
|
63 | 63 | map.permission :manage_files, {:projects => :add_file, :versions => :destroy_file}, :require => :loggedin |
|
64 | 64 | map.permission :view_files, :projects => :list_files, :versions => :download |
|
65 | 65 | end |
|
66 | 66 | |
|
67 | 67 | map.project_module :wiki do |map| |
|
68 | 68 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member |
|
69 | 69 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member |
|
70 | 70 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member |
|
71 | 71 | map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :special] |
|
72 | 72 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment] |
|
73 | 73 | end |
|
74 | 74 | |
|
75 | 75 | map.project_module :repository do |map| |
|
76 | 76 | map.permission :manage_repository, :repositories => [:edit, :destroy] |
|
77 | 77 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :changes, :diff, :stats, :graph] |
|
78 | 78 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] |
|
79 | 79 | end |
|
80 | 80 | |
|
81 | 81 | map.project_module :boards do |map| |
|
82 | 82 | map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member |
|
83 | 83 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true |
|
84 | 84 | map.permission :add_messages, {:messages => [:new, :reply]}, :require => :loggedin |
|
85 | 85 | end |
|
86 | 86 | end |
|
87 | 87 | |
|
88 | 88 | # Project menu configuration |
|
89 | 89 | Redmine::MenuManager.map :project_menu do |menu| |
|
90 | 90 | menu.push :label_overview, :controller => 'projects', :action => 'show' |
|
91 | 91 | menu.push :label_activity, :controller => 'projects', :action => 'activity' |
|
92 | 92 | menu.push :label_roadmap, :controller => 'projects', :action => 'roadmap' |
|
93 | 93 | menu.push :label_issue_plural, :controller => 'projects', :action => 'list_issues' |
|
94 | 94 | menu.push :label_news_plural, :controller => 'projects', :action => 'list_news' |
|
95 | 95 | menu.push :label_document_plural, :controller => 'projects', :action => 'list_documents' |
|
96 | 96 | menu.push :label_wiki, { :controller => 'wiki', :action => 'index', :page => nil }, :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } |
|
97 | 97 | menu.push :label_board_plural, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, :if => Proc.new { |p| p.boards.any? } |
|
98 | 98 | menu.push :label_attachment_plural, :controller => 'projects', :action => 'list_files' |
|
99 | 99 | menu.push :label_repository, { :controller => 'repositories', :action => 'show' }, :if => Proc.new { |p| p.repository && !p.repository.new_record? } |
|
100 | 100 | menu.push :label_settings, :controller => 'projects', :action => 'settings' |
|
101 | 101 | end |
@@ -1,161 +1,161 | |||
|
1 | 1 | --- |
|
2 | 2 | roles_004: |
|
3 | 3 | name: Non member |
|
4 | 4 | id: 4 |
|
5 | 5 | builtin: 1 |
|
6 | 6 | permissions: | |
|
7 | 7 | --- |
|
8 | 8 | - :add_issues |
|
9 | 9 | - :edit_issues |
|
10 | 10 | - :manage_issue_relations |
|
11 | 11 | - :add_issue_notes |
|
12 | 12 | - :change_issue_status |
|
13 | 13 | - :move_issues |
|
14 | 14 | - :save_queries |
|
15 | 15 | - :view_gantt |
|
16 | 16 | - :view_calendar |
|
17 | 17 | - :log_time |
|
18 | 18 | - :view_time_entries |
|
19 | 19 | - :comment_news |
|
20 | 20 | - :view_documents |
|
21 | 21 | - :manage_documents |
|
22 | 22 | - :view_wiki_pages |
|
23 | 23 | - :edit_wiki_pages |
|
24 | 24 | - :add_messages |
|
25 | 25 | - :view_files |
|
26 | 26 | - :manage_files |
|
27 | 27 | - :browse_repository |
|
28 | 28 | - :view_changesets |
|
29 | 29 | |
|
30 | 30 | position: 5 |
|
31 | 31 | roles_005: |
|
32 | 32 | name: Anonymous |
|
33 | 33 | id: 5 |
|
34 | 34 | builtin: 2 |
|
35 | 35 | permissions: | |
|
36 | 36 | --- |
|
37 | 37 | - :view_gantt |
|
38 | 38 | - :view_calendar |
|
39 | 39 | - :view_time_entries |
|
40 | 40 | - :view_documents |
|
41 | 41 | - :view_wiki_pages |
|
42 | 42 | - :edit_wiki_pages |
|
43 | 43 | - :view_files |
|
44 | 44 | - :browse_repository |
|
45 | 45 | - :view_changesets |
|
46 | 46 | |
|
47 | 47 | position: 6 |
|
48 | 48 | roles_001: |
|
49 | 49 | name: Manager |
|
50 | 50 | id: 1 |
|
51 | 51 | builtin: 0 |
|
52 | 52 | permissions: | |
|
53 | 53 | --- |
|
54 | 54 | - :edit_project |
|
55 | 55 | - :manage_members |
|
56 | 56 | - :manage_versions |
|
57 | 57 | - :manage_categories |
|
58 | 58 | - :add_issues |
|
59 | 59 | - :edit_issues |
|
60 | 60 | - :manage_issue_relations |
|
61 | 61 | - :add_issue_notes |
|
62 | 62 | - :change_issue_status |
|
63 | 63 | - :move_issues |
|
64 | 64 | - :delete_issues |
|
65 | - :manage_pulic_queries | |
|
65 | - :manage_public_queries | |
|
66 | 66 | - :save_queries |
|
67 | 67 | - :view_gantt |
|
68 | 68 | - :view_calendar |
|
69 | 69 | - :log_time |
|
70 | 70 | - :view_time_entries |
|
71 | 71 | - :manage_news |
|
72 | 72 | - :comment_news |
|
73 | 73 | - :view_documents |
|
74 | 74 | - :manage_documents |
|
75 | 75 | - :view_wiki_pages |
|
76 | 76 | - :edit_wiki_pages |
|
77 | 77 | - :delete_wiki_pages |
|
78 | 78 | - :add_messages |
|
79 | 79 | - :manage_boards |
|
80 | 80 | - :view_files |
|
81 | 81 | - :manage_files |
|
82 | 82 | - :browse_repository |
|
83 | 83 | - :view_changesets |
|
84 | 84 | |
|
85 | 85 | position: 2 |
|
86 | 86 | roles_002: |
|
87 | 87 | name: Developer |
|
88 | 88 | id: 2 |
|
89 | 89 | builtin: 0 |
|
90 | 90 | permissions: | |
|
91 | 91 | --- |
|
92 | 92 | - :edit_project |
|
93 | 93 | - :manage_members |
|
94 | 94 | - :manage_versions |
|
95 | 95 | - :manage_categories |
|
96 | 96 | - :add_issues |
|
97 | 97 | - :edit_issues |
|
98 | 98 | - :manage_issue_relations |
|
99 | 99 | - :add_issue_notes |
|
100 | 100 | - :change_issue_status |
|
101 | 101 | - :move_issues |
|
102 | 102 | - :delete_issues |
|
103 | - :manage_pulic_queries | |
|
103 | - :manage_public_queries | |
|
104 | 104 | - :save_queries |
|
105 | 105 | - :view_gantt |
|
106 | 106 | - :view_calendar |
|
107 | 107 | - :log_time |
|
108 | 108 | - :view_time_entries |
|
109 | 109 | - :manage_news |
|
110 | 110 | - :comment_news |
|
111 | 111 | - :view_documents |
|
112 | 112 | - :manage_documents |
|
113 | 113 | - :view_wiki_pages |
|
114 | 114 | - :edit_wiki_pages |
|
115 | 115 | - :delete_wiki_pages |
|
116 | 116 | - :add_messages |
|
117 | 117 | - :manage_boards |
|
118 | 118 | - :view_files |
|
119 | 119 | - :manage_files |
|
120 | 120 | - :browse_repository |
|
121 | 121 | - :view_changesets |
|
122 | 122 | |
|
123 | 123 | position: 3 |
|
124 | 124 | roles_003: |
|
125 | 125 | name: Reporter |
|
126 | 126 | id: 3 |
|
127 | 127 | builtin: 0 |
|
128 | 128 | permissions: | |
|
129 | 129 | --- |
|
130 | 130 | - :edit_project |
|
131 | 131 | - :manage_members |
|
132 | 132 | - :manage_versions |
|
133 | 133 | - :manage_categories |
|
134 | 134 | - :add_issues |
|
135 | 135 | - :edit_issues |
|
136 | 136 | - :manage_issue_relations |
|
137 | 137 | - :add_issue_notes |
|
138 | 138 | - :change_issue_status |
|
139 | 139 | - :move_issues |
|
140 | 140 | - :delete_issues |
|
141 | - :manage_pulic_queries | |
|
141 | - :manage_public_queries | |
|
142 | 142 | - :save_queries |
|
143 | 143 | - :view_gantt |
|
144 | 144 | - :view_calendar |
|
145 | 145 | - :log_time |
|
146 | 146 | - :view_time_entries |
|
147 | 147 | - :manage_news |
|
148 | 148 | - :comment_news |
|
149 | 149 | - :view_documents |
|
150 | 150 | - :manage_documents |
|
151 | 151 | - :view_wiki_pages |
|
152 | 152 | - :edit_wiki_pages |
|
153 | 153 | - :delete_wiki_pages |
|
154 | 154 | - :add_messages |
|
155 | 155 | - :manage_boards |
|
156 | 156 | - :view_files |
|
157 | 157 | - :manage_files |
|
158 | 158 | - :browse_repository |
|
159 | 159 | - :view_changesets |
|
160 | 160 | |
|
161 | 161 | position: 4 |
General Comments 0
You need to be logged in to leave comments.
Login now