Nuevo plugin Redmine Checklist 3.1.10 light

This commit is contained in:
Manuel Cillero 2018-02-04 19:51:03 +01:00
parent 294bc87e76
commit ef5521e0a2
65 changed files with 3544 additions and 0 deletions

View file

@ -0,0 +1,107 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
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]
helper :issues
accept_api_auth :index, :update, :destroy, :create, :show
def index
@checklists = @issue.checklists
respond_to do |format|
format.api
end
end
def show
respond_to do |format|
format.api
end
end
def destroy
@checklist_item.destroy
respond_to do |format|
format.api { render_api_ok }
end
end
def create
@checklist_item = Checklist.new(params[:checklist])
@checklist_item.issue = @issue
respond_to do |format|
format.api {
if @checklist_item.save
render :action => 'show', :status => :created, :location => checklist_url(@checklist_item)
else
render_validation_errors(@checklist_item)
end
}
end
end
def update
respond_to do |format|
format.api {
if @checklist_item.update_attributes(params[:checklist])
render_api_ok
else
render_validation_errors(@checklist_item)
end
}
end
end
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
end
end
respond_to do |format|
format.js
format.html { redirect_to :back }
end
end
private
def find_issue_by_id
@issue = Issue.find(params[:issue_id])
@project = @issue.project
rescue ActiveRecord::RecordNotFound
render_404
end
def find_checklist_item
@checklist_item = Checklist.find(params[:id])
@project = @checklist_item.issue.project
rescue ActiveRecord::RecordNotFound
render_404
end
end

View file

@ -0,0 +1,58 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module ChecklistsHelper
def link_to_remove_checklist_fields(name, f, options={})
f.hidden_field(:_destroy) + link_to(name, "javascript:void(0)", options)
end
def new_object(f, association)
@new_object ||= f.object.class.reflect_on_association(association).klass.new
end
def fields(f, association)
@fields ||= f.fields_for(association, new_object(f, association), :child_index => "new_#{association}") do |builder|
render(association.to_s.singularize + "_fields", :f => builder)
end
end
def new_or_show(f)
if f.object.new_record?
if f.object.subject.present?
"show"
else
"new"
end
else
"show"
end
end
def done_css(f)
if f.object.is_done
"is-done-checklist-item"
else
""
end
end
end

View file

@ -0,0 +1,92 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
class Checklist < ActiveRecord::Base
unloadable
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
acts_as_event :datetime => :created_at,
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue_id}},
:type => 'issue issue-closed',
:title => Proc.new {|o| o.subject },
:description => Proc.new {|o| "#{l(:field_issue)}: #{o.issue.subject}" }
if ActiveRecord::VERSION::MAJOR >= 4
acts_as_activity_provider :type => "checklists",
:permission => :view_checklists,
:scope => preload({:issue => :project})
acts_as_searchable :columns => ["#{table_name}.subject"],
:scope => lambda { includes([:issue => :project]).order("#{table_name}.id") },
:project_key => "#{Issue.table_name}.project_id"
else
acts_as_activity_provider :type => "checklists",
:permission => :view_checklists,
:find_options => {:issue => :project}
acts_as_searchable :columns => ["#{table_name}.subject"],
:include => [:issue => :project],
:project_key => "#{Issue.table_name}.project_id",
:order_column => "#{table_name}.id"
end
acts_as_list
validates_presence_of :subject
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}
done_ratio = (done_checklist.count(1) * 10) / done_checklist.count * 10
issue.update_attribute(:done_ratio, done_ratio)
end
def self.old_format?(detail)
(detail.old_value.is_a?(String) && detail.old_value.match(/^\[[ |x]\] .+$/).present?) ||
(detail.value.is_a?(String) && detail.value.match(/^\[[ |x]\] .+$/).present?)
end
safe_attributes 'subject', 'position', 'issue_id', 'is_done'
def editable_by?(usr = User.current)
usr && (usr.allowed_to?(:edit_checklists, project) || (author == usr && usr.allowed_to?(:edit_own_checklists, project)))
end
def project
issue.project if issue
end
def info
"[#{is_done ? 'x' : ' '}] #{subject.strip}"
end
def add_to_list_bottom
return unless issue.checklists.select(&:persisted?).map(&:position).include?(self[position_column])
self[position_column] = bottom_position_in_list.to_i + 1
end
end

View file

@ -0,0 +1,130 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
class JournalChecklistHistory
def self.can_fixup?(journal_details)
unless journal_details.journal
return false
end
issue = journal_details.journal.journalized
unless issue.is_a?(Issue)
return false
end
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 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'} &&
journal_details.journal.notes.blank? &&
prev_journal.notes.blank? &&
prev_journal.details.select{ |x| x.prop_key == 'checklist' }.size == 1
end
def self.fixup(journal_details)
issue = journal_details.journal.journalized
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
checklist_details = prev_journal.details.find{ |x| x.prop_key == 'checklist'}
if new(checklist_details.old_value, journal_details.value).empty_diff?
prev_journal.destroy
else
checklist_details.update_attribute(:value, journal_details.value)
journal_details.journal.destroy unless journal_details.journal.new_record? && journal_details.journal.details.any?{ |x| x.prop_key != 'checklist'}
end
end
def initialize(was, become)
@was = force_object(was)
@become = force_object(become)
@was_ids = @was.map(&:id)
@become_ids = @become.map(&:id)
@both_ids = @become_ids & @was_ids
end
def diff
{
:undone => undone,
:done => done
}
end
def empty_diff?
diff.all?{ |_,v| v.empty? }
end
def journal_details(opts = {})
JournalDetail.new(opts.merge({
:property => 'attr',
:prop_key => 'checklist',
:old_value => @was.map(&:to_h).to_json,
:value => @become.map(&:to_h).to_json
}))
end
private
def undone
@both_ids.map do |id|
was_is_done = was_by_id(id).is_done
become_is_done = become_by_id(id).is_done
if was_is_done != become_is_done && was_is_done
become_by_id(id)
else
nil
end
end.compact
end
def done
@both_ids.map do |id|
was_is_done = was_by_id(id).is_done
become_is_done = become_by_id(id).is_done
if was_is_done != become_is_done && become_is_done
become_by_id(id)
else
nil
end
end.compact
end
def was_by_id(id)
@was.find{ |x| x.id == id }
end
def become_by_id(id)
@become.find{ |x| x.id == id }
end
def force_object(unk)
if unk.is_a?(String)
json = JSON.parse(unk)
json = [json] unless json.is_a?(Array)
json.map{ |x| OpenStruct2.new(x.has_key?('checklist') ? x['checklist'] : x) }
else
unk.map{ |x| OpenStruct2.new(x.attributes) }
end
end
end

View file

@ -0,0 +1,8 @@
<li id="checklist_item_<%= checklist_item.id %>" <%= "class=is-done-checklist-item" if checklist_item.is_done %> >
<%= check_box_tag 'checklist_item', "", checklist_item.is_done,
:disabled => !User.current.allowed_to?(:done_checklists, checklist_item.issue.project) && !User.current.allowed_to?(:edit_checklists, checklist_item.issue.project),
:data_url => url_for( {:controller => "checklists", :action => "done", :id => checklist_item.id} ), :class => 'checklist-checkbox'
%>
<%= textilizable(checklist_item, :subject).gsub(/<\/?(p|h\d+|li|ul)>/, '').strip.html_safe %>
</li>

View file

@ -0,0 +1,4 @@
$("#checklist_item_<%= @checklist_item.id %>").toggleClass('is-done-checklist-item');
$('#checklist_form .checklist-item#<%= @checklist_item.id %> input[type=checkbox]').trigger('click');
$('.issue .attributes table.progress').parent().html('<%= j(progress_bar(@checklist_item.issue.done_ratio, :width => '80px', :legend => "#{@checklist_item.issue.done_ratio}%")) %>');
$('#issue_done_ratio').val('<%= @checklist_item.issue.done_ratio %>');

View file

@ -0,0 +1,14 @@
api.array :checklists, api_meta(:total_count => @checklists.size) do
@checklists.each do |checklist|
api.checklist do
api.id checklist.id
api.issue_id checklist.issue_id
api.subject checklist.subject
api.is_done checklist.is_done
api.position checklist.position
api.created_at checklist.created_at
api.updated_at checklist.updated_at
end
end
end

View file

@ -0,0 +1,10 @@
api.checklist do
api.id @checklist_item.id
api.issue_id @checklist_item.issue_id
api.subject @checklist_item.subject
api.is_done @checklist_item.is_done
api.position @checklist_item.position
api.created_at @checklist_item.created_at
api.updated_at @checklist_item.updated_at
end

View file

@ -0,0 +1,16 @@
<% if !@issue.blank? && @issue.checklists.any? && User.current.allowed_to?(:view_checklists, @project) %>
<hr />
<div id="checklist">
<p><strong><%=l(:label_checklist_plural)%></strong></p>
<ul id="checklist_items">
<% @issue.checklists.each do |checklist_item| %>
<%= render :partial => 'checklists/checklist_item', :object => checklist_item %>
<% end %>
</ul>
</div>
<% end %>

View file

@ -0,0 +1,21 @@
<span class="checklist-item <%= new_or_show(f) %>" id = "<%=f.object.id%>">
<span class = "checklist-show-only checklist-checkbox"><%= f.check_box :is_done %></span>
<span class = "checklist-show checklist-subject <%= done_css(f) %>">
<%= f.object.subject %>
</span>
<span class = "checklist-edit checklist-new checklist-edit-box">
<%= text_field_tag nil, f.object.subject, :class => 'edit-box'%>
<%= f.hidden_field :subject, :class => 'checklist-subject-hidden' %>
</span>
<span class= "checklist-edit-only checklist-edit-save-button"><%= submit_tag l(:button_save), :type => "button", :class => "item item-save small"%> </span>
<span class= "checklist-edit-only checklist-edit-reset-button"><% concat l(:button_cancel)
%> </span>
<span class = "checklist-show-only checklist-remove"><%= link_to_remove_checklist_fields "", f,
:class => "icon icon-del" %></span>
<%= f.hidden_field :position, :class => 'checklist-item-position' %>
<%= f.hidden_field :id, :class => 'checklist-item-id' %>
<span class = "icon icon-add checklist-new-only save-new-by-button"></span>
<br>
</span>

View file

@ -0,0 +1,24 @@
<% if User.current.allowed_to?(:edit_checklists, @project, :global => true) %>
<div class="tabular">
<p id="checklist_form">
<label><%=l(:label_checklist_plural)%></label>
<% @issue.checklists.build if @issue.checklists.blank? || @issue.checklists.last.subject.present? %>
<%= fields_for :issue, issue do |f| -%>
<span id="checklist_form_items" data-checklist-fields='<%= fields(f, :checklists) %>'>
<%= f.fields_for :checklists do |builder| %>
<%= render :partial => 'checklist_fields', :locals => {:f => builder, :checklist => @checklist} %>
<% end %>
</span>
<% end %>
</p>
</div>
<% end %>
<%= javascript_tag do %>
<% unless User.current.allowed_to?(:done_checklists, @project) %>
$("#checklist_items input").attr("disabled", true);
<% end %>
$("span#checklist_form_items").checklist();
$("#checklist_items").checklist();
<% end %>

View file

@ -0,0 +1,8 @@
<% checklist_tabs = [
{:name => 'general', :partial => 'settings/checklists/general', :label => :label_general}]
%>
<%= render_tabs checklist_tabs %>
<% html_title(l(:label_settings), l(:label_checklists)) -%>

View file

@ -0,0 +1,7 @@
<% if Setting.issue_done_ratio == "issue_field" %>
<p>
<label for="settings_issue_done_ratio"><%= l(:label_checklist_done_ratio) %></label>
<%= hidden_field_tag 'settings[issue_done_ratio]', 0, :id => nil %>
<%= check_box_tag 'settings[issue_done_ratio]', 1, @settings["issue_done_ratio"].to_i > 0 %>
</p>
<% end %>

View file

@ -0,0 +1,354 @@
if(typeof(String.prototype.trim) === "undefined")
{
String.prototype.trim = function()
{
return String(this).replace(/^\s+|\s+$/g, '');
};
}
/*! jQuery klass v0.2a - Jean-Louis Grall - MIT license - http://code.google.com/p/jquery-klass-plugin */
( function( $, undefined ) {
// Function: $.klass( [SuperKlass,] props )
// Creates and returns a new class.
// Usages: MyKlass = $.klass( { init: function() { ... } } )
// MyKlass = $.klass( SuperKlass, { } )
// Arguments:
// SuperKlass (optional) The super class that the new class will extend.
// props Set of methods and other class properties.
// Special props names:
// init The constructor. If omitted, an implicit init will be created.
// Thus all classes have an init method.
// _klass Set of class methods (static methods). They will be added directly to the class.
// Notes:
// - $.klass is the implicit super class, not Object
var $klass = $.klass = function( _super, fields ) { // The class factory. It is also the invisible "super class" of all classes. Methods added to its prototype will be available to all classes.
// If no _super:
if ( !fields ) {
fields = _super;
_super = undefined;
}
var
// init is our future class and constructor
// If no init is provided, make one (Implicit constructor)
klass = fields.init || ( fields.init = function() {
// Automatically calls the superconstructor if there is one.
_super && _super.prototype.init.apply( this, arguments );
} ),
// Used to make the new klass extends its super class
protoChainingProxy = function() { },
// klass.prototype
proto,
// index in loop
name;
// Prepare prototype chaining to the super class
// If no super class, use $.klass as implicit super class
protoChainingProxy.prototype = (_super || $klass).prototype;
// Make the [[prototype]]'s chain from klass to it's super class
proto = klass.prototype = new protoChainingProxy; // At the end we have: klass.prototype.[[prototype]] = protoChainingProxy.prototype = _super.prototype. Here the "new" operator creates the new object with the right prototype chain, but doesn't call the constructor because there is no "()". See also: http://brokenliving.blogspot.com/2009/09/simple-javascript-inheritance.html
// Now we have: klass.prototype.[[prototype]] = protoChainingProxy.prototype = _super.prototype
// Accessor for super klass ( can be undefined )
klass._super = _super;
// Add each function to the prototype of the new class (they are our new class methods):
for ( name in fields ) {
// Add the static variables to the new class:
if ( name === "_klass" ) $.extend( klass, fields[name] );
// Each new method keeps a reference to its name and its class, allowing us to find its super method dynamically at runtime:
else $.isFunction( proto[ name ] = fields[name] ) && ( fields[name]._klass = { klass: klass, name: name } );
}
// Sets the constructor for instanciated objects
proto.constructor = klass;
return klass;
},
Array_slice = [].slice;
/* $.klass.prototype */
// Properties assigned to it are available from any instance of a class made by $.klass
// Function: this._super( [ methodName,] arguments, args... )
// Calls a super method. Finds the super method dynamically.
// Usages: this._super( arguments, arg1, arg2, arg3, ... )
// this._super( "methodName", arguments, arg1, arg2, arg3, ... )
// Arguments:
// methodName (optional) Name of the super method.
// By default, use the name of the calling method.
// arguments You must give the arguments object here.
// args... List of arguments for the super method.
// Note:
// - Super methods are found dynamically by the function in the super class using the method's name.
$klass.prototype._super = function( arg0, arg1 ) {
var arg0IsArguments = arg0.callee,
_klass = ( arg0IsArguments ? arg0 : arg1 ).callee._klass,
name = arg0IsArguments ? _klass.name : arg0,
superMethod = _klass.klass._super.prototype[ name ];
return superMethod.apply( this, Array_slice.call( arguments, 1 + ( !arg0IsArguments ) ) );
};
})( jQuery );
var Redmine = Redmine || {};
Redmine.Checklist = $.klass({
preventEvent: function(event) {
if (event.preventDefault)
event.preventDefault()
else
event.returnValue = false
},
addChecklistFields: function(templateDiv) {
var new_id = new Date().getTime();
var regexp = new RegExp("new_checklist", "g");
if (templateDiv) {
appended = $(this.content.replace(regexp, new_id)).insertBefore(templateDiv)
} else {
appended = $(this.content.replace(regexp, new_id)).appendTo(this.root)
}
appended.find('.edit-box').focus()
},
findSpan: function(event) {
return $(event.target).closest('.checklist-item')
},
findSpanBefore: function(elem) {
return elem.prevAll('span.checklist-item.new')
},
transformItem: function(event, elem, valueToSet) {
var checklistItem;
if (event) {
checklistItem = this.findSpan(event)
} else {
checklistItem = this.findSpanBefore(elem)
}
var val;
if (valueToSet) {
val = valueToSet
checklistItem.find('input.edit-box').val(val)
} else {
val = checklistItem.find('input.edit-box').val()
}
checklistItem.find('.checklist-subject').text(val)
checklistItem.find('.checklist-subject-hidden').val(val)
checklistItem.removeClass('edit')
checklistItem.removeClass('new')
checklistItem.addClass('show')
},
resetItem: function(item) {
item.find('input.edit-box').val(item.find('checklist-subject-hidden').val() )
item.removeClass('edit')
item.addClass('show')
},
addChecklistItem: function(event) {
this.preventEvent(event)
this.transformItem(event)
if ($('.template-wrapper').length)
this.addChecklistFields($('.template-wrapper'))
else
this.addChecklistFields()
},
canSave: function(span) {
return (!span.hasClass('invalid')) && (span.find('input.edit-box').val().length > 0)
},
onEnterInNewChecklistItemForm: function() {
this.root.on('keydown', 'input.edit-box', $.proxy(function(event) {
if (event.which == 13) {
this.preventEvent(event)
span = this.findSpan(event)
if (this.canSave(span))
{
if (span.hasClass('edit'))
this.transformItem(event)
else
this.addChecklistItem(event)
}
}
}, this))
},
onClickPlusInNewChecklistItem: function() {
this.root.on('click', '.save-new-by-button', $.proxy(function(event){
span = this.findSpan(event)
if (this.canSave(span))
this.addChecklistItem(event)
}, this))
},
onIssueFormSubmitRemoveEmptyChecklistItems: function() {
$('body').on('submit', '#issue-form', function(){
$('.checklist-subject-hidden').each(function(i, elem) {
if ($(elem).val() == "")
{
$(elem).closest('.checklist-item').remove()
}
})
})
},
onChecklistRemove: function() {
this.root.on('click', '.checklist-remove a', $.proxy(function(event){
this.preventEvent(event)
removed = this.findSpan(event)
removed.find('.checklist-remove input[type=hidden]').val('1')
removed.fadeOut(200)
}, this))
},
makeChecklistsSortable: function() {
$('#checklist_form_items').sortable({
revert: true,
items: '.checklist-item.show',
helper: "clone",
stop: function (event, ui) {
if (ui.item.hasClass("edited-now")) {
$( this ).sortable( "cancel" );
}
if (ui.item.hasClass("edit-active")) {
$( this ).sortable( "cancel" );
}
$(".checklist-item").each(function(index, element){
$(element).children('.checklist-item-position').val(index);
});
}
});
},
makeChecklistsEditable: function() {
this.root.on('click', '.checklist-subject', $.proxy(function(event) {
$('.checklist-item').each($.proxy(function(i, elem) {
if ($(elem).hasClass('edit'))
this.resetItem($(elem))
}, this))
span = this.findSpan(event)
span.addClass('edit')
span.removeClass('show')
span.find('.edit-box').val(span.find('.checklist-subject-hidden').val())
span.find('.edit-box').focus()
}, this));
this.root.on('click', '.checklist-edit-save-button', $.proxy(function(event){
this.transformItem(event)
}, this))
this.root.on('click', '.checklist-edit-reset-button', $.proxy(function(event){
this.resetItem(this.findSpan(event))
}, this))
},
onCheckboxChanged: function() {
this.root.on('change', 'input[type=checkbox]', $.proxy(function(event){
checkbox = $(event.target)
subj = this.findSpan(event).find('.checklist-subject')
if (checkbox.is(':checked'))
subj.addClass('is-done-checklist-item')
else
subj.removeClass('is-done-checklist-item')
}, this))
},
onChangeCheckbox: function(){
this.root.on('change', 'input.checklist-checkbox', $.proxy(function(event){
checkbox = $(event.target)
url = checkbox.attr('data_url')
$.ajax({type: "PUT", url: url, data: { is_done: checkbox.prop('checked') }, dataType: 'script'})
}, this))
},
enableUniquenessValidation: function() {
this.root.on('keyup', 'input.edit-box', $.proxy(function(event) {
value = $(event.target).val()
span = this.findSpan(event)
span.removeClass('invalid')
$('.checklist-item').each(function(i, elem) {
e = $(elem)
if (!e.is('.edit') && !e.is('.new'))
{
if ( (value == e.find('.edit-box').val()) )
{
span.addClass('invalid')
}
}
})
}, this))
},
hasAlreadyChecklistWithName: function(value) {
var ret = false;
$('.checklist-show.checklist-subject').each(function(i, elem) {
e = $(elem)
if (value == e.text().trim())
{
ret = true;
}
})
return ret;
},
assignTemplateSelectedEvent: function() {
var item;
this.root.on('change', '#checklist_template', $.proxy(function(){
value = $('#checklist_template').val()
selected = $('#checklist_template option[value='+value+']').data('template-items')
items = selected.split(/\n/)
for(i = 0; i<items.length; i++)
{
item = items[i]
if (!this.hasAlreadyChecklistWithName(item))
{
this.transformItem(null, $('#checklist_template'), item)
this.addChecklistFields($('#template-link').closest('span'))
}
}
$('#checklist_template').val('')
$('#template-link').show()
$('#checklist_template').hide()
}, this))
},
clickSelectTemplateLink: function() {
this.root.on('click', '#template-link', function(){
$('#template-link').hide()
$('#checklist_template').show()
})
},
init: function(element) {
this.root = element
this.content = element.data('checklist-fields')
this.onEnterInNewChecklistItemForm()
this.onClickPlusInNewChecklistItem()
this.onIssueFormSubmitRemoveEmptyChecklistItems()
this.onChecklistRemove()
this.makeChecklistsSortable()
this.makeChecklistsEditable()
this.onCheckboxChanged()
this.onChangeCheckbox()
this.enableUniquenessValidation()
this.assignTemplateSelectedEvent()
this.clickSelectTemplateLink()
}
})
$.fn.checklist = function(element){
new Redmine.Checklist(this);
}

View file

@ -0,0 +1,77 @@
div#checklist ul {
list-style: none;
padding-left: 0px;
margin-bottom: 0px;
}
div#checklist li {
padding-bottom: 10px;
margin-left: 10px;
}
#checklist li:hover a.delete {opacity: 1;}
#checklist a.delete {opacity: 0.4;}
span.checklist-item {
display: block;
margin-bottom: 5px;
}
span.checklist-subject.is-done-checklist-item, span.checklist-item.is-done-checklist-item, #checklist_items li.is-done-checklist-item {
text-decoration: line-through;
color: #999;
}
span.checklist-remove { margin-left: 2px; opacity: 0.4;}
span.checklist-remove:hover {opacity: 1;}
span.checklist-edit-box input {
margin-right: 6px;
width: 40%;
-moz-transition: top 0.2s;
-o-transition: top 0.2s;
-webkit-transition: top 0.2s;
transition: top 0.2s;
}
.invalid span.checklist-edit-box input {
border-color: #b94a48;
color: #b94a48;
}
.invalid span.checklist-edit-box input:focus {
border-color: #953b39;
color: #b94a48;
}
.invalid .checklist-edit-save-button {
display: none;
}
span.checklist-edit-reset-button {
cursor: pointer;
color: #2996CC;
}
span.checklist-subject {cursor: pointer;}
span.checklist-item.show .checklist-edit,
span.checklist-item.show .checklist-edit-only,
span.checklist-item.show .checklist-new,
span.checklist-item.show .checklist-new-only,
span.checklist-item.edit .checklist-show,
span.checklist-item.edit .checklist-new-only,
span.checklist-item.new .checklist-edit-only,
span.checklist-item.new .checklist-show-or-edit,
span.checklist-item.new .checklist-show-only,
span.checklist-item.edit .checklist-show-only {
display: none;
}
div#checklist ol {
display: inline-block;
padding-left: 0;
}

View file

@ -0,0 +1,9 @@
# encoding: utf-8
bg:
label_checklist_plural: Чеклист
field_checklist: Чеклист
label_checklist_save_log: Съхраняване на записи в историята на дейността
label_checklist_done_ratio: Преизчисляване на процента готовност
permission_view_checklists: Разглеждане на чеклисти
permission_done_checklists: Изпълнение на чеклисти
permission_edit_checklists: Редактиране на чеклисти

View file

@ -0,0 +1,29 @@
# encoding: utf-8
# German strings go here for Rails i18n
de:
label_checklist_plural: Checkliste
field_checklist: Checkliste
label_checklist_save_log: "Speichere Änderungen in der Ticket-Historie"
label_checklist_done_ratio: Aktualisiere den Ticket-Fortschritt
permission_view_checklists: Checkliste anzeigen
permission_done_checklists: Checkliste anwenden
permission_edit_checklists: Checkliste bearbeiten
label_checklist_template_category_plural: Kategorien
label_checklist_template_category_new: Neue Kategorie
field_checklist_template_category: Kategorie
label_checklist_templates: Checklisten-Vorlagen
label_checklist_new_checklist_template: Neue Checklisten-Vorlage
field_template_items: "Einträge"
label_checklist_template: Checklisten-Vorlage
label_add_checklists_from_template: "Aus Vorlage wählen"
label_select_template: "-- Vorlage auswählen --"
label_checklist_category_not_specified: "-- Nicht spezifiziert --"
label_checklists_description: 'Mehrere Einträge erlaubt (ein Eintrag pro Zeile)'
label_checklist_item: Checklisten-Eintrag
label_checklist_deleted: gelöscht
label_checklist_changed_from: geändert von
label_checklist_changed_to: zu
label_checklist_added: hinzugefügt
label_checklist_done: als Erledigt markiert
label_checklist_undone: als Nicht Erledigt markiert
label_checklist_updated: Checklisten-Eintrag editiert

View file

@ -0,0 +1,34 @@
# English strings go here for Rails i18n
en:
label_checklist_plural: Checklist
field_checklist: Checklist
label_checklist_save_log: Save changes to issue log
label_checklist_done_ratio: Set issue done ratio
permission_view_checklists: View checklist
permission_done_checklists: Done checklist items
permission_edit_checklists: Edit checklist items
label_checklist_template_category_plural: Template categories
label_checklist_template_category_new: New category
field_checklist_template_category: Category
label_checklist_templates: Checklist templates
label_checklist_new_checklist_template: New checklist template
field_template_items: Template items
label_checklist_template: Checklist template
label_add_checklists_from_template: Add from template
label_select_template: "-- Select template --"
label_checklist_category_not_specified: "-- Not specified --"
label_checklists_description: 'Multiple values allowed (one line for each value)'
label_checklist_item: Checklist item
label_checklist_deleted: deleted
label_checklist_changed_from: changed from
label_checklist_changed_to: to
label_checklist_added: added
label_checklist_done: set to Done
label_checklist_undone: set to Not done
label_checklist_updated: Checklist item edited
label_checklist_status: Checklist status
label_checklist_status_done: Done
label_checklist_status_undone: Undone
label_checklist_status: Checklist status
label_checklist_is_default: Default
field_is_for_tracker: Tracker

View file

@ -0,0 +1,28 @@
# Spanish strings go here for Rails i18n
es:
label_checklist_plural: Checklist
field_checklist: Checklist
label_checklist_save_log: Salvar cambios al log de la petición
label_checklist_done_ratio: Setear porcentaje de estado de petición
permission_view_checklists: Ver checklist
permission_done_checklists: Cerrar items de checklist
permission_edit_checklists: Editar iterms de checklist
label_checklist_template_category_plural: Categorías de plantillas
label_checklist_template_category_new: Nueva categoría
field_checklist_template_category: Categoría
label_checklist_templates: Plantillas de checklists
label_checklist_new_checklist_template: Nueva plantilla de checklist
field_template_items: Items de la plantilla
label_checklist_template: Plantilla de checklist
label_add_checklists_from_template: Añadir desde plantilla
label_select_template: "-- Seleccionar plantilla --"
label_checklist_category_not_specified: "-- No especificada --"
label_checklists_description: 'Se permiten múltiples valores (un valor por línea)'
label_checklist_item: Item de checklist
label_checklist_deleted: borrado
label_checklist_changed_from: cambiado de
label_checklist_changed_to: a
label_checklist_added: añadido
label_checklist_done: marcado como Hecho
label_checklist_undone: marcado como No hecho
label_checklist_updated: Item de checklist modificado

View file

@ -0,0 +1,4 @@
# encoding: utf-8
fr:
label_checklist_plural: Liste de Tâches
field_checklist: Tâche

View file

@ -0,0 +1,9 @@
# encoding: utf-8
ja:
label_checklist_plural: "チェックリスト" # Checklist
field_checklist: "チェックリスト" # Checklist
label_checklist_save_log: "変更をチケットに記録する" # Save changes to issue log
label_checklist_done_ratio: "チェック完了率" # Set issue done ratio
permission_view_checklists: "チェックリストの参照" # View checklist
permission_done_checklists: "チェックリストへ済印" # Done checklist items
permission_edit_checklists: "チェックリストの編集" # Edit checklist items

View file

@ -0,0 +1,9 @@
# Translation by Ki Won Kim (http://x10.iptime.org/redmine, http://xyz37.blog.me, xyz37@naver.com)
ko:
label_checklist_plural: "체크리스트"
field_checklist: "체크리스트"
label_checklist_save_log: "일감 로그에 변경사항을 저장합니다."
label_checklist_done_ratio: "완료 비율 일감 설정"
permission_view_checklists: "체크리스트 보기"
permission_done_checklists: "체크리스트 완료"
permission_edit_checklists: "체크리스트 수정"

View file

@ -0,0 +1,28 @@
# English strings go here for Rails i18n
pl:
label_checklist_plural: Lista
field_checklist: Checklista
label_checklist_save_log: Zapisuj zmiany w historii
label_checklist_done_ratio: Ustawia wskaźnik wykonania dla zgłoszeń
permission_view_checklists: Zobacz listę
permission_done_checklists: Ustaw jako ukończone elementy checklisty
permission_edit_checklists: Edytuj elementy checklisty
label_checklist_template_category_plural: Kategorie szablonów
label_checklist_template_category_new: Nowa kategoria
field_checklist_template_category: Kategoria
label_checklist_templates: Szablony checklist
label_checklist_new_checklist_template: New checklist template
field_template_items: Elementy szablonu
label_checklist_template: Szablon checklisty
label_add_checklists_from_template: Dodaj z szablonu
label_select_template: "-- Wybierz szablon --"
label_checklist_category_not_specified: "-- Nie wybrano --"
label_checklists_description: 'Dozwolone wiele wartości (po jednej linii dla każdej wartości)'
label_checklist_item: Element checklisty
label_checklist_deleted: usunięty
label_checklist_changed_from: zmieniony z
label_checklist_changed_to: na
label_checklist_added: dodany
label_checklist_done: ustaw jako Wykonane
label_checklist_undone: ustaw jako Niewykonane
label_checklist_updated: Zmieniono element checklisty

View file

@ -0,0 +1,9 @@
#Portuguese Brazilian strings go here for Rails i18n
pt-BR:
label_checklist_plural: Checklist
field_checklist: Checklist
label_checklist_save_log: Salvar alterações nos logs das tarefas
label_checklist_done_ratio: Definir % terminando quando desmarcar o item
permission_view_checklists: Ver checklist
permission_done_checklists: Remover itens do checklist
permission_edit_checklists: Alterar itens do checklist

View file

@ -0,0 +1,33 @@
# encoding: utf-8
ru:
label_checklist_plural: Чеклист
field_checklist: Чеклист
label_checklist_save_log: Сохранять изменения в истории
label_checklist_done_ratio: Рассчитывать готовность задачи
permission_view_checklists: Просматривать чеклисты
permission_done_checklists: Выполнять чеклисты
permission_edit_checklists: Редактировать чеклисты
label_checklist_template_category_plural: Категории шаблонов чеклистов
label_checklist_template_category_new: Новая категория шаблонов чеклистов
field_checklist_template_category: Категория
label_checklist_templates: Шаблоны чеклистов
label_checklist_new_checklist_template: Новый шаблон чеклистов
field_template_items: Элементы шаблона
label_checklist_template: Шаблон чеклистов
label_add_checklists_from_template: Добавить из шаблона
label_select_template: "-- Выберите шаблон --"
label_checklist_category_not_specified: "-- Без категории --"
label_checklists_description: 'Для ввода нескольких значений вводите по одному на строку'
label_checklist_item: Пункт чеклиста
label_checklist_deleted: удалён
label_checklist_changed_from: изменён с
label_checklist_changed_to: на
label_checklist_added: добавлен
label_checklist_done: выполнен
label_checklist_undone: не выполнен
label_checklist_updated: Пункт чеклиста изменен
label_checklist_status: Статус пункта чеклиста
label_checklist_status_done: Выполнен
label_checklist_status_undone: Не выполнен
label_checklist_is_default: По умолчанию
field_is_for_tracker: Трекер

View file

@ -0,0 +1,10 @@
# encoding: utf-8
# Slovak strings go here for Rails i18n
sk:
label_checklist_plural: Checklist
field_checklist: Checklist
label_checklist_save_log: Uložiť zmeny do histórie úlohy
label_checklist_done_ratio: Nastaviť úlohu ako kompletnú
permission_view_checklists: Zobraziť checklist
permission_done_checklists: Splnené checklist položky
permission_edit_checklists: Upraviť checklist položky

View file

@ -0,0 +1,11 @@
# Swedish strings go here for Rails i18n
# Translation by Khedron Wilk (khedron.wilk@gmail.com)
# Created 2014 Dec 14 Based on RedmineUP Checklist plugin (Light) ver 3.0.2
sv:
label_checklist_plural: Checklista
field_checklist: Checklista
label_checklist_save_log: Spara ändringar i ärendeloggen
label_checklist_done_ratio: Använd checklista för att beräkna % klart
permission_view_checklists: Visa checklistor
permission_done_checklists: Klara checklistepunkter
permission_edit_checklists: Redigera checklistepunkter

View file

@ -0,0 +1,9 @@
# encoding: utf-8
uk:
label_checklist_plural: Чекліст
field_checklist: Чекліст
label_checklist_save_log: Зберегти зміни в історії
label_checklist_done_ratio: Розрахувати готовність завдання
permission_view_checklists: Переглядати чеклісти
permission_done_checklists: Виконувати чеклісти
permission_edit_checklists: Редагувати чеклісти

View file

@ -0,0 +1,32 @@
# encoding: utf-8
# Simplified Chinese strings go here for Rails i18n
# Author: Steven.W
# Based on file: en.yml
zh:
label_checklist_plural: 检查列表
field_checklist: 检查列表
label_checklist_save_log: 保存检查列表变更到问题日志
label_checklist_done_ratio: 设置列表完成比率
permission_view_checklists: 查看检查列表
permission_done_checklists: 完成检查项
permission_edit_checklists: 编辑检查项
label_checklist_template_category_plural: 模板类别
label_checklist_template_category_new: 新类别
field_checklist_template_category: 类别
label_checklist_templates: 检查列表模板
label_checklist_new_checklist_template: 新检查列表模板
field_template_items: 模板项
label_checklist_template: 检查列表模板
label_add_checklists_from_template: 从模板新建
label_select_template: "-- 选择模板 --"
label_checklist_category_not_specified: "-- 未指定 --"
label_checklists_description: '允许多重值 (每一行的值)'
label_checklist_item: 检查列表项
label_checklist_deleted: 删除
label_checklist_changed_from: 改变自
label_checklist_changed_to:
label_checklist_added: 添加
label_checklist_done: 设置完成
label_checklist_undone: 设置未完成
label_checklist_updated: 检查列表项编辑

View file

@ -0,0 +1,28 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
resources :issues do
resources :checklists, :only => [:index, :create]
end
resources :checklists, :only => [:destroy, :update, :show] do
member do
put :done
end
end

View file

@ -0,0 +1,38 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
class CreateChecklists < ActiveRecord::Migration
def self.up
if ActiveRecord::Base.connection.table_exists? :issue_checklists
rename_table :issue_checklists, :checklists
else
create_table :checklists do |t|
t.boolean :is_done, :default => false
t.string :subject
t.integer :position, :default => 1
t.references :issue, :null => false
end
end
end
def self.down
drop_table :checklists
end
end

View file

@ -0,0 +1,25 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
class AddTimeStampsToChecklists < ActiveRecord::Migration
def change
add_column :checklists, :created_at, :timestamp
add_column :checklists, :updated_at, :timestamp
end
end

View file

@ -0,0 +1,32 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
class CreateChecklistTemplateCategory < ActiveRecord::Migration
def self.up
create_table :checklist_template_categories do |t|
t.string :name
t.integer :position, :default => 1
end
end
def self.down
drop_table :checklist_template_categories
end
end

View file

@ -0,0 +1,36 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
class CreateChecklistTemplates < ActiveRecord::Migration
def self.up
create_table :checklist_templates do |t|
t.string :name
t.references :project
t.references :category
t.references :user
t.boolean :is_public
t.text :template_items
end
end
def self.down
drop_table :checklist_templates
end
end

View file

@ -0,0 +1,28 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
class ModifyChecklistSubjectLength < ActiveRecord::Migration
def self.up
change_column :checklists, :subject, :string, :limit => 512
end
def self.down
change_column :checklists, :subject, :string, :limit => 256
end
end

View file

@ -0,0 +1,31 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
class AddFieldsToChecklistTemplate < ActiveRecord::Migration
def self.up
add_column :checklist_templates, :is_default, :boolean, :default => false
add_column :checklist_templates, :tracker_id, :integer
add_index :checklist_templates, :tracker_id
end
def self.down
remove_column :checklist_templates, :is_default
remove_column :checklist_templates, :tracker_id
end
end

View file

@ -0,0 +1,96 @@
== Redmine Checklists plugin changelog
Redmine Checklists plugin - managing issue checklists plugin for Redmine
Copyright (C) 2011-2017 RedmineUP
http://www.redmineup.com/
== 2017-10-12 v3.1.10
* Fixed email notification bug
* Fixed empty project issues bug
== 2017-09-23 v3.1.9
* Fixed bug with creating issues without checklist
== 2017-09-21 v3.1.8
* Default templates bug fixed
== 2017-08-30 v3.1.7
* Assigned tracker for checklist template
* Fixed bug with coping project and issue with subissues
* Fixed settings saving bug
* 512 characters in checklist subjects (Ondřej Kudlík)
* Fixed bug for markdown
== 2017-07-07 v3.1.6
* Redmine 3.4 support
* New checklists filters for issues table
* Save log by default
* Chinese translation update
* Polish translation update
* Fixed bug with template editing
== 2016-08-15 v3.1.5
* Fixed bug with project tabs
== 2016-08-10 v3.1.4
* Fixed empty history items for issues with checklists
* Fixed XSS in journal rendering
* Fixed error with template search in MSSQL
* Banner plugin compatibility
* Fixed for-all-project template option
* Validation for subject length
* Hungarian translation by Peter Tabajdi
* Spanish translation update by Luis Blasco
* Merge checklists history if less than minute interval changes
== 2015-09-25 v3.1.3
* Bug with attach files history fixed
* Bug with old checkboxes fixed
== 2015-09-25 v3.1.2
* Issue history details
* Templates permissions fixes
== 2015-04-08 v3.1.0
* Checklist templates
== 2015-03-06 v3.0.4
* Redmine 3.0 compatibility fixes
* Fixed checklist styles on read only issue mode
== 2015-02-23 v3.0.3
* Swedish translation update (Khedron Wilk)
* Portuguese Brazilian translation (Leandro Gehlen)
* Redmine 3.0 (Rails4) support
* Copying checklists with project copying (Andrew Reshetov)
* Fixed bug with unable editing checklist after tracker or status changed
== 2014-12-09 v3.0.2
* Fixed bug wuth empty subject with CKEditor plugin
== 2014-09-15 v3.0.1
* Bulgarian translation (Иван Ценов)
* Fixed bug with IE browser
== 2014-09-10 v3.0.0
* Editing checklist items
* REST API for index, create, destroy, update, show
* Change issues progress in real time
* Sync checked items with show and edit forms
* Fixed bug with rejecting new checklist items on update issue status
* Japan translation (Yukio KANEDA)

View file

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View file

@ -0,0 +1,26 @@
LICENSING
RedmineUP Licencing
This End User License Agreement is a binding legal agreement between you and RedmineUP. Purchase, installation or use of RedmineUP Extensions provided on redmineup.com signifies that you have read, understood, and agreed to be bound by the terms outlined below.
RedmineUP GPL Licencing
All Redmine Extensions produced by RedmineUP are released under the GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html). Specifically, the Ruby code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript are NOT GPL, and are released under the RedmineUP Proprietary Use License v1.0 (See below) unless specifically authorized by RedmineUP. Elements of the extensions released under this proprietary license may not be redistributed or repackaged for use other than those allowed by the Terms of Service.
RedmineUP Proprietary Use License (v1.0)
The RedmineUP Proprietary Use License covers any images, cascading stylesheets, manuals and JavaScript files in any extensions produced and/or distributed by redmineup.com. These files are copyrighted by redmineup.com (RedmineUP) and cannot be redistributed in any form without prior consent from redmineup.com (RedmineUP)
Usage Terms
You are allowed to use the Extensions on one or many "production" domains, depending on the type of your license
You are allowed to make any changes to the code, however modified code will not be supported by us.
Modification Of Extensions Produced By RedmineUP.
You are authorized to make any modification(s) to RedmineUP extension Ruby code. However, if you change any Ruby code and it breaks functionality, support may not be available to you.
In accordance with the RedmineUP Proprietary Use License v1.0, you may not release any proprietary files (modified or otherwise) under the GPL license. The terms of this license and the GPL v2 prohibit the removal of the copyright information from any file.
Please contact us if you have any requirements that are not covered by these terms.

View file

@ -0,0 +1,52 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require 'redmine'
require 'redmine_checklists/redmine_checklists'
CHECKLISTS_VERSION_NUMBER = '3.1.10'
CHECKLISTS_VERSION_TYPE = "Light version"
Redmine::Plugin.register :redmine_checklists do
name "Redmine Checklists plugin (#{CHECKLISTS_VERSION_TYPE})"
author 'RedmineUP'
description 'This is a issue checklist plugin for Redmine'
version CHECKLISTS_VERSION_NUMBER
url 'https://www.redmineup.com/pages/plugins/checklists'
author_url 'mailto:support@redmineup.com'
requires_redmine :version_or_higher => '2.3'
settings :default => {
:save_log => true,
:issue_done_ratio => false
}, :partial => 'settings/checklists/checklists'
Redmine::AccessControl.map do |map|
map.project_module :issue_tracking do |map|
map.permission :view_checklists, {:checklists => [:show, :index]}
map.permission :done_checklists, {:checklists => :done}
map.permission :edit_checklists, {:checklists => [:done, :create, :destroy, :update]}
end
end
Redmine::Search.map do |search|
# search.register :checklists
end
end

View file

@ -0,0 +1,31 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Hooks
class ControllerIssuesHook < Redmine::Hook::ViewListener
def controller_issues_edit_after_save(context = {})
if (Setting.issue_done_ratio == "issue_field") && RedmineChecklists.settings["issue_done_ratio"].to_i > 0
Checklist.recalc_issue_done_ratio(context[:issue].id)
end
end
end
end
end

View file

@ -0,0 +1,27 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Hooks
class ViewsIssuesHook < Redmine::Hook::ViewListener
render_on :view_issues_show_description_bottom, :partial => "issues/checklist"
render_on :view_issues_form_details_bottom, :partial => "issues/checklist_form"
end
end
end

View file

@ -0,0 +1,29 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Hooks
class ViewsLayoutsHook < Redmine::Hook::ViewListener
def view_layouts_base_html_head(context={})
return javascript_include_tag(:checklists, :plugin => 'redmine_checklists') +
stylesheet_link_tag(:checklists, :plugin => 'redmine_checklists')
end
end
end
end

View file

@ -0,0 +1,33 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Patches
module AddHelpersForChecklistPatch
def self.apply(controller)
controller.send(:helper, 'checklists')
end
end
end
end
[IssuesController].each do |controller|
RedmineChecklists::Patches::AddHelpersForChecklistPatch.apply(controller)
end

View file

@ -0,0 +1,275 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module Redmine
module ApiTest
# Base class for API tests
class Base < ActionDispatch::IntegrationTest
# Test that a request allows the three types of API authentication
#
# * HTTP Basic with username and password
# * HTTP Basic with an api key for the username
# * Key based with the key=X parameter
#
# @param [Symbol] http_method the HTTP method for request (:get, :post, :put, :delete)
# @param [String] url the request url
# @param [optional, Hash] parameters additional request parameters
# @param [optional, Hash] options additional options
# @option options [Symbol] :success_code Successful response code (:success)
# @option options [Symbol] :failure_code Failure response code (:unauthorized)
def self.should_allow_api_authentication(http_method, url, parameters={}, options={})
should_allow_http_basic_auth_with_username_and_password(http_method, url, parameters, options)
should_allow_http_basic_auth_with_key(http_method, url, parameters, options)
should_allow_key_based_auth(http_method, url, parameters, options)
end
# Test that a request allows the username and password for HTTP BASIC
#
# @param [Symbol] http_method the HTTP method for request (:get, :post, :put, :delete)
# @param [String] url the request url
# @param [optional, Hash] parameters additional request parameters
# @param [optional, Hash] options additional options
# @option options [Symbol] :success_code Successful response code (:success)
# @option options [Symbol] :failure_code Failure response code (:unauthorized)
def self.should_allow_http_basic_auth_with_username_and_password(http_method, url, parameters={}, options={})
success_code = options[:success_code] || :success
failure_code = options[:failure_code] || :unauthorized
context "should allow http basic auth using a username and password for #{http_method} #{url}" do
context "with a valid HTTP authentication" do
setup do
@user = User.generate! do |user|
user.admin = true
user.password = 'my_password'
end
send(http_method, url, parameters, credentials(@user.login, 'my_password'))
end
should_respond_with success_code
should_respond_with_content_type_based_on_url(url)
should "login as the user" do
assert_equal @user, User.current
end
end
context "with an invalid HTTP authentication" do
setup do
@user = User.generate!
send(http_method, url, parameters, credentials(@user.login, 'wrong_password'))
end
should_respond_with failure_code
should_respond_with_content_type_based_on_url(url)
should "not login as the user" do
assert_equal User.anonymous, User.current
end
end
context "without credentials" do
setup do
send(http_method, url, parameters)
end
should_respond_with failure_code
should_respond_with_content_type_based_on_url(url)
should "include_www_authenticate_header" do
assert @controller.response.headers.has_key?('WWW-Authenticate')
end
end
end
end
# Test that a request allows the API key with HTTP BASIC
#
# @param [Symbol] http_method the HTTP method for request (:get, :post, :put, :delete)
# @param [String] url the request url
# @param [optional, Hash] parameters additional request parameters
# @param [optional, Hash] options additional options
# @option options [Symbol] :success_code Successful response code (:success)
# @option options [Symbol] :failure_code Failure response code (:unauthorized)
def self.should_allow_http_basic_auth_with_key(http_method, url, parameters={}, options={})
success_code = options[:success_code] || :success
failure_code = options[:failure_code] || :unauthorized
context "should allow http basic auth with a key for #{http_method} #{url}" do
context "with a valid HTTP authentication using the API token" do
setup do
@user = User.generate! do |user|
user.admin = true
end
@token = Token.create!(:user => @user, :action => 'api')
send(http_method, url, parameters, credentials(@token.value, 'X'))
end
should_respond_with success_code
should_respond_with_content_type_based_on_url(url)
should_be_a_valid_response_string_based_on_url(url)
should "login as the user" do
assert_equal @user, User.current
end
end
context "with an invalid HTTP authentication" do
setup do
@user = User.generate!
@token = Token.create!(:user => @user, :action => 'feeds')
send(http_method, url, parameters, credentials(@token.value, 'X'))
end
should_respond_with failure_code
should_respond_with_content_type_based_on_url(url)
should "not login as the user" do
assert_equal User.anonymous, User.current
end
end
end
end
# Test that a request allows full key authentication
#
# @param [Symbol] http_method the HTTP method for request (:get, :post, :put, :delete)
# @param [String] url the request url, without the key=ZXY parameter
# @param [optional, Hash] parameters additional request parameters
# @param [optional, Hash] options additional options
# @option options [Symbol] :success_code Successful response code (:success)
# @option options [Symbol] :failure_code Failure response code (:unauthorized)
def self.should_allow_key_based_auth(http_method, url, parameters={}, options={})
success_code = options[:success_code] || :success
failure_code = options[:failure_code] || :unauthorized
context "should allow key based auth using key=X for #{http_method} #{url}" do
context "with a valid api token" do
setup do
@user = User.generate! do |user|
user.admin = true
end
@token = Token.create!(:user => @user, :action => 'api')
# Simple url parse to add on ?key= or &key=
request_url = if url.match(/\?/)
url + "&key=#{@token.value}"
else
url + "?key=#{@token.value}"
end
send(http_method, request_url, parameters)
end
should_respond_with success_code
should_respond_with_content_type_based_on_url(url)
should_be_a_valid_response_string_based_on_url(url)
should "login as the user" do
assert_equal @user, User.current
end
end
context "with an invalid api token" do
setup do
@user = User.generate! do |user|
user.admin = true
end
@token = Token.create!(:user => @user, :action => 'feeds')
# Simple url parse to add on ?key= or &key=
request_url = if url.match(/\?/)
url + "&key=#{@token.value}"
else
url + "?key=#{@token.value}"
end
send(http_method, request_url, parameters)
end
should_respond_with failure_code
should_respond_with_content_type_based_on_url(url)
should "not login as the user" do
assert_equal User.anonymous, User.current
end
end
end
context "should allow key based auth using X-Redmine-API-Key header for #{http_method} #{url}" do
setup do
@user = User.generate! do |user|
user.admin = true
end
@token = Token.create!(:user => @user, :action => 'api')
send(http_method, url, parameters, {'X-Redmine-API-Key' => @token.value.to_s})
end
should_respond_with success_code
should_respond_with_content_type_based_on_url(url)
should_be_a_valid_response_string_based_on_url(url)
should "login as the user" do
assert_equal @user, User.current
end
end
end
# Uses should_respond_with_content_type based on what's in the url:
#
# '/project/issues.xml' => should_respond_with_content_type :xml
# '/project/issues.json' => should_respond_with_content_type :json
#
# @param [String] url Request
def self.should_respond_with_content_type_based_on_url(url)
case
when url.match(/xml/i)
should "respond with XML" do
assert_equal 'application/xml', @response.content_type
end
when url.match(/json/i)
should "respond with JSON" do
assert_equal 'application/json', @response.content_type
end
else
raise "Unknown content type for should_respond_with_content_type_based_on_url: #{url}"
end
end
# Uses the url to assert which format the response should be in
#
# '/project/issues.xml' => should_be_a_valid_xml_string
# '/project/issues.json' => should_be_a_valid_json_string
#
# @param [String] url Request
def self.should_be_a_valid_response_string_based_on_url(url)
case
when url.match(/xml/i)
should_be_a_valid_xml_string
when url.match(/json/i)
should_be_a_valid_json_string
else
raise "Unknown content type for should_be_a_valid_response_based_on_url: #{url}"
end
end
# Checks that the response is a valid JSON string
def self.should_be_a_valid_json_string
should "be a valid JSON string (or empty)" do
assert(response.body.blank? || ActiveSupport::JSON.decode(response.body))
end
end
# Checks that the response is a valid XML string
def self.should_be_a_valid_xml_string
should "be a valid XML string" do
assert REXML::Document.new(response.body)
end
end
def self.should_respond_with(status)
should "respond with #{status}" do
assert_response status
end
end
end
end
end

View file

@ -0,0 +1,69 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require_dependency 'journal'
module RedmineChecklists
module Patches
module JournalPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
end
end
module InstanceMethods
if Redmine::VERSION.to_s < '2.6'
def send_notification
if notify? &&
(Setting.notified_events.include?('issue_updated') ||
(Setting.notified_events.include?('issue_note_added') && notes.present?) ||
(Setting.notified_events.include?('issue_status_updated') && new_status.present?) ||
(Setting.notified_events.include?('issue_priority_updated') && new_value_for('priority_id').present?)
)
checklist_email_nootification(self).deliver
end
end
def detail_for_attribute(attribute)
details.detect { |detail| detail.prop_key == attribute }
end
end
def checklist_email_nootification(journal)
if Redmine::VERSION.to_s < '2.4'
Mailer.issue_edit(journal)
else
to_users = Redmine::VERSION.to_s <= '3.0' ? journal.notified_users : journal.recipients
cc_users = Redmine::VERSION.to_s <= '3.0' ? journal.notified_watchers - to_users : journal.watcher_recipients - to_users
Mailer.issue_edit(journal, to_users, cc_users)
end
end
end
end
end
end
unless Journal.included_modules.include?(RedmineChecklists::Patches::JournalPatch)
Journal.send(:include, RedmineChecklists::Patches::JournalPatch)
end

View file

@ -0,0 +1,37 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
class OpenStruct2 < OpenStruct
undef id if defined?(id)
def to_h
json
end
def [](key)
json[key.to_s]
end
def json
return @json if @json
@json = JSON.parse(to_json)
@json = @json['table'] if @json.has_key?('table')
@json
end
end

View file

@ -0,0 +1,22 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
if Redmine::VERSION.to_s < '2.3'
Dir[File.dirname(__FILE__) + '/compatibility/2.1/*.rb'].each { |f| require f }
end

View file

@ -0,0 +1,74 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require_dependency 'issue'
module RedmineChecklists
module Patches
module IssuePatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
attr_accessor :old_checklists
attr_reader :copied_from
alias_method_chain :copy, :checklist
after_save :copy_subtask_checklists
if ActiveRecord::VERSION::MAJOR >= 4
has_many :checklists, lambda { order("#{Checklist.table_name}.position") }, :class_name => "Checklist", :dependent => :destroy, :inverse_of => :issue
else
has_many :checklists, :class_name => "Checklist", :dependent => :destroy, :inverse_of => :issue,
:order => 'position'
end
accepts_nested_attributes_for :checklists, :allow_destroy => true, :reject_if => proc { |attrs| attrs["subject"].blank? }
safe_attributes 'checklists_attributes',
:if => lambda {|issue, user| (user.allowed_to?(:done_checklists, issue.project) ||
user.allowed_to?(:edit_checklists, issue.project))}
def copy_checklists(arg)
issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
issue.checklists.each{ |checklist| Checklist.create(checklist.attributes.except('id','issue_id').merge(:issue => self)) } if issue
end
end
end
module InstanceMethods
def copy_subtask_checklists
return if !copy? || parent_id.nil? || checklists.any?
copy_checklists(@copied_from)
end
def copy_with_checklist(attributes = nil, copy_options = {})
copy = copy_without_checklist(attributes, copy_options)
copy.copy_checklists(self)
copy
end
end
end
end
end
unless Issue.included_modules.include?(RedmineChecklists::Patches::IssuePatch)
Issue.send(:include, RedmineChecklists::Patches::IssuePatch)
end

View file

@ -0,0 +1,37 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require_dependency 'query'
module RedmineChecklists
module Patches
module IssueQueryPatch
def self.included(base)
base.send(:include, InstanceMethods)
end
module InstanceMethods
end
end
end
end
unless IssueQuery.included_modules.include?(RedmineChecklists::Patches::IssueQueryPatch)
IssueQuery.send(:include, RedmineChecklists::Patches::IssueQueryPatch)
end

View file

@ -0,0 +1,76 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Patches
module IssuesControllerPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
alias_method_chain :build_new_issue_from_params, :checklist
before_filter :save_before_state, :only => [:update]
end
end
module InstanceMethods
def build_new_issue_from_params_with_checklist
if params[:id].blank?
if params[:copy_from].blank?
else
fill_checklist_attributes
end
end
build_new_issue_from_params_without_checklist
end
def save_before_state
@issue.old_checklists = @issue.checklists.to_json
end
def fill_checklist_attributes
return unless params[:issue].blank?
begin
@copy_from = Issue.visible.find(params[:copy_from])
add_checklists_to_params(@copy_from.checklists)
rescue ActiveRecord::RecordNotFound
render_404
return
end
end
def add_checklists_to_params(checklists)
params[:issue].blank? ? params[:issue] = { :checklists_attributes => {} } : params[:issue][:checklists_attributes] = {}
checklists.each_with_index do |checklist_item, index|
params[:issue][:checklists_attributes][index.to_s] = { :is_done => checklist_item.is_done,
:subject => checklist_item.subject,
:position => checklist_item.position }
end
end
end
end
end
end
unless IssuesController.included_modules.include?(RedmineChecklists::Patches::IssuesControllerPatch)
IssuesController.send(:include, RedmineChecklists::Patches::IssuesControllerPatch)
end

View file

@ -0,0 +1,90 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
module RedmineChecklists
module Patches
module IssuesHelperPatch
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
alias_method_chain :details_to_strings, :checklists
alias_method_chain :render_email_issue_attributes, :checklists if Redmine::VERSION.to_s <= '2.4' && Redmine::VERSION.to_s >= '2.2'
end
end
module InstanceMethods
def render_email_issue_attributes_with_checklists(issue, html = false)
journal = issue.journals.order(:id).last
return render_email_issue_attributes_without_checklists(issue, html) unless journal
details = journal.details
return render_email_issue_attributes_without_checklists(issue, html) unless details
checklist_details = details.select{ |x| x.prop_key == 'checklist'}
return render_email_issue_attributes_without_checklists(issue, html) unless checklist_details.any?
return render_email_issue_attributes_without_checklists(issue, html) + details_to_strings_with_checklists(checklist_details, !html).join(html ? "<br/>".html_safe : "\n")
end
def details_to_strings_with_checklists(details, no_html = false, options = {})
details_checklist, details_other = details.partition{ |x| x.prop_key == 'checklist' }
details_checklist.map do |detail|
result = []
diff = Hash.new([])
if Checklist.old_format?(detail)
result << "<b>#{l(:label_checklist_item)}</b> #{l(:label_checklist_changed_from)} #{detail.old_value} #{l(:label_checklist_changed_to)} #{detail.value}"
else
diff = JournalChecklistHistory.new(detail.old_value, detail.value).diff
end
if diff[:done].any?
diff[:done].each do |item|
result << "<b>#{ERB::Util.h l(:label_checklist_item)}</b> <input type='checkbox' #{item.is_done ? 'checked' : '' } disabled> <i>#{ERB::Util.h item[:subject]}</i> #{ERB::Util.h l(:label_checklist_done)}"
end
end
if diff[:undone].any?
diff[:undone].each do |item|
result << "<b>#{ERB::Util.h l(:label_checklist_item)}</b> <input type='checkbox' #{item.is_done ? 'checked' : '' } disabled> <i>#{ERB::Util.h item[:subject]}</i> #{ERB::Util.h l(:label_checklist_undone)}"
end
end
result = result.join('</li><li>').html_safe
result = nil if result.blank?
if result && no_html
result = result.gsub /<\/li><li>/, "\n"
result = result.gsub /<input type='checkbox'[^c^>]*checked[^>]*>/, '[x]'
result = result.gsub /<input type='checkbox'[^c^>]*>/, '[ ]'
result = result.gsub /<[^>]*>/, ''
result = CGI.unescapeHTML(result)
end
result
end.compact + details_to_strings_without_checklists(details_other, no_html, options)
end
end
end
end
end
unless IssuesHelper.included_modules.include?(RedmineChecklists::Patches::IssuesHelperPatch)
IssuesHelper.send(:include, RedmineChecklists::Patches::IssuesHelperPatch)
end

View file

@ -0,0 +1,20 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.

View file

@ -0,0 +1,46 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require_dependency 'project'
module RedmineChecklists
module Patches
module ProjectPatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
alias_method_chain :copy_issues, :checklist
end
end
module InstanceMethods
def copy_issues_with_checklist(project)
copy_issues_without_checklist(project)
issues.each{ |issue| issue.copy_checklists(issue.copied_from)}
end
end
end
end
end
unless Project.included_modules.include?(RedmineChecklists::Patches::ProjectPatch)
Project.send(:include, RedmineChecklists::Patches::ProjectPatch)
end

View file

@ -0,0 +1,37 @@
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
Rails.configuration.to_prepare do
require 'redmine_checklists/hooks/views_issues_hook'
require 'redmine_checklists/hooks/views_layouts_hook'
require 'redmine_checklists/hooks/controller_issues_hook'
require 'redmine_checklists/patches/issue_patch'
require 'redmine_checklists/patches/project_patch'
require 'redmine_checklists/patches/issues_controller_patch'
require 'redmine_checklists/patches/add_helpers_for_checklists_patch'
require 'redmine_checklists/patches/compatibility_patch'
require 'redmine_checklists/patches/issues_helper_patch'
require 'redmine_checklists/patches/compatibility/open_struct_patch'
require 'redmine_checklists/patches/compatibility/journal_patch'
end
module RedmineChecklists
def self.settings() Setting[:plugin_redmine_checklists].blank? ? {} : Setting[:plugin_redmine_checklists] end
end

View file

@ -0,0 +1,12 @@
#!/bin/bash
RUBY=$1
DB=$2
REDMINE=$3
docker run -t -i -v `pwd`:/var/www/$RUBY/$DB/$REDMINE/plugins/redmine_checklists \
--env RUBY=$1 \
--env DB=$2 \
--env REDMINE=$3 \
--env PLUGIN=redmine_checklists \
redmineup/redmine_checklists \
/root/run_local.sh

View file

@ -0,0 +1,16 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
id: 1
is_done: false
subject: First todo
issue_id: 1
two:
id: 2
is_done: true
subject: Second todo
issue_id: 1
three:
id: 3
is_done: true
subject: Third todo
issue_id: 2

View file

@ -0,0 +1,92 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path('../../test_helper', __FILE__)
class ChecklistsControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
[:checklists])
def setup
RedmineChecklists::TestCase.prepare
Setting.default_language = 'en'
Project.find(1).enable_module!(:checklists)
User.current = nil
@project_1 = Project.find(1)
@issue_1 = Issue.find(1)
@checklist_1 = Checklist.find(1)
end
test "should post done" do
# log_user('admin', 'admin')
@request.session[:user_id] = 1
xhr :put, :done, :is_done => 'true', :id => '1'
assert_response :success, 'Post done not working'
assert_equal true, Checklist.find(1).is_done, 'Post done not working'
end
test "should not post done by deny user" do
# log_user('admin', 'admin')
@request.session[:user_id] = 5
xhr :put, :done, :is_done => true, :id => "1"
assert_response 403, "Post done accessible for all"
end
test "should view issue with checklist" do
# log_user('admin', 'admin')
@request.session[:user_id] = 1
@controller = IssuesController.new
get :show, :id => @issue_1.id
assert_select 'ul#checklist_items li#checklist_item_1', @checklist_1.subject, "Issue won't view for admin"
end
test "should not view issue with checklist if deny" do
# log_user('anonymous', '')
@request.session[:user_id] = 5
@controller = IssuesController.new
get :show, :id => @issue_1.id
assert_select 'ul#checklist_items', false, "Issue view for anonymous"
end
end

View file

@ -0,0 +1,200 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path('../../test_helper', __FILE__)
# Re-raise errors caught by the controller.
# class HelpdeskMailerController; def rescue_action(e) raise e end; end
class IssuesControllerTest < ActionController::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
[:checklists])
def setup
@request.session[:user_id] = 1
end
def test_new_issue_without_project
get :new
assert_response :success
end if Redmine::VERSION.to_s > '3.0'
def test_get_show_issue
issue = Issue.find(1)
assert_not_nil issue.checklists.first
get :show, :id => 1
assert_response :success
assert_select "ul#checklist_items li#checklist_item_1", /First todo/
assert_select "ul#checklist_items li#checklist_item_1 input[checked=?]", "checked", {:count => 0}
assert_select "ul#checklist_items li#checklist_item_2 input[checked=?]", "checked"
end
def test_get_edit_issue
get :edit, :id => 1
assert_response :success
end
def test_get_copy_issue
get :new, :project_id => 1, :copy_from => 1
assert_response :success
assert_select "span#checklist_form_items span.checklist-subject", {:count => 3}
assert_select "span#checklist_form_items span.checklist-edit input[value=?]", "First todo"
end
def test_put_update_form
parameters = {:tracker_id => 2,
:checklists_attributes => {
"0" => {"is_done"=>"0", "subject"=>"First"},
"1" => {"is_done"=>"0", "subject"=>"Second"}}}
@request.session[:user_id] = 1
issue = Issue.find(1)
if Redmine::VERSION.to_s > '2.3' && Redmine::VERSION.to_s < '3.0'
xhr :put, :update_form,
:issue => parameters,
:project_id => issue.project
else
xhr :put, :new,
:issue => parameters,
:project_id => issue.project
end
assert_response :success
assert_equal 'text/javascript', response.content_type
if Redmine::VERSION.to_s < '3.0'
assert_template 'update_form'
else
assert_template 'new'
end
issue = assigns(:issue)
assert_kind_of Issue, issue
assert_match 'First', issue.checklists.map(&:subject).join
end
def test_added_attachment_shows_in_log_once
Setting[:plugin_redmine_checklists] = { :save_log => 1, :issue_done_ratio => 0 }
set_tmp_attachments_directory
parameters = { :tracker_id => 2,
:checklists_attributes => {
'0' => { 'is_done' => '0', 'subject' => 'First' },
'1' => { 'is_done' => '0', 'subject' => 'Second' } } }
@request.session[:user_id] = 1
issue = Issue.find(1)
post :update,
:issue => parameters,
:attachments => { '1' => { 'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file' } },
:project_id => issue.project,
:id => issue.to_param
assert_response :redirect
assert_equal 1, Journal.last.details.where(:property => 'attachment').count
end
def test_history_dont_show_old_format_checklists
Setting[:plugin_redmine_checklists] = { :save_log => 1, :issue_done_ratio => 0 }
@request.session[:user_id] = 1
issue = Issue.find(1)
issue.journals.create!(:user_id => 1)
issue.journals.last.details.create!(:property => 'attr',
:prop_key => 'checklist',
:old_value => '[ ] TEST',
:value => '[x] TEST')
post :show, :id => issue.id
assert_response :success
last_journal = issue.journals.last
assert_equal last_journal.details.size, 1
assert_equal last_journal.details.first.prop_key, 'checklist'
assert_select "#change-#{last_journal.id} .details li", 'Checklist item changed from [ ] TEST to [x] TEST'
end
def test_empty_update_dont_write_to_journal
@request.session[:user_id] = 1
issue = Issue.find(1)
journals_before = issue.journals.count
post :update, :issue => {}, :id => issue.to_param, :project_id => issue.project
assert_response :redirect
assert_equal journals_before, issue.reload.journals.count
end
def test_create_issue_without_checklists
@request.session[:user_id] = 1
assert_difference 'Issue.count' do
post :create, :project_id => 1, :issue => { :tracker_id => 3,
:status_id => 2,
:subject => 'NEW issue without checklists',
:description => 'This is the description'
}
end
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
issue = Issue.find_by_subject('NEW issue without checklists')
assert_not_nil issue
end
def test_create_issue_using_json
old_value = Setting.rest_api_enabled
Setting.rest_api_enabled = '1'
@request.session[:user_id] = 1
assert_difference 'Issue.count' do
post :create, :format => :json, :project_id => 1, :issue => { :tracker_id => 3,
:status_id => 2,
:subject => 'NEW JSON issue',
:description => 'This is the description',
:checklists_attributes => [{:is_done => 0, :subject => 'JSON checklist'}]
},
:key => User.find(1).api_key
end
assert_response :created
issue = Issue.find_by_subject('NEW JSON issue')
assert_not_nil issue
assert_equal 1, issue.checklists.count
ensure
Setting.rest_api_enabled = old_value
end
end

View file

@ -0,0 +1,115 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.dirname(__FILE__) + '/../../test_helper'
class Redmine::ApiTest::ChecklistsTest < Redmine::ApiTest::Base
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
[:checklists])
def setup
Setting.rest_api_enabled = '1'
end
def test_get_checklists_xml
get '/issues/1/checklists.xml', {}, credentials('admin')
assert_select 'checklists[type=array]' do
assert_select 'checklist' do
assert_select 'id', :text => "1"
assert_select 'subject', :text => "First todo"
end
end
end
def test_get_checklists_1_xml
get '/checklists/1.xml', {}, credentials('admin')
assert_select 'checklist' do
assert_select 'id', :text => '1'
assert_select 'subject', :text => 'First todo'
end
end
def test_post_checklists_xml
parameters = {:checklist => {:issue_id => 1,
:subject => 'api_test_001',
:is_done => true}}
assert_difference('Checklist.count') do
post '/issues/1/checklists.xml', parameters, credentials('admin')
end
checklist = Checklist.order('id DESC').first
assert_equal parameters[:checklist][:subject], checklist.subject
assert_response :created
assert_equal 'application/xml', @response.content_type
assert_select 'checklist id', :text => checklist.id.to_s
end
def test_put_checklists_1_xml
parameters = {:checklist => {:subject => 'Item_UPDATED'}}
assert_no_difference('Checklist.count') do
put '/checklists/1.xml', parameters, credentials('admin')
end
checklist = Checklist.find(1)
assert_equal parameters[:checklist][:subject], checklist.subject
end
def test_delete_1_xml
assert_difference 'Checklist.count', -1 do
delete '/checklists/1.xml', {}, credentials('admin')
end
assert_response :ok
assert_equal '', @response.body
assert_nil Checklist.find_by_id(1)
end
end

View file

@ -0,0 +1,66 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path('../../test_helper', __FILE__)
class CommonIssueTest < RedmineChecklists::IntegrationTest
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
[:checklists])
def setup
RedmineChecklists::TestCase.prepare
Setting.default_language = 'en'
@project_1 = Project.find(1)
@issue_1 = Issue.find(1)
@checklist_1 = Checklist.find(1)
@request = ActionController::TestRequest.new
end
test "Global search with checklist" do
# log_user('admin', 'admin')
@request.session[:user_id] = 1
get "/search?q=First"
assert_response :success
end
end

View file

@ -0,0 +1,59 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
if ActiveRecord::VERSION::MAJOR >= 4
class RedmineChecklists::IntegrationTest < Redmine::IntegrationTest; end
else
class RedmineChecklists::IntegrationTest < ActionController::IntegrationTest; end
end
class RedmineChecklists::TestCase
def self.create_fixtures(fixtures_directory, table_names, class_names = {})
if ActiveRecord::VERSION::MAJOR >= 4
ActiveRecord::FixtureSet.create_fixtures(fixtures_directory, table_names, class_names = {})
else
ActiveRecord::Fixtures.create_fixtures(fixtures_directory, table_names, class_names = {})
end
end
def self.prepare
Role.find(1, 2, 3, 4).each do |r|
r.permissions << :edit_checklists
r.save
end
Role.find(3, 4).each do |r|
r.permissions << :done_checklists
r.save
end
Role.find([2]).each do |r|
r.permissions << :manage_checklist_templates
r.save
end
end
end

View file

@ -0,0 +1,93 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path('../../test_helper', __FILE__)
class ChecklistTest < ActiveSupport::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
[:checklists])
def setup
RedmineChecklists::TestCase.prepare
Setting.default_language = 'en'
@project_1 = Project.find(1)
@issue_1 = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 1,
:status_id => 1, :priority => IssuePriority.first,
:subject => 'Invoice Issue 1')
@checklist_1 = Checklist.create(:subject => 'TEST1', :position => 1, :issue => @issue_1)
end
test "should save checklist" do
assert @checklist_1.save, "Checklist save error"
end
test "should not save checklist without subject" do
@checklist_1.subject = nil
assert !@checklist_1.save, "Checklist save with nil subject"
end
test "should not save checklist without position" do
@checklist_1.position = nil
assert !@checklist_1.save, "Checklist save with nil position"
end
test "should not save checklist with non integer position" do
@checklist_1.position = "string"
assert !@checklist_1.save, "Checklist save with non ingeger position"
end
test "should return project info" do
assert_equal @project_1, @checklist_1.project, "Helper project broken"
end
test "should return info about checklist" do
assert_equal "[ ] #{@checklist_1.subject}", @checklist_1.info, "Helper info broken"
@checklist_1.is_done = 1
assert_equal "[x] #{@checklist_1.subject}", @checklist_1.info, "Helper info broken"
end
end

View file

@ -0,0 +1,73 @@
# encoding: utf-8
#
# This file is a part of Redmine Checklists (redmine_checklists) plugin,
# issue checklists management plugin for Redmine
#
# Copyright (C) 2011-2017 RedmineUP
# http://www.redmineup.com/
#
# redmine_checklists is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# redmine_checklists is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with redmine_checklists. If not, see <http://www.gnu.org/licenses/>.
require File.expand_path('../../test_helper', __FILE__)
class ProjectTest < ActiveSupport::TestCase
fixtures :projects,
:users,
:roles,
:members,
:member_roles,
:issues,
:issue_statuses,
:versions,
:trackers,
:projects_trackers,
:issue_categories,
:enabled_modules,
:enumerations,
:attachments,
:workflows,
:custom_fields,
:custom_values,
:custom_fields_projects,
:custom_fields_trackers,
:time_entries,
:journals,
:journal_details,
:queries
RedmineChecklists::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_checklists).directory + '/test/fixtures/',
[:checklists])
def setup
RedmineChecklists::TestCase.prepare
Setting.default_language = 'en'
@project_1 = Project.find(1)
@issue_1 = Issue.create(:project => @project_1, :tracker_id => 1, :author_id => 1,
:status_id => 1, :priority => IssuePriority.first,
:subject => 'TestIssue')
@checklist_1 = Checklist.create(:subject => 'TEST1', :position => 1, :issue => @issue_1)
@checklist_1 = Checklist.create(:subject => 'TEST2', :position => 2, :issue => @issue_1, :is_done => true)
end
test 'should copy checklists' do
project_copy = Project.copy_from(Project.find(1))
project_copy.name = 'Test name'
project_copy.identifier = Project.next_identifier
project_copy.copy(Project.find(1))
checklists_copies = project_copy.issues.where(:subject => 'TestIssue').first.checklists
assert_equal(checklists_copies.count, 2)
assert_equal(checklists_copies.where(:subject => 'TEST1').first.is_done, false)
assert_equal(checklists_copies.where(:subject => 'TEST2').first.is_done, true)
end
end