mirror of
https://github.com/anteo/redmine_custom_workflows.git
synced 2026-01-26 00:04:20 +00:00
More robust XML import
This commit is contained in:
parent
325585e434
commit
e70642cd66
@ -53,10 +53,18 @@ class CustomWorkflow < ApplicationRecord
|
|||||||
|
|
||||||
def self.import_from_xml(xml)
|
def self.import_from_xml(xml)
|
||||||
attributes = Hash.from_xml(xml).values.first
|
attributes = Hash.from_xml(xml).values.first
|
||||||
|
attributes.delete 'id'
|
||||||
attributes.delete 'exported_at'
|
attributes.delete 'exported_at'
|
||||||
attributes.delete 'plugin_version'
|
attributes.delete 'plugin_version'
|
||||||
attributes.delete 'ruby_version'
|
attributes.delete 'ruby_version'
|
||||||
attributes.delete 'rails_version'
|
attributes.delete 'rails_version'
|
||||||
|
name = attributes['name']
|
||||||
|
i = 1
|
||||||
|
while CustomWorkflow.exists?(name: name)
|
||||||
|
name = "#{attributes['name']}_#{i}"
|
||||||
|
i += 1
|
||||||
|
end
|
||||||
|
attributes['name'] = name
|
||||||
CustomWorkflow.new attributes
|
CustomWorkflow.new attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user