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
|
# prebuild assets
|
||||||
|
|
||||||
|
# reload new files
|
||||||
|
Package.reload_classes
|
||||||
|
|
||||||
# delete package
|
# delete package
|
||||||
record = Package.where(
|
record = Package.where(
|
||||||
:name => meta[:name],
|
:name => meta[:name],
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
module Auth
|
||||||
|
end
|
||||||
module Auth::ENV
|
module Auth::ENV
|
||||||
def self.check( user, username, password, config )
|
def self.check( user, username, password, config )
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
module Auth
|
||||||
|
end
|
||||||
module Auth::INTERNAL
|
module Auth::INTERNAL
|
||||||
def self.check( user, username, password, config )
|
def self.check( user, username, password, config )
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
module Auth
|
||||||
|
end
|
||||||
module Auth::LDAP
|
module Auth::LDAP
|
||||||
def self.check( user, username, password, config )
|
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 )
|
def self.check( user, username, password, config )
|
||||||
|
|
||||||
endpoint = Setting.get('import_otrs_endpoint')
|
endpoint = Setting.get('import_otrs_endpoint')
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
module Auth
|
||||||
|
end
|
||||||
module Auth::TEST
|
module Auth::TEST
|
||||||
def self.check( user, username, password, config )
|
def self.check( user, username, password, config )
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
module Import
|
||||||
|
end
|
||||||
module Import::OTRS
|
module Import::OTRS
|
||||||
def self.request(part)
|
def self.request(part)
|
||||||
url = Setting.get('import_otrs_endpoint') + '/' + part + ';Key=' + Setting.get('import_otrs_endpoint_key')
|
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 = JSON.parse( response.body )
|
||||||
result = result.reverse
|
result = result.reverse
|
||||||
|
|
||||||
thread_count = 8
|
Thread.abort_on_exception = true
|
||||||
|
thread_count = 2
|
||||||
threads = {}
|
threads = {}
|
||||||
(1..thread_count).each {|thread|
|
(1..thread_count).each {|thread|
|
||||||
threads[thread] = Thread.new {
|
threads[thread] = Thread.new {
|
||||||
|
@ -158,6 +161,10 @@ module Import::OTRS
|
||||||
}
|
}
|
||||||
|
|
||||||
result.each {|record|
|
result.each {|record|
|
||||||
|
|
||||||
|
# use transaction
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
|
||||||
ticket_new = {
|
ticket_new = {
|
||||||
:title => '',
|
:title => '',
|
||||||
:created_by_id => 1,
|
:created_by_id => 1,
|
||||||
|
@ -176,7 +183,7 @@ module Import::OTRS
|
||||||
#puts 'TICKET OLD ' + ticket_old.inspect
|
#puts 'TICKET OLD ' + ticket_old.inspect
|
||||||
# find user
|
# find user
|
||||||
if ticket_new[:owner]
|
if ticket_new[:owner]
|
||||||
user = User.where( :login => ticket_new[:owner] ).first
|
user = User.lookup( :login => ticket_new[:owner] )
|
||||||
if user
|
if user
|
||||||
ticket_new[:owner_id] = user.id
|
ticket_new[:owner_id] = user.id
|
||||||
else
|
else
|
||||||
|
@ -185,7 +192,7 @@ module Import::OTRS
|
||||||
ticket_new.delete(:owner)
|
ticket_new.delete(:owner)
|
||||||
end
|
end
|
||||||
if ticket_new[:customer]
|
if ticket_new[:customer]
|
||||||
user = User.where( :login => ticket_new[:customer] ).first
|
user = User.lookup( :login => ticket_new[:customer] )
|
||||||
if user
|
if user
|
||||||
ticket_new[:customer_id] = user.id
|
ticket_new[:customer_id] = user.id
|
||||||
else
|
else
|
||||||
|
@ -242,7 +249,7 @@ module Import::OTRS
|
||||||
# do extra decoding because we needed to use field.value
|
# do extra decoding because we needed to use field.value
|
||||||
display_name = Mail::Field.new( 'X-From', display_name ).to_s
|
display_name = Mail::Field.new( 'X-From', display_name ).to_s
|
||||||
|
|
||||||
roles = Role.where( :name => 'Customer' )
|
roles = Role.lookup( :name => 'Customer' )
|
||||||
user = User.create(
|
user = User.create(
|
||||||
:login => email,
|
:login => email,
|
||||||
:firstname => display_name,
|
:firstname => display_name,
|
||||||
|
@ -417,6 +424,7 @@ module Import::OTRS
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue