annotate .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
rev   line source
Chris@1295 1 # Redmine - project management software
Chris@1295 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
Chris@1295 3 #
Chris@1295 4 # This program is free software; you can redistribute it and/or
Chris@1295 5 # modify it under the terms of the GNU General Public License
Chris@1295 6 # as published by the Free Software Foundation; either version 2
Chris@1295 7 # of the License, or (at your option) any later version.
Chris@1295 8 #
Chris@1295 9 # This program is distributed in the hope that it will be useful,
Chris@1295 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1295 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1295 12 # GNU General Public License for more details.
Chris@1295 13 #
Chris@1295 14 # You should have received a copy of the GNU General Public License
Chris@1295 15 # along with this program; if not, write to the Free Software
Chris@1295 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1295 17
Chris@1295 18 class ContextMenusController < ApplicationController
Chris@1295 19 helper :watchers
Chris@1295 20 helper :issues
Chris@1295 21
Chris@1295 22 def issues
Chris@1295 23 @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
Chris@1295 24 (render_404; return) unless @issues.present?
Chris@1295 25 if (@issues.size == 1)
Chris@1295 26 @issue = @issues.first
Chris@1295 27 end
Chris@1295 28 @issue_ids = @issues.map(&:id).sort
Chris@1295 29
Chris@1295 30 @allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
Chris@1295 31 @projects = @issues.collect(&:project).compact.uniq
Chris@1295 32 @project = @projects.first if @projects.size == 1
Chris@1295 33
Chris@1295 34 @can = {:edit => User.current.allowed_to?(:edit_issues, @projects),
Chris@1295 35 :log_time => (@project && User.current.allowed_to?(:log_time, @project)),
Chris@1295 36 :update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)),
Chris@1295 37 :move => (@project && User.current.allowed_to?(:move_issues, @project)),
Chris@1295 38 :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
Chris@1295 39 :delete => User.current.allowed_to?(:delete_issues, @projects)
Chris@1295 40 }
Chris@1295 41 if @project
Chris@1295 42 if @issue
Chris@1295 43 @assignables = @issue.assignable_users
Chris@1295 44 else
Chris@1295 45 @assignables = @project.assignable_users
Chris@1295 46 end
Chris@1295 47 @trackers = @project.trackers
Chris@1295 48 else
Chris@1295 49 #when multiple projects, we only keep the intersection of each set
Chris@1295 50 @assignables = @projects.map(&:assignable_users).reduce(:&)
Chris@1295 51 @trackers = @projects.map(&:trackers).reduce(:&)
Chris@1295 52 end
Chris@1295 53 @versions = @projects.map {|p| p.shared_versions.open}.reduce(:&)
Chris@1295 54
Chris@1295 55 @priorities = IssuePriority.active.reverse
Chris@1295 56 @back = back_url
Chris@1295 57
Chris@1295 58 @options_by_custom_field = {}
Chris@1295 59 if @can[:edit]
Chris@1295 60 custom_fields = @issues.map(&:available_custom_fields).reduce(:&).select do |f|
Chris@1295 61 %w(bool list user version).include?(f.field_format) && !f.multiple?
Chris@1295 62 end
Chris@1295 63 custom_fields.each do |field|
Chris@1295 64 values = field.possible_values_options(@projects)
Chris@1295 65 if values.any?
Chris@1295 66 @options_by_custom_field[field] = values
Chris@1295 67 end
Chris@1295 68 end
Chris@1295 69 end
Chris@1295 70
Chris@1295 71 @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
Chris@1295 72 render :layout => false
Chris@1295 73 end
Chris@1295 74
Chris@1295 75 def time_entries
Chris@1295 76 @time_entries = TimeEntry.all(
Chris@1295 77 :conditions => {:id => params[:ids]}, :include => :project)
Chris@1295 78 (render_404; return) unless @time_entries.present?
Chris@1295 79
Chris@1295 80 @projects = @time_entries.collect(&:project).compact.uniq
Chris@1295 81 @project = @projects.first if @projects.size == 1
Chris@1295 82 @activities = TimeEntryActivity.shared.active
Chris@1295 83 @can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects),
Chris@1295 84 :delete => User.current.allowed_to?(:edit_time_entries, @projects)
Chris@1295 85 }
Chris@1295 86 @back = back_url
Chris@1295 87 render :layout => false
Chris@1295 88 end
Chris@1295 89 end