-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance compatibility with Redmine 5
- Loading branch information
Showing
7 changed files
with
45 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
require_dependency 'issue' | ||
|
||
class Issue < ActiveRecord::Base | ||
|
||
has_many :drafts, :as => :element | ||
|
||
after_create :clean_drafts_after_create | ||
after_update :clean_drafts_after_update | ||
|
||
module RedmineDrafts::IssuePatch | ||
def clean_drafts_after_create | ||
draft = Draft.find_for_issue(:element_id => 0, :user_id => User.current.id) | ||
draft.destroy if draft | ||
end | ||
|
||
def clean_drafts_after_update | ||
self.drafts.select{|d| d.user_id == User.current.id}.each(&:destroy) | ||
self.drafts.select { |d| d.user_id == User.current.id }.each(&:destroy) | ||
end | ||
end | ||
|
||
class Issue < ActiveRecord::Base | ||
|
||
include RedmineDrafts::IssuePatch | ||
|
||
has_many :drafts, :as => :element | ||
|
||
after_create :clean_drafts_after_create | ||
after_update :clean_drafts_after_update | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
require_dependency 'issues_controller' | ||
|
||
class IssuesController | ||
prepend_before_action :set_draft | ||
|
||
private | ||
module RedmineDrafts::IssuesControllerPatch | ||
def set_draft | ||
if params[:draft_id] | ||
if params[:draft_id].present? | ||
draft = Draft.find(params[:draft_id]) rescue nil | ||
if draft | ||
if draft.present? | ||
params.merge!(draft.content.permit!) | ||
end | ||
end | ||
true | ||
end | ||
end | ||
|
||
class IssuesController | ||
|
||
include RedmineDrafts::IssuesControllerPatch | ||
|
||
prepend_before_action :set_draft, :only => [:new, :edit] | ||
|
||
end | ||
|