annotate .svn/pristine/35/35f480895683cc5d4622ecd0b8aa6794e388969c.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

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