Actualizar plugin Checklists a 3.1.18 light
This commit is contained in:
parent
a26f5567af
commit
24560c8598
55 changed files with 992 additions and 307 deletions
|
@ -1,7 +1,7 @@
|
|||
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
|
||||
# issue checklists management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2011-2017 RedmineUP
|
||||
# Copyright (C) 2011-2020 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_checklists is free software: you can redistribute it and/or modify
|
||||
|
@ -20,9 +20,9 @@
|
|||
class ChecklistsController < ApplicationController
|
||||
unloadable
|
||||
|
||||
before_filter :find_checklist_item, :except => [:index, :create]
|
||||
before_filter :find_issue_by_id, :only => [:index, :create]
|
||||
before_filter :authorize, :except => [:done]
|
||||
before_action :find_checklist_item, :except => [:index, :create]
|
||||
before_action :find_issue_by_id, :only => [:index, :create]
|
||||
before_action :authorize, :except => [:done]
|
||||
helper :issues
|
||||
|
||||
accept_api_auth :index, :update, :destroy, :create, :show
|
||||
|
@ -48,11 +48,13 @@ class ChecklistsController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
@checklist_item = Checklist.new(params[:checklist])
|
||||
@checklist_item = Checklist.new
|
||||
@checklist_item.safe_attributes = params[:checklist]
|
||||
@checklist_item.issue = @issue
|
||||
respond_to do |format|
|
||||
format.api {
|
||||
if @checklist_item.save
|
||||
recalculate_issue_ratio(@checklist_item)
|
||||
render :action => 'show', :status => :created, :location => checklist_url(@checklist_item)
|
||||
else
|
||||
render_validation_errors(@checklist_item)
|
||||
|
@ -62,9 +64,11 @@ class ChecklistsController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
@checklist_item.safe_attributes = params[:checklist]
|
||||
respond_to do |format|
|
||||
format.api {
|
||||
if @checklist_item.update_attributes(params[:checklist])
|
||||
if with_issue_journal { @checklist_item.save }
|
||||
recalculate_issue_ratio(@checklist_item)
|
||||
render_api_ok
|
||||
else
|
||||
render_validation_errors(@checklist_item)
|
||||
|
@ -75,12 +79,12 @@ class ChecklistsController < ApplicationController
|
|||
|
||||
def done
|
||||
(render_403; return false) unless User.current.allowed_to?(:done_checklists, @checklist_item.issue.project)
|
||||
@checklist_item.is_done = params[:is_done] == 'true'
|
||||
|
||||
if @checklist_item.save
|
||||
if (Setting.issue_done_ratio == "issue_field") && RedmineChecklists.settings["issue_done_ratio"].to_i > 0
|
||||
Checklist.recalc_issue_done_ratio(@checklist_item.issue.id)
|
||||
@checklist_item.issue.reload
|
||||
with_issue_journal do
|
||||
@checklist_item.is_done = params[:is_done] == 'true'
|
||||
if @checklist_item.save
|
||||
recalculate_issue_ratio(@checklist_item)
|
||||
true
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
|
@ -104,4 +108,15 @@ class ChecklistsController < ApplicationController
|
|||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def with_issue_journal(&block)
|
||||
return unless yield
|
||||
end
|
||||
|
||||
def recalculate_issue_ratio(checklist_item)
|
||||
if (Setting.issue_done_ratio == 'issue_field') && RedmineChecklists.issue_done_ratio?
|
||||
Checklist.recalc_issue_done_ratio(checklist_item.issue.id)
|
||||
checklist_item.issue.reload
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue