Improved name spaces.
This commit is contained in:
parent
0095f24af7
commit
0dc6e96a5a
7 changed files with 255 additions and 234 deletions
|
@ -251,6 +251,9 @@ class Package < ApplicationModel
|
|||
|
||||
# prebuild assets
|
||||
|
||||
# reload new files
|
||||
Package.reload_classes
|
||||
|
||||
# delete package
|
||||
record = Package.where(
|
||||
:name => meta[:name],
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
module Auth
|
||||
end
|
||||
module Auth::ENV
|
||||
def self.check( user, username, password, config )
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
module Auth
|
||||
end
|
||||
module Auth::INTERNAL
|
||||
def self.check( user, username, password, config )
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
module Auth
|
||||
end
|
||||
module Auth::LDAP
|
||||
def self.check( user, username, password, config )
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class Auth::OTRS
|
||||
module Auth
|
||||
end
|
||||
module Auth::OTRS
|
||||
def self.check( user, username, password, config )
|
||||
|
||||
endpoint = Setting.get('import_otrs_endpoint')
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
module Auth
|
||||
end
|
||||
module Auth::TEST
|
||||
def self.check( user, username, password, config )
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
module Import
|
||||
end
|
||||
module Import::OTRS
|
||||
def self.request(part)
|
||||
url = Setting.get('import_otrs_endpoint') + '/' + part + ';Key=' + Setting.get('import_otrs_endpoint_key')
|
||||
|
@ -85,7 +87,8 @@ module Import::OTRS
|
|||
result = JSON.parse( response.body )
|
||||
result = result.reverse
|
||||
|
||||
thread_count = 8
|
||||
Thread.abort_on_exception = true
|
||||
thread_count = 2
|
||||
threads = {}
|
||||
(1..thread_count).each {|thread|
|
||||
threads[thread] = Thread.new {
|
||||
|
@ -158,6 +161,10 @@ module Import::OTRS
|
|||
}
|
||||
|
||||
result.each {|record|
|
||||
|
||||
# use transaction
|
||||
ActiveRecord::Base.transaction do
|
||||
|
||||
ticket_new = {
|
||||
:title => '',
|
||||
:created_by_id => 1,
|
||||
|
@ -176,7 +183,7 @@ module Import::OTRS
|
|||
#puts 'TICKET OLD ' + ticket_old.inspect
|
||||
# find user
|
||||
if ticket_new[:owner]
|
||||
user = User.where( :login => ticket_new[:owner] ).first
|
||||
user = User.lookup( :login => ticket_new[:owner] )
|
||||
if user
|
||||
ticket_new[:owner_id] = user.id
|
||||
else
|
||||
|
@ -185,7 +192,7 @@ module Import::OTRS
|
|||
ticket_new.delete(:owner)
|
||||
end
|
||||
if ticket_new[:customer]
|
||||
user = User.where( :login => ticket_new[:customer] ).first
|
||||
user = User.lookup( :login => ticket_new[:customer] )
|
||||
if user
|
||||
ticket_new[:customer_id] = user.id
|
||||
else
|
||||
|
@ -242,7 +249,7 @@ module Import::OTRS
|
|||
# do extra decoding because we needed to use field.value
|
||||
display_name = Mail::Field.new( 'X-From', display_name ).to_s
|
||||
|
||||
roles = Role.where( :name => 'Customer' )
|
||||
roles = Role.lookup( :name => 'Customer' )
|
||||
user = User.create(
|
||||
:login => email,
|
||||
:firstname => display_name,
|
||||
|
@ -294,11 +301,11 @@ module Import::OTRS
|
|||
end
|
||||
article_new.delete( :ticket_article_type )
|
||||
article_old = Ticket::Article.where( :id => article_new[:id] ).first
|
||||
#puts 'ARTICLE OLD ' + article_old.inspect
|
||||
#puts 'ARTICLE OLD ' + article_old.inspect
|
||||
# set state types
|
||||
if article_old
|
||||
puts "update Ticket::Article.find(#{article_new[:id]})"
|
||||
# puts article_new.inspect
|
||||
# puts article_new.inspect
|
||||
article_old.update_attributes(article_new)
|
||||
else
|
||||
puts "add Ticket::Article.find(#{article_new[:id]})"
|
||||
|
@ -310,8 +317,8 @@ module Import::OTRS
|
|||
}
|
||||
|
||||
record['History'].each { |history|
|
||||
# puts '-------'
|
||||
# puts history.inspect
|
||||
# puts '-------'
|
||||
# puts history.inspect
|
||||
if history['HistoryType'] == 'NewTicket'
|
||||
History.history_create(
|
||||
:id => history['HistoryID'],
|
||||
|
@ -339,7 +346,7 @@ module Import::OTRS
|
|||
to_id = state_to.id
|
||||
end
|
||||
end
|
||||
# puts "STATE UPDATE (#{history['HistoryID']}): -> #{from}->#{to}"
|
||||
# puts "STATE UPDATE (#{history['HistoryID']}): -> #{from}->#{to}"
|
||||
History.history_create(
|
||||
:id => history['HistoryID'],
|
||||
:o_id => history['TicketID'],
|
||||
|
@ -417,6 +424,7 @@ module Import::OTRS
|
|||
)
|
||||
end
|
||||
}
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue