Redmine 4.1.1

This commit is contained in:
Manuel Cillero 2020-11-22 21:20:06 +01:00
parent 33e7b881a5
commit 3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2006-2019 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -25,7 +27,6 @@ class TimelogController < ApplicationController
before_action :find_optional_issue, :only => [:new, :create]
before_action :find_optional_project, :only => [:index, :report]
before_action :authorize_global, :only => [:new, :create, :index, :report]
accept_rss_auth :index
accept_api_auth :index, :show, :create, :update, :destroy
@ -91,12 +92,12 @@ class TimelogController < ApplicationController
end
def new
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :author => User.current, :spent_on => User.current.today)
@time_entry.safe_attributes = params[:time_entry]
end
def create
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => User.current.today)
@time_entry ||= TimeEntry.new(:project => @project, :issue => @issue, :author => User.current, :user => User.current, :spent_on => User.current.today)
@time_entry.safe_attributes = params[:time_entry]
if @time_entry.project && !User.current.allowed_to?(:log_time, @time_entry.project)
render_403
@ -146,7 +147,6 @@ class TimelogController < ApplicationController
def update
@time_entry.safe_attributes = params[:time_entry]
call_hook(:controller_timelog_edit_before_save, { :params => params, :time_entry => @time_entry })
if @time_entry.save
@ -166,8 +166,18 @@ class TimelogController < ApplicationController
end
def bulk_edit
@available_activities = @projects.map(&:activities).reduce(:&)
@target_projects = Project.allowed_to(:log_time).to_a
@custom_fields = TimeEntry.first.available_custom_fields.select {|field| field.format.bulk_edit_supported}
if params[:time_entry]
@target_project = @target_projects.detect {|p| p.id.to_s == params[:time_entry][:project_id].to_s}
end
if @target_project
@available_activities = @target_project.activities
else
@available_activities = @projects.map(&:activities).reduce(:&)
end
@time_entry_params = params[:time_entry] || {}
@time_entry_params[:custom_field_values] ||= {}
end
def bulk_update
@ -230,7 +240,8 @@ class TimelogController < ApplicationController
end
end
private
private
def find_time_entry
@time_entry = TimeEntry.find(params[:id])
@project = @time_entry.project
@ -262,25 +273,18 @@ private
if params[:issue_id].present?
@issue = Issue.find(params[:issue_id])
@project = @issue.project
authorize
else
find_optional_project
end
end
def find_optional_project
if params[:project_id].present?
@project = Project.find(params[:project_id])
end
rescue ActiveRecord::RecordNotFound
render_404
end
# Returns the TimeEntry scope for index and report actions
def time_entry_scope(options={})
@query.results_scope(options)
end
def retrieve_time_entry_query
retrieve_query(TimeEntryQuery, false)
retrieve_query(TimeEntryQuery, false, :defaults => @default_columns_names)
end
end