comparison .svn/pristine/8b/8bccd0624e4f8225c7389853d52b177216bc29f0.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 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 def issues
23 @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
24 (render_404; return) unless @issues.present?
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 @projects = @issues.collect(&:project).compact.uniq
32 @project = @projects.first if @projects.size == 1
33
34 @can = {:edit => User.current.allowed_to?(:edit_issues, @projects),
35 :log_time => (@project && User.current.allowed_to?(:log_time, @project)),
36 :update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)),
37 :move => (@project && User.current.allowed_to?(:move_issues, @project)),
38 :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
39 :delete => User.current.allowed_to?(:delete_issues, @projects)
40 }
41 if @project
42 if @issue
43 @assignables = @issue.assignable_users
44 else
45 @assignables = @project.assignable_users
46 end
47 @trackers = @project.trackers
48 else
49 #when multiple projects, we only keep the intersection of each set
50 @assignables = @projects.map(&:assignable_users).reduce(:&)
51 @trackers = @projects.map(&:trackers).reduce(:&)
52 end
53 @versions = @projects.map {|p| p.shared_versions.open}.reduce(:&)
54
55 @priorities = IssuePriority.active.reverse
56 @back = back_url
57
58 @options_by_custom_field = {}
59 if @can[:edit]
60 custom_fields = @issues.map(&:available_custom_fields).reduce(:&).select do |f|
61 %w(bool list user version).include?(f.field_format) && !f.multiple?
62 end
63 custom_fields.each do |field|
64 values = field.possible_values_options(@projects)
65 if values.any?
66 @options_by_custom_field[field] = values
67 end
68 end
69 end
70
71 @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
72 render :layout => false
73 end
74
75 def time_entries
76 @time_entries = TimeEntry.all(
77 :conditions => {:id => params[:ids]}, :include => :project)
78 (render_404; return) unless @time_entries.present?
79
80 @projects = @time_entries.collect(&:project).compact.uniq
81 @project = @projects.first if @projects.size == 1
82 @activities = TimeEntryActivity.shared.active
83 @can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects),
84 :delete => User.current.allowed_to?(:edit_time_entries, @projects)
85 }
86 @back = back_url
87 render :layout => false
88 end
89 end