diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..83f5661 --- /dev/null +++ b/Gemfile @@ -0,0 +1 @@ +gem 'acts_as_list', "0.9.19" \ No newline at end of file diff --git a/app/controllers/adburndown_controller.rb b/app/controllers/adburndown_controller.rb index 41ea14d..c2c81ba 100644 --- a/app/controllers/adburndown_controller.rb +++ b/app/controllers/adburndown_controller.rb @@ -1,7 +1,6 @@ class AdburndownController < ApplicationController - unloadable - before_filter :find_project, :authorize + before_action :find_project, :authorize def show # data for filters diff --git a/app/controllers/admytasks_controller.rb b/app/controllers/admytasks_controller.rb index 6303264..a2d2d8b 100644 --- a/app/controllers/admytasks_controller.rb +++ b/app/controllers/admytasks_controller.rb @@ -1,11 +1,5 @@ class AdmytasksController < ApplicationController - unloadable - - - - - - #before_filter :authorize + #before_action :authorize def list # data for filters @@ -41,11 +35,6 @@ def list end end - - - - - private def find_project diff --git a/app/controllers/adsprintinl_controller.rb b/app/controllers/adsprintinl_controller.rb index f1364c3..a842626 100644 --- a/app/controllers/adsprintinl_controller.rb +++ b/app/controllers/adsprintinl_controller.rb @@ -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 diff --git a/app/controllers/adsprints_controller.rb b/app/controllers/adsprints_controller.rb index 4349678..a654673 100644 --- a/app/controllers/adsprints_controller.rb +++ b/app/controllers/adsprints_controller.rb @@ -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) diff --git a/app/controllers/adtaskinl_controller.rb b/app/controllers/adtaskinl_controller.rb index ab10a93..db1d1f7 100644 --- a/app/controllers/adtaskinl_controller.rb +++ b/app/controllers/adtaskinl_controller.rb @@ -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]) @@ -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']=@project.trackers().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 diff --git a/app/controllers/adtasks_controller.rb b/app/controllers/adtasks_controller.rb index d9a2c46..127320f 100644 --- a/app/controllers/adtasks_controller.rb +++ b/app/controllers/adtasks_controller.rb @@ -1,11 +1,5 @@ class AdtasksController < ApplicationController - unloadable - - - - - - before_filter :find_project, :authorize + before_action :find_project, :authorize def list # data for filters diff --git a/app/models/sprints.rb b/app/models/sprints.rb index 27a5a05..c0e7e2a 100644 --- a/app/models/sprints.rb +++ b/app/models/sprints.rb @@ -1,6 +1,4 @@ class Sprints < Version - unloadable - validate :start_and_end_dates class << self diff --git a/app/models/sprints_tasks.rb b/app/models/sprints_tasks.rb index 5a87ba8..408b340 100644 --- a/app/models/sprints_tasks.rb +++ b/app/models/sprints_tasks.rb @@ -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' diff --git a/db/migrate/001_add_issue_position.rb b/db/migrate/001_add_issue_position.rb index 01f38bf..9bb7af4 100644 --- a/db/migrate/001_add_issue_position.rb +++ b/db/migrate/001_add_issue_position.rb @@ -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 diff --git a/db/migrate/002_add_versions_range.rb b/db/migrate/002_add_versions_range.rb index 120834e..fe1ef01 100644 --- a/db/migrate/002_add_versions_range.rb +++ b/db/migrate/002_add_versions_range.rb @@ -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 diff --git a/init.rb b/init.rb index 2cb10a2..176c581 100644 --- a/init.rb +++ b/init.rb @@ -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 => { @@ -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 diff --git a/lib/scrum_enabled_module_patch.rb b/lib/scrum_enabled_module_patch.rb index 9cfa565..a809a12 100644 --- a/lib/scrum_enabled_module_patch.rb +++ b/lib/scrum_enabled_module_patch.rb @@ -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) \ No newline at end of file +end \ No newline at end of file