Finished updating method
The plugin is not fully fuctional
This commit is contained in:
@@ -27,13 +27,7 @@ class ExceptionhandlerController < ApplicationController
|
|||||||
helper :exceptionhandler
|
helper :exceptionhandler
|
||||||
include ExceptionhandlerHelper
|
include ExceptionhandlerHelper
|
||||||
|
|
||||||
require 'logger'
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
log = Logger.new('redmine-exceptionhandler-plugin.txt')
|
|
||||||
log.level = Logger::DEBUG
|
|
||||||
log.debug "Loading Index"
|
|
||||||
|
|
||||||
if params.size < 8
|
if params.size < 8
|
||||||
@output = "<strong> not enough args </strong>"
|
@output = "<strong> not enough args </strong>"
|
||||||
elsif Project.find_by_name(params[:app]) == nil
|
elsif Project.find_by_name(params[:app]) == nil
|
||||||
@@ -41,14 +35,13 @@ class ExceptionhandlerController < ApplicationController
|
|||||||
else
|
else
|
||||||
issue_id = check_for_existing_report
|
issue_id = check_for_existing_report
|
||||||
if issue_id > 0
|
if issue_id > 0
|
||||||
# TODO update report
|
update_report(issue_id)
|
||||||
@output = issue_id
|
@output = "Updated report"
|
||||||
else
|
else
|
||||||
#TODO create new report and save
|
|
||||||
issue = create_new_report
|
issue = create_new_report
|
||||||
if issue.valid?
|
if issue.valid?
|
||||||
issue.save
|
issue.save
|
||||||
@output = "Report filed, Thank You."
|
@output = "New report filed"
|
||||||
else
|
else
|
||||||
@output = issue.errors.full_messages
|
@output = issue.errors.full_messages
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ module ExceptionhandlerHelper
|
|||||||
issue.project = Project.find_by_name(params[:app])
|
issue.project = Project.find_by_name(params[:app])
|
||||||
issue.start_date = Time.now.localtime.strftime("%Y-%m-%d %T")
|
issue.start_date = Time.now.localtime.strftime("%Y-%m-%d %T")
|
||||||
issue.priority = IssuePriority.find_by_name("Normal")
|
issue.priority = IssuePriority.find_by_name("Normal")
|
||||||
issue.author = User.find_by_mail("rickbarrette@gmail.com")
|
issue.author = User.anonymous
|
||||||
issue.status = IssueStatus.find_by_name("New")
|
issue.status = IssueStatus.find_by_name("New")
|
||||||
|
|
||||||
issue.custom_values = [
|
issue.custom_values = [
|
||||||
@@ -110,4 +110,33 @@ module ExceptionhandlerHelper
|
|||||||
return custom_value
|
return custom_value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# retrives an issue by it's id and updates it
|
||||||
|
# @returns updated issue
|
||||||
|
def update_report(issue_id)
|
||||||
|
issue = Issue.find_by_id(issue_id)
|
||||||
|
if params[:description].length > 0
|
||||||
|
description = issue.description
|
||||||
|
description += "\n\n--- New Description --- \n"
|
||||||
|
description += params[:description]
|
||||||
|
issue.description = description
|
||||||
|
end
|
||||||
|
|
||||||
|
custom_fields = CustomField
|
||||||
|
issue.custom_field_values.each do |value|
|
||||||
|
case custom_fields.find_by_id(value.custom_field_id).name
|
||||||
|
when "Device"
|
||||||
|
value.value = value.value += "\n"
|
||||||
|
value.value = value.value += params[:device]
|
||||||
|
when "Date"
|
||||||
|
value.value = value.value += "\n"
|
||||||
|
value.value = value.value += params[:date]
|
||||||
|
when "Count"
|
||||||
|
value.value = (value.value.to_i + 1).to_s
|
||||||
|
end
|
||||||
|
value.save
|
||||||
|
end
|
||||||
|
issue.init_journal(User.anonymous, "Issue updated")
|
||||||
|
issue.save
|
||||||
|
end
|
||||||
|
|
||||||
end #EOF
|
end #EOF
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
<h1>Exception Handler</h1>
|
<h1>Exception Handler</h1>
|
||||||
<%= @output %>
|
<%= @output %>
|
||||||
<%= Rails.logger.info %>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user