Skip to content

Commit

Permalink
Upgrade to Rails 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
buithehien1991 committed Dec 17, 2019
1 parent c4e1f03 commit 8b547d2
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 52 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gem 'acts_as_list', "0.9.19"
3 changes: 1 addition & 2 deletions app/controllers/adburndown_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class AdburndownController < ApplicationController
unloadable

before_filter :find_project, :authorize
before_action :find_project, :authorize

def show
# data for filters
Expand Down
13 changes: 1 addition & 12 deletions app/controllers/admytasks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
class AdmytasksController < ApplicationController
unloadable





#before_filter :authorize
#before_action :authorize

def list
# data for filters
Expand Down Expand Up @@ -41,11 +35,6 @@ def list
end
end






private

def find_project
Expand Down
9 changes: 4 additions & 5 deletions app/controllers/adsprintinl_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
class AdsprintinlController < ApplicationController
unloadable

before_filter :find_project, :authorize
before_action :find_project, :authorize

def create
attribs = params.select{|k,v| k != 'id' and Sprints.column_names.include? k }
attribs = Hash[*attribs.flatten]
sprint = Sprints.new(attribs)
attribs = (attribs || {}).deep_dup
sprint = Sprints
sprint.safe_attributes = attribs
begin
sprint.save!
rescue => e
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/adsprints_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class AdsprintsController < ApplicationController
unloadable

before_filter :find_project, :authorize
before_action :find_project, :authorize

def list
@backlog = SprintsTasks.get_backlog(@project)
Expand Down
28 changes: 19 additions & 9 deletions app/controllers/adtaskinl_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
class AdtaskinlController < ApplicationController
unloadable

before_filter :find_project, :authorize, :except=> :update
before_action :find_project, :authorize, :except=> :update

def update
task = SprintsTasks.find(params[:id])
Expand All @@ -23,16 +21,28 @@ def update
def create
trackers_avail=@project.trackers().select('id').all().pluck(:id)
attribs = params.select{|k,v| k != 'id' and SprintsTasks.column_names.include? k }
attribs = (attribs || {}).deep_dup

attribs = Hash[*attribs.flatten]
attribs['tracker_id'] = attribs['tracker_id'] || Setting.plugin_AgileDwarf[:tracker]
#attribs = Hash[*attribs.flatten]
#attribs['tracker_id'] = attribs['tracker_id'] || Setting.plugin_AgileDwarf[:tracker]

if !trackers_avail.include?(attribs['tracker_id'])
attribs['tracker_id']=@project.trackers().first()
#if !trackers_avail.include?(attribs['tracker_id'])
# attribs['tracker_id'][email protected]().first()
#end

#attribs['author_id'] = User.current.id
#task = SprintsTasks.new(attribs)
task = SprintsTasks.new

tracker_id = attribs.delete(:tracker_id)
tracker_id = Setting.plugin_AgileDwarf[:tracker] unless tracker_id.present?
unless trackers_avail.include?(tracker_id)
tracker_id = @project.trackers.first
end

attribs['author_id'] = User.current.id
task = SprintsTasks.new(attribs)
task.tracker_id = tracker_id
task.author_id = User.current.id
task.safe_attributes = attribs
begin
task.save!
rescue => e
Expand Down
8 changes: 1 addition & 7 deletions app/controllers/adtasks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
class AdtasksController < ApplicationController
unloadable





before_filter :find_project, :authorize
before_action :find_project, :authorize

def list
# data for filters
Expand Down
2 changes: 0 additions & 2 deletions app/models/sprints.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class Sprints < Version
unloadable

validate :start_and_end_dates

class << self
Expand Down
2 changes: 0 additions & 2 deletions app/models/sprints_tasks.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class SprintsTasks < Issue
unloadable

acts_as_list :column => "ir_position"

ORDER = 'case when issues.ir_position is null then 1 else 0 end ASC, case when issues.ir_position is NULL then issues.id else issues.ir_position end ASC'
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/001_add_issue_position.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddIssuePosition < ActiveRecord::Migration
class AddIssuePosition < ActiveRecord::Migration[5.0]
def self.up
add_column :issues, :ir_position, :integer, :null => true, :default => nil
add_index :issues, :ir_position
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/002_add_versions_range.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddVersionsRange < ActiveRecord::Migration
class AddVersionsRange < ActiveRecord::Migration[5.0]
def self.up
add_column :versions, :ir_start_date, :date, :null => true
add_column :versions, :ir_end_date, :date, :null => true
Expand Down
8 changes: 7 additions & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name 'Agile dwarf plugin'
author 'Mark Ablovacky'
description 'Agile for Redmine'
version '0.0.3'
version '0.0.4.tsdv'
url ''

settings :default => {
Expand All @@ -30,4 +30,10 @@
menu :project_menu, :adsprints, { :controller => 'adsprints', :action => 'list' }, :caption => :label_menu_sprints, :after => :adtasks, :param => :project_id
menu :project_menu, :adburndown, { :controller => 'adburndown', :action => 'show' }, :caption => :label_menu_burndown, :after => :adsprints, :param => :project_id
menu :top_menu, :admytasks, {:controller=>'admytasks',:action=>'list'}, :caption=>:label_my_tasks_board

ActiveSupport::Reloader.to_prepare do
unless EnabledModule.included_modules.include?(EnabledModulePatch)
EnabledModule.send(:prepend, EnabledModulePatch)
end
end
end
14 changes: 6 additions & 8 deletions lib/scrum_enabled_module_patch.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
require_dependency 'enabled_module'

module EnabledModulePatch
def self.included(base)
base.send(:include, InstanceMethods)
def self.prepended(base)
base.send(:prepend, InstanceMethods)
base.class_eval do
alias_method_chain :module_enabled, :scrum

end
end

module InstanceMethods
# init task positions when enable module
def module_enabled_with_scrum
def module_enabled
if name == 'scrum'
max = 0
ActiveRecord::Base.connection.execute("select max(ir_position) from issues where project_id = #{self.project_id}").each{|row| max = row[0]}
ActiveRecord::Base.connection.execute "update issues set ir_position = #{max} + id where ir_position is null"
logger.info("Module attached to project #{self.project_id}")
end
module_enabled_without_scrum
super
end
end
end

EnabledModule.send(:include, EnabledModulePatch)
end

0 comments on commit 8b547d2

Please sign in to comment.