mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-11-19 10:40:36 -05:00
Implement issue creation error handling; add project validation and refactored issue hooks
This commit is contained in:
1 parent
7a73b7e8a9
commit
548dc4fba8
4 files changed
+42
-71
No files matched your search
@@ -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