comparison .svn/pristine/35/35f480895683cc5d4622ecd0b8aa6794e388969c.svn-base @ 1494:e248c7af89ec redmine-2.4

Update to Redmine SVN revision 12979 on 2.4-stable branch
author Chris Cannam
date Mon, 17 Mar 2014 08:54:02 +0000
parents
children
comparison
equal deleted inserted replaced
1464:261b3d9a4903 1494:e248c7af89ec
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 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 ContextMenusController < ApplicationController
19 helper :watchers
20 helper :issues
21
22 before_filter :find_issues, :only => :issues
23
24 def issues
25 if (@issues.size == 1)
26 @issue = @issues.first
27 end
28 @issue_ids = @issues.map(&:id).sort
29
30 @allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
31
32 @can = {:edit => User.current.allowed_to?(:edit_issues, @projects),
33 :log_time => (@project && User.current.allowed_to?(:log_time, @project)),
34 :update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)),
35 :move => (@project && User.current.allowed_to?(:move_issues, @project)),
36 :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
37 :delete => User.current.allowed_to?(:delete_issues, @projects)
38 }
39 if @project
40 if @issue
41 @assignables = @issue.assignable_users
42 else
43 @assignables = @project.assignable_users
44 end
45 @trackers = @project.trackers
46 else
47 #when multiple projects, we only keep the intersection of each set
48 @assignables = @projects.map(&:assignable_users).reduce(:&)
49 @trackers = @projects.map(&:trackers).reduce(:&)
50 end
51 @versions = @projects.map {|p| p.shared_versions.open}.reduce(:&)
52
53 @priorities = IssuePriority.active.reverse
54 @back = back_url
55
56 @options_by_custom_field = {}
57 if @can[:edit]
58 custom_fields = @issues.map(&:available_custom_fields).reduce(:&).select do |f|
59 %w(bool list user version).include?(f.field_format) && !f.multiple?
60 end
61 custom_fields.each do |field|
62 values = field.possible_values_options(@projects)
63 if values.any?
64 @options_by_custom_field[field] = values
65 end
66 end
67 end
68
69 @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
70 render :layout => false
71 end
72
73 def time_entries
74 @time_entries = TimeEntry.where(:id => params[:ids]).preload(:project).to_a
75 (render_404; return) unless @time_entries.present?
76
77 @projects = @time_entries.collect(&:project).compact.uniq
78 @project = @projects.first if @projects.size == 1
79 @activities = TimeEntryActivity.shared.active
80 @can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects),
81 :delete => User.current.allowed_to?(:edit_time_entries, @projects)
82 }
83 @back = back_url
84 render :layout => false
85 end
86 end