mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-02-14 01:23:59 -05:00
Implement issue creation error handling; add project validation and refactored issue hooks
This commit is contained in:
@@ -24,29 +24,9 @@ module RedmineQbo
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
helper Helper
|
||||
before_action :error_check, only: [:create]
|
||||
end
|
||||
end
|
||||
|
||||
# Check for errors when creating an issue.
|
||||
# If the project or tracker is not set, reload the new issue form with an error message.
|
||||
def error_check
|
||||
logger.info "Creating issue for: #{@issue.project}"
|
||||
|
||||
if @issue.project.nil?
|
||||
@issue.project = Project.first
|
||||
flash[:error] = t :notice_error_project_nil
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
if @issue.tracker.nil?
|
||||
@issue.tracker = Tracker.first
|
||||
flash[:error] = t :notice_error_tracker_nil
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Add module to IssuessController
|
||||
IssuesController.send(:include, IssuesControllerPatch)
|
||||
|
||||
Reference in New Issue
Block a user