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
|
||||
|
@ -22,10 +22,9 @@ class Checklist < ActiveRecord::Base
|
|||
include Redmine::SafeAttributes
|
||||
belongs_to :issue
|
||||
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
||||
has_one :comment, :as => :commented, :dependent => :delete
|
||||
if ActiveRecord::VERSION::MAJOR >= 4
|
||||
attr_protected :id
|
||||
end
|
||||
|
||||
attr_protected :id if ActiveRecord::VERSION::MAJOR <= 4
|
||||
|
||||
acts_as_event :datetime => :created_at,
|
||||
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue_id}},
|
||||
:type => 'issue issue-closed',
|
||||
|
@ -51,17 +50,17 @@ class Checklist < ActiveRecord::Base
|
|||
:order_column => "#{table_name}.id"
|
||||
end
|
||||
|
||||
acts_as_list
|
||||
rcrm_acts_as_list
|
||||
|
||||
validates_presence_of :subject
|
||||
validates_length_of :subject, :maximum => 512
|
||||
validates_length_of :subject, maximum: 512
|
||||
validates_presence_of :position
|
||||
validates_numericality_of :position
|
||||
|
||||
def self.recalc_issue_done_ratio(issue_id)
|
||||
issue = Issue.find(issue_id)
|
||||
return false if (Setting.issue_done_ratio != "issue_field") || RedmineChecklists.settings["issue_done_ratio"].to_i < 1 || issue.checklists.empty?
|
||||
done_checklist = issue.checklists.map{|c| c.is_done ? 1 : 0}
|
||||
return false if (Setting.issue_done_ratio != 'issue_field') || !RedmineChecklists.issue_done_ratio? || issue.checklists.reject(&:is_section).empty?
|
||||
done_checklist = issue.checklists.reject(&:is_section).map { |c| c.is_done ? 1 : 0 }
|
||||
done_ratio = (done_checklist.count(1) * 10) / done_checklist.count * 10
|
||||
issue.update_attribute(:done_ratio, done_ratio)
|
||||
end
|
||||
|
@ -71,7 +70,7 @@ class Checklist < ActiveRecord::Base
|
|||
(detail.value.is_a?(String) && detail.value.match(/^\[[ |x]\] .+$/).present?)
|
||||
end
|
||||
|
||||
safe_attributes 'subject', 'position', 'issue_id', 'is_done'
|
||||
safe_attributes 'subject', 'position', 'issue_id', 'is_done', 'is_section'
|
||||
|
||||
def editable_by?(usr = User.current)
|
||||
usr && (usr.allowed_to?(:edit_checklists, project) || (author == usr && usr.allowed_to?(:edit_own_checklists, project)))
|
||||
|
|
|
@ -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
|
||||
|
@ -19,27 +19,24 @@
|
|||
|
||||
class JournalChecklistHistory
|
||||
def self.can_fixup?(journal_details)
|
||||
unless journal_details.journal
|
||||
return false
|
||||
end
|
||||
return false if journal_details.journal.nil?
|
||||
|
||||
issue = journal_details.journal.journalized
|
||||
unless issue.is_a?(Issue)
|
||||
return false
|
||||
end
|
||||
return false unless issue.is_a?(Issue)
|
||||
|
||||
prev_journal_scope = issue.journals.order('id DESC')
|
||||
prev_journal_scope = prev_journal_scope.where('id <> ?', journal_details.journal_id) if journal_details.journal_id
|
||||
prev_journal = prev_journal_scope.first
|
||||
unless prev_journal
|
||||
return false
|
||||
end
|
||||
return false unless prev_journal
|
||||
|
||||
return false if prev_journal.user_id != journal_details.journal.user_id
|
||||
return false if Time.zone.now > prev_journal.created_on + 1.minute
|
||||
|
||||
prev_journal.details.all?{ |x| x.prop_key == 'checklist'} &&
|
||||
journal_details.journal.details.all?{ |x| x.prop_key == 'checklist'} &&
|
||||
prev_journal.details.all? { |x| x.prop_key == 'checklist' } &&
|
||||
journal_details.journal.details.all? { |x| x.prop_key == 'checklist' } &&
|
||||
journal_details.journal.notes.blank? &&
|
||||
prev_journal.notes.blank? &&
|
||||
prev_journal.details.select{ |x| x.prop_key == 'checklist' }.size == 1
|
||||
prev_journal.details.select { |x| x.prop_key == 'checklist' }.size == 1
|
||||
end
|
||||
|
||||
def self.fixup(journal_details)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue