Improved name spaces.

This commit is contained in:
Martin Edenhofer 2013-02-01 20:58:53 +01:00
parent 0095f24af7
commit 0dc6e96a5a
7 changed files with 255 additions and 234 deletions

View file

@ -251,6 +251,9 @@ class Package < ApplicationModel
# prebuild assets
# reload new files
Package.reload_classes
# delete package
record = Package.where(
:name => meta[:name],

View file

@ -1,3 +1,5 @@
module Auth
end
module Auth::ENV
def self.check( user, username, password, config )

View file

@ -1,3 +1,5 @@
module Auth
end
module Auth::INTERNAL
def self.check( user, username, password, config )

View file

@ -1,3 +1,5 @@
module Auth
end
module Auth::LDAP
def self.check( user, username, password, config )

View file

@ -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')

View file

@ -1,3 +1,5 @@
module Auth
end
module Auth::TEST
def self.check( user, username, password, config )

View file

@ -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,
@ -417,6 +424,7 @@ module Import::OTRS
)
end
}
end
}
end