Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for compatibility with latest versions of Redmine, Ruby and Rails #3

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/issue_slas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
class IssueSlasController < ApplicationController
unloadable

before_filter :find_project_by_project_id
before_filter :authorize, :only => [:update]
before_action :find_project_by_project_id
before_action :authorize, :only => [:update]

def update
params[:issue_sla].each do |priority_id, allowed_delay|
Expand Down
2 changes: 1 addition & 1 deletion app/models/issue_sla.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class IssueSla < ActiveRecord::Base
validates_presence_of :priority, :project
validates_numericality_of :allowed_delay, :allow_nil => true

attr_protected :priority_id, :project_id
#attr_protected :priority_id, :project_id

before_save :update_issues

Expand Down
14 changes: 14 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Sample plugin
ru:
project_module_redmine_issue_sla: SLA задачи
label_issue_sla: SLA задачи
field_allowed_delay: Допустимая задержка
field_expiration_date: Дата окончания
field_expiration: Окончание
field_issue_sla: SLA
field_update_by_manager_date: Обновлено менеджером
expiration_status_overdue: Просроченный
expiration_status_replied: Среагировано
expiration_status_expires_in_x_time: До просрочки %{value}
expiration_status_x_time_overdue: '%{value} просроченно'
expiration_status_replied_in_x_time: Среагировано %{value}
2 changes: 1 addition & 1 deletion db/migrate/001_create_issue_sla.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateIssueSla < ActiveRecord::Migration
class CreateIssueSla < ActiveRecord::Migration[5.1]
def self.up
create_table :issue_slas, :force => true do |t|
t.integer :project_id, :null => false
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/201210302135_add_issue_sla_unique_index.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddIssueSlaUniqueIndex < ActiveRecord::Migration
class AddIssueSlaUniqueIndex < ActiveRecord::Migration[5.1]
def self.up
add_index :issue_slas, [:project_id, :priority_id], :unique => true
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RenameColumnsAndAddIssueSlaToIssue < ActiveRecord::Migration
class RenameColumnsAndAddIssueSlaToIssue < ActiveRecord::Migration[5.1]
def self.up
add_column :issues, :issue_sla, :float
rename_column :issues, :update_by_manager_date, :first_response_date
Expand Down
4 changes: 2 additions & 2 deletions lib/redmine_issue_sla/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ def save_expiration_date(issue, user = User.current)
sla = issue.priority_issue_sla
if sla && sla.allowed_delay.present?
attrs = { :expiration_date => sla.allowed_delay.hours.from_now.round, :issue_sla => sla.allowed_delay }
issue.assign_attributes attrs, :without_protection => true
issue.assign_attributes attrs #, :without_protection => true
previous_values['expiration_date'] = issue.expiration_date if previous_values
end
end

if user.allowed_to?(:be_project_manager, issue.project) && (issue.new_record? || issue.status_id != previous_values['status_id'])
attrs = { :first_response_date => Time.now.round }
issue.assign_attributes attrs, :without_protection => true
issue.assign_attributes attrs #, :without_protection => true
previous_values['first_response_date'] = issue.first_response_date if previous_values
end
end
Expand Down
19 changes: 16 additions & 3 deletions lib/redmine_issue_sla/infectors/issue_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ def available_filters_with_issue_sla
available_filters_without_issue_sla

if User.current.allowed_to?(:view_issue_sla, project, :global => true)
@available_filters["expiration_date"] = { :name => l("field_expiration_date") , :type => :date, :order => 5.5}
field = "expiration_date"
options = {
type: :date,
order: 5.5,
name: l("field_expiration_date")
}
@available_filters[field] = QueryFilter.new(field, options)
end

@available_filters
Expand Down Expand Up @@ -38,11 +44,18 @@ def self.included(receiver)
receiver.class_eval do
unloadable

alias_method_chain :available_filters, :issue_sla
alias_method_chain :available_columns, :issue_sla
#alias_method_chain :available_filters, :issue_sla
#alias_method_chain :available_columns, :issue_sla
alias_method :available_filters_without_issue_sla, :available_filters
alias_method :available_filters, :available_filters_with_issue_sla

alias_method :available_columns_without_issue_sla, :available_columns
alias_method :available_columns, :available_columns_with_issue_sla
end
end

end
end
end

#Issue.prepend RedmineIssueSla::Infectors::IssueQuery
8 changes: 6 additions & 2 deletions lib/redmine_issue_sla/infectors/projects_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ def self.included(receiver)
receiver.send :include, InstanceMethods
receiver.class_eval do
unloadable
alias_method_chain :project_settings_tabs, :issue_sla
#alias_method_chain :project_settings_tabs, :issue_sla
alias_method :project_settings_tabs_without_issue_sla, :project_settings_tabs
alias_method :project_settings_tabs, :project_settings_tabs_with_issue_sla
alias_method :retrieve_slas, :_retrieve_slas
end
end
end
end
end
end

#ProjectsHelper.prepend RedmineIssueSla::Infectors::ProjectsHelper
12 changes: 8 additions & 4 deletions lib/redmine_issue_sla/infectors/queries_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module ClassMethods; end

module InstanceMethods

def column_value_with_issue_sla(column, issue, value)
def column_value_with_issue_slas(column, issue, value)
if column.name != :expiration_date || value.class.name != 'Time'
return column_value_without_issue_sla(column, issue, value)
return column_value_without_issue_slas(column, issue, value)
end

now = Time.now
Expand Down Expand Up @@ -41,10 +41,14 @@ def self.included(receiver)
receiver.send :include, InstanceMethods
receiver.class_eval do
unloadable
alias_method_chain :column_value, :issue_sla
#alias_method_chain :column_value, :issue_sla
alias_method :column_value_without_issue_slas, :column_value
alias_method :column_value, :column_value_with_issue_slas
alias_method :expiration_in_words, :_expiration_in_words
end
end
end
end
end
end

#QueriesHelper.prepend RedmineIssueSla::Infectors::QueriesHelper