Skip to content

Commit

Permalink
Compatibility for Redmine 4 / Rails 5
Browse files Browse the repository at this point in the history
  • Loading branch information
canidas committed Mar 7, 2019
1 parent a090fc3 commit 09596b7
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 32 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Link to Redmine plugin page: https://www.redmine.org/plugins/redmine_issue_todo_

## Compatibility

* Last tested with Redmine 3.4, should also work with 2.6 - 3.3
* Version 1.3 for >= Redmine 4 **ONLY**
* Version 1.2 for <= Redmine 3.4
* Currently there's no difference between 1.2 and 1.3 except Redmine 4 compatibility

## Features

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/issue_todo_list_items_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class IssueTodoListItemsController < ApplicationController

before_filter :find_project
before_filter :find_todo_list
before_action :find_project
before_action :find_todo_list

def create
@item = IssueTodoListItem.new
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/issue_todo_lists_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class IssueTodoListsController < ApplicationController

before_filter :find_project, :except => [:bulk_allocate_issues]
before_filter :find_todo_list, :only => [:show, :edit, :update, :destroy, :update_item_order, :bulk_allocate_issues]
before_action :find_project, :except => [:bulk_allocate_issues]
before_action :find_todo_list, :only => [:show, :edit, :update, :destroy, :update_item_order, :bulk_allocate_issues]

def index
@todo_lists = IssueTodoList.where(project_id: @project.id).order('id')
Expand Down
8 changes: 1 addition & 7 deletions app/models/issue_todo_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ class IssueTodoList < ActiveRecord::Base
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by'
belongs_to :last_updated_by, :class_name => 'User', :foreign_key => 'last_updated_by'

# Rails 3 (Redmine 2) and Rails 4 (Redmine 3)
if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new('4.0.0')
has_many :issue_todo_list_items, -> { order('position ASC') }, dependent: :destroy
else
has_many :issue_todo_list_items, dependent: :destroy, :order => 'position ASC'
end

has_many :issue_todo_list_items, -> { order('position ASC') }, dependent: :destroy
has_many :issues, through: :issue_todo_list_items

validates :title, presence: true
Expand Down
17 changes: 1 addition & 16 deletions db/migrate/001_create_todo_lists.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
class CreateTodoLists < ActiveRecord::Migration
class CreateTodoLists < ActiveRecord::Migration[4.2]
def up
# Check if migration has already been run
version = ::ActiveRecord::Base.connection.select_values(
"SELECT version FROM #{::ActiveRecord::Migrator.schema_migrations_table_name} WHERE version='1-issue_todo_lists'"
)

# Plugin directory has been renamed
# Delete entry and return because migration adds entry afterwards anyway
if version.length != 0
execute <<-SQL
DELETE FROM #{::ActiveRecord::Migrator.schema_migrations_table_name} WHERE version = '1-issue_todo_lists';
SQL

return
end

create_table :issue_todo_lists do |t|
t.string :project_identifier
t.string :title
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/002_remove_closed_issues.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RemoveClosedIssues < ActiveRecord::Migration
class RemoveClosedIssues < ActiveRecord::Migration[4.2]
def change
add_column :issue_todo_lists, :remove_closed_issues, :boolean, :default => false, :null => false
end
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/003_project_identifier_to_id.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ProjectIdentifierToId < ActiveRecord::Migration
class ProjectIdentifierToId < ActiveRecord::Migration[4.2]
def up
add_column :issue_todo_lists, :project_id, :integer, null: true, after: :id

Expand Down
2 changes: 1 addition & 1 deletion db/migrate/004_todo_list_item_comments.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class TodoListItemComments < ActiveRecord::Migration
class TodoListItemComments < ActiveRecord::Migration[4.2]
def change
add_column :issue_todo_list_items, :comment, :text, :after => :issue_id
end
Expand Down
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
name 'Issue To-do Lists Plugin'
author 'Den'
description 'Organize issues in to-do lists by manually ordering their priority'
version '1.2'
version '1.3'
url 'https://github.com/canidas/redmine_issue_todo_lists'
author_url 'mailto:[email protected]'

Expand Down

0 comments on commit 09596b7

Please sign in to comment.