Mercurial > hg > soundsoftware-site
comparison app/controllers/context_menus_controller.rb @ 1464:261b3d9a4903 redmine-2.4
Update to Redmine 2.4 branch rev 12663
author | Chris Cannam |
---|---|
date | Tue, 14 Jan 2014 14:37:42 +0000 |
parents | 433d4f72a19b |
children | e248c7af89ec |
comparison
equal
deleted
inserted
replaced
1296:038ba2d95de8 | 1464:261b3d9a4903 |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
17 | 17 |
18 class ContextMenusController < ApplicationController | 18 class ContextMenusController < ApplicationController |
19 helper :watchers | 19 helper :watchers |
20 helper :issues | 20 helper :issues |
21 | 21 |
22 before_filter :find_issues, :only => :issues | |
23 | |
22 def issues | 24 def issues |
23 @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project) | |
24 if (@issues.size == 1) | 25 if (@issues.size == 1) |
25 @issue = @issues.first | 26 @issue = @issues.first |
26 end | 27 end |
27 @issue_ids = @issues.map(&:id).sort | 28 @issue_ids = @issues.map(&:id).sort |
28 | 29 |
29 @allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) | 30 @allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) |
30 @projects = @issues.collect(&:project).compact.uniq | |
31 @project = @projects.first if @projects.size == 1 | |
32 | 31 |
33 @can = {:edit => User.current.allowed_to?(:edit_issues, @projects), | 32 @can = {:edit => User.current.allowed_to?(:edit_issues, @projects), |
34 :log_time => (@project && User.current.allowed_to?(:log_time, @project)), | 33 :log_time => (@project && User.current.allowed_to?(:log_time, @project)), |
35 :update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)), | 34 :update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)), |
36 :move => (@project && User.current.allowed_to?(:move_issues, @project)), | 35 :move => (@project && User.current.allowed_to?(:move_issues, @project)), |
70 @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) | 69 @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) |
71 render :layout => false | 70 render :layout => false |
72 end | 71 end |
73 | 72 |
74 def time_entries | 73 def time_entries |
75 @time_entries = TimeEntry.all( | 74 @time_entries = TimeEntry.where(:id => params[:ids]).preload(:project).to_a |
76 :conditions => {:id => params[:ids]}, :include => :project) | 75 (render_404; return) unless @time_entries.present? |
76 | |
77 @projects = @time_entries.collect(&:project).compact.uniq | 77 @projects = @time_entries.collect(&:project).compact.uniq |
78 @project = @projects.first if @projects.size == 1 | 78 @project = @projects.first if @projects.size == 1 |
79 @activities = TimeEntryActivity.shared.active | 79 @activities = TimeEntryActivity.shared.active |
80 @can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects), | 80 @can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects), |
81 :delete => User.current.allowed_to?(:edit_time_entries, @projects) | 81 :delete => User.current.allowed_to?(:edit_time_entries, @projects) |