annotate .svn/pristine/db/db8f4e77d30a8490da79511166f71ee7a646520b.svn-base @ 1327:287f201c2802 redmine-2.2-integration

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