Skip to content

Commit

Permalink
Backlog upgrade for redmine 4.0.5
Browse files Browse the repository at this point in the history
- task directory deleted
- Add sidekiq dependancy to GemFile
- Change deprecated method *_filter by *_action, it is the equivalent since Rails5.2
- Change css z-index to prevent search menu to pass under backlog menu
- hash attribute to prevent internal error when drag and drop task
- Error Block Message in impediment
  • Loading branch information
Guillaume DUPE committed Nov 5, 2019
1 parent b2424fe commit b454433
Show file tree
Hide file tree
Showing 105 changed files with 89 additions and 18,394 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

gem "sidekiq"
gem 'erubis', '~> 2.7'
gem "holidays", "~>1.0.3"
gem "icalendar"
gem "open-uri-cached"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/rb_all_projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class RbAllProjectsController < ApplicationController
unloadable

before_filter :authorize_global
before_action :authorize_global

def statistics
backlogs_projects = RbCommonHelper.find_backlogs_enabled_active_projects
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/rb_application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class RbApplicationController < ApplicationController
unloadable

before_filter :load_project, :authorize, :check_if_plugin_is_configured
before_action :load_project, :authorize, :check_if_plugin_is_configured

#provide list of javascript_include_tags which must be rendered before common.js
def rb_jquery_plugins
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/rb_calendars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class RbCalendarsController < RbApplicationController

case Backlogs.platform
when :redmine
before_filter :require_admin_or_api_request, :only => :ical
before_action :require_admin_or_api_request, :only => :ical
accept_api_auth :ical
when :chiliproject
accept_key_auth :ical
Expand Down
9 changes: 6 additions & 3 deletions app/controllers/rb_impediments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ class RbImpedimentsController < RbApplicationController
unloadable

def create
@settings = Backlogs.settings
params.permit!
@settings = Backlogs.setting
begin
@impediment = RbTask.create_with_relationships(params, User.current.id, @project.id, true)
rescue => e
render :text => e.message.blank? ? e.to_s : e.message, :status => 400
Rails.logger.error(e.message.blank? ? e.to_s : e.message)
render :partial => "backlogs/model_errors", :object => { "base" => e.message.blank? ? e.to_s : e.message }, :status => 400
return
end

Expand All @@ -22,8 +24,9 @@ def create
end

def update
params.permit!
@impediment = RbTask.find_by_id(params[:id])
@settings = Backlogs.settings
@settings = Backlogs.setting
begin
result = @impediment.update_with_relationships(params)
rescue => e
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/rb_project_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ def project_settings
:tab => 'backlogs'
end

def project_settings_params
params.require(:rb_project_settings).permit(:project_id);
end
end
2 changes: 1 addition & 1 deletion app/controllers/rb_releases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def edit
def update
except = ['id', 'project_id']
attribs = params.select{|k,v| (!except.include? k) and (RbRelease.column_names.include? k) }
attribs = Hash[*attribs.flatten]
attribs = attribs.to_enum.to_h
begin
result = @release.update_attributes attribs
rescue => e
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/rb_server_variables_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class RbServerVariablesController < RbApplicationController

# for index there's no @project
# (eliminates the need of RbAllProjectsController)
skip_before_filter :load_project, :authorize, :only => [:index]
skip_before_action :load_project, :authorize, :only => [:index]

def index
@context = params[:context]
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/rb_sprints_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RbSprintsController < RbApplicationController

def create
attribs = params.select{|k,v| k != 'id' and RbSprint.column_names.include? k }
attribs = Hash[*attribs.flatten]
attribs = attribs.to_enum.to_h
@sprint = RbSprint.new(attribs)

#share the sprint according to the global setting
Expand Down Expand Up @@ -43,7 +43,7 @@ def create
def update
except = ['id', 'project_id']
attribs = params.select{|k,v| (!except.include? k) and (RbSprint.column_names.include? k) }
attribs = Hash[*attribs.flatten]
attribs = attribs.to_enum.to_h
begin
result = @sprint.update_attributes attribs
rescue => e
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/rb_stories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def create
begin
story = RbStory.create_and_position(params)
rescue => e
render :text => e.message.blank? ? e.to_s : e.message, :status => 400
Rails.logger.error(e.message.blank? ? e.to_s : e.message)
render text: e.message.blank? ? e.to_s : e.message, status: 400
return
end

Expand All @@ -48,6 +49,7 @@ def update
begin
result = story.update_and_position!(params)
rescue => e
Rails.logger.error(e.message.blank? ? e.to_s : e.message)
render :text => e.message.blank? ? e.to_s : e.message, :status => 400
return
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/rb_taskboards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def show
stories = @sprint.stories
@story_ids = stories.map{|s| s.id}

@settings = Backlogs.settings
@settings = Backlogs.setting

## determine status columns to show
tracker = Tracker.find_by_id(RbTask.tracker)
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/rb_tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ class RbTasksController < RbApplicationController
unloadable

def create
@settings = Backlogs.settings
params.permit!
@settings = Backlogs.setting
@task = nil
begin
@task = RbTask.create_with_relationships(params, User.current.id, @project.id)
rescue => e
Rails.logger.error(e.to_yaml)
Rails.logger.error(e.backtrace)
render :text => e.message.blank? ? e.to_s : e.message, :status => 400
return
end
Expand All @@ -23,8 +26,9 @@ def create
end

def update
params.permit!
@task = RbTask.find_by_id(params[:id])
@settings = Backlogs.settings
@settings = Backlogs.setting
result = @task.update_with_relationships(params)
status = (result ? 200 : 400)
@include_meta = true
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/rb_partials_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def def_erb_method(method_name_and_args, filename)
define_method "#{method_name}_with_html_safe" do |*args, &block|
send("#{method_name}_without_html_safe", *args, &block).html_safe
end
alias_method_chain method_name, :html_safe
alias_method "#{method_name}_without_html_safe", method_name
alias_method method_name, "#{method_name}_with_html_safe"
method_name
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/rb_issue_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class RbIssueHistory < ActiveRecord::Base
self.table_name = 'rb_issue_history'
attr_protected :created_at # hack, all attributes will be mass asigment
#attr_protected :created_at # hack, all attributes will be mass asigment
belongs_to :issue

serialize :history, Array
Expand Down
4 changes: 2 additions & 2 deletions app/models/rb_journal.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RbJournal < ActiveRecord::Base
unloadable
attr_protected :created_at # hack, all attributes will be mass asigment
#unloadable
#attr_protected :created_at # hack, all attributes will be mass asigment
end
6 changes: 3 additions & 3 deletions app/models/rb_project_settings.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class RbProjectSettings < ActiveRecord::Base
unloadable
attr_protected :created_at # hack, all attributes will be mass asigment
#unloadable
#attr_protected :created_at # hack, all attributes will be mass asigment
belongs_to :project
attr_accessible :project_id
#attr_accessible :project_id
end

4 changes: 2 additions & 2 deletions app/models/rb_release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ class RbRelease < ActiveRecord::Base
has_many :issues, :class_name => 'RbStory', :foreign_key => 'release_id', :dependent => :nullify
has_many :rb_release_burnchart_day_cache, :dependent => :delete_all, :foreign_key => 'release_id'

attr_accessible :project_id, :name, :release_start_date, :release_end_date, :status
attr_accessible :project, :description, :planned_velocity, :sharing
#attr_accessible :project_id, :name, :release_start_date, :release_end_date, :status
#attr_accessible :project, :description, :planned_velocity, :sharing

validates_presence_of :project_id, :name, :release_start_date, :release_end_date
validates_inclusion_of :status, :in => RELEASE_STATUSES
Expand Down
4 changes: 2 additions & 2 deletions app/models/rb_release_burnchart_day_cache.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Release burnchart cache per day per story.
# Table layout optimized for quickly summing up release burncharts.
class RbReleaseBurnchartDayCache < ActiveRecord::Base
unloadable
attr_protected :created_at # hack, all attributes will be mass asigment
#unloadable
#attr_protected :created_at # hack, all attributes will be mass asigment
belongs_to :issue
belongs_to :release

Expand Down
6 changes: 3 additions & 3 deletions app/models/rb_release_multiview.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class RbReleaseMultiview < ActiveRecord::Base
self.table_name = 'rb_releases_multiview'

unloadable
attr_protected :created_at # hack, all attributes will be mass asigment
#unloadable
#attr_protected :created_at # hack, all attributes will be mass asigment

belongs_to :project

attr_accessible :name, :project_id, :release_ids, :project, :description
#attr_accessible :name, :project_id, :release_ids, :project, :description
serialize :release_ids

validates_presence_of :project_id, :name
Expand Down
2 changes: 1 addition & 1 deletion app/models/rb_sprint_burndown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class RbSprintBurndown < ActiveRecord::Base
self.table_name = 'rb_sprint_burndown'
belongs_to :version

attr_accessible :directon, :version_id, :stories, :burndown
#attr_accessible :directon, :version_id, :stories, :burndown

serialize :stories, Array
serialize :burndown, Hash
Expand Down
2 changes: 1 addition & 1 deletion app/models/rb_stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

class RbStats < ActiveRecord::Base
attr_protected :created_at # hack, all attributes will be mass asigment
#attr_protected :created_at # hack, all attributes will be mass asigment
REDMINE_PROPERTIES = ['estimated_hours', 'fixed_version_id', 'status_id', 'story_points', 'remaining_hours']
JOURNALED_PROPERTIES = {
'estimated_hours' => :float,
Expand Down
15 changes: 7 additions & 8 deletions app/models/rb_story.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ def self.create_and_position(params)
attribs = params.select{|k,v| !['prev', 'next', 'id', 'lft', 'rgt'].include?(k) && RbStory.column_names.include?(k) }

attribs[:status] = RbStory.class_default_status
attribs = Hash[*attribs.flatten]
attribs = attribs.to_enum.to_h
s = RbStory.new(attribs)
s.save!
s.save
s.position!(params)

return s
Expand Down Expand Up @@ -263,7 +263,7 @@ def update_and_position!(params)

# lft and rgt fields are handled by acts_as_nested_set
attribs = params.select{|k,v| !['prev', 'id', 'project_id', 'lft', 'rgt'].include?(k) && RbStory.column_names.include?(k) }
attribs = Hash[*attribs.flatten]
attribs = attribs.to_enum.to_h

return self.journalized_update_attributes attribs
end
Expand Down Expand Up @@ -291,11 +291,10 @@ def update_release_burnchart_data(days,release_burndown_id)
end

def save_release_burnchart_data(series,release_burndown_id)
RbReleaseBurnchartDayCache.delete_all(
["issue_id = ? AND release_id = ? AND day IN (?)",
self.id,
release_burndown_id,
series.series(:day)])
RbReleaseBurnchartDayCache.where(["issue_id = ? AND release_id = ? AND day IN (?)",
self.id,
release_burndown_id,
series.series(:day)]).delete_all

series.each{|s|
RbReleaseBurnchartDayCache.create(:issue_id => self.id,
Expand Down
12 changes: 7 additions & 5 deletions app/models/rb_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def self.rb_safe_attributes(params)
attribs = params.select {|k,v| safe_attributes_names.include?(k) }
# lft and rgt fields are handled by acts_as_nested_set
attribs = attribs.select{|k,v| k != 'lft' and k != 'rgt' }
attribs = Hash[*attribs.flatten] if attribs.is_a?(Array)
attribs = attribs.to_enum.to_h if attribs.is_a?(Array)
return attribs
end

Expand All @@ -82,14 +82,16 @@ def self.create_with_relationships(params, user_id, project_id, is_impediment =
end
end

task = new(attribs)
attribs = attribs.to_enum.to_h
task = RbTask.new(attribs)
if params['parent_issue_id']
parent = Issue.find(params['parent_issue_id'])
task.start_date = parent.start_date
end
task.save!

raise "Block list must be comma-separated list of task IDs" if is_impediment && !task.validate_blocks_list(blocks) # could we do that before save and integrate cross-project checks?
return task if is_impediment && !task.validate_blocks_list(blocks) # could we do that before save and integrate cross-project checks?

task.save!

task.move_before params[:next] unless is_impediment # impediments are not hosted under a single parent, so you can't tree-order them
task.update_blocked_list blocks.split(/\D+/) if is_impediment
Expand Down Expand Up @@ -175,7 +177,7 @@ def update_blocked_list(for_blocking)

def validate_blocks_list(list)
if list.split(/\D+/).length==0
errors.add :blocks, :must_have_comma_delimited_list
errors.add :blocks, :must_have_comma_delimited_list.to_s
false
else
true
Expand Down
2 changes: 1 addition & 1 deletion assets/stylesheets/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ a:hover{
position:relative;
width:100%;
box-shadow: 0 3px 4px #A0A0A0;
z-index:1000;
z-index:98;
border-radius: 10px;
}
#toolbar .breadcrumbs{
Expand Down
2 changes: 1 addition & 1 deletion assets/stylesheets/taskboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ See RB.Taskboard.initialize()
margin-bottom:0;
margin-right:10px;
position: absolute;
z-index: 200;
z-index: 100;
}
#board_header td{
background-color:#EEEEEE;
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ en:
error_release_end_after_start: "Release end date has to be after start date"
error_sprint_end_before_start: "Sprint cannot end before it starts"
error_taken: "is already in use"
error_impediment: "Block list must be comma-separated list of task IDs"
event_sprint_summary: "%{project}: %{summary}"
field_assigned_to: "Assigned To"
field_backlogs_issue_type: "Backlog type"
Expand Down
19 changes: 0 additions & 19 deletions features/.autotest

This file was deleted.

0 comments on commit b454433

Please sign in to comment.