Corrected with rubocop cop 'Style/IndentationWidth'.
This commit is contained in:
parent
8c2ea52b3c
commit
19feb32c7b
7 changed files with 90 additions and 97 deletions
2
Gemfile
2
Gemfile
|
@ -62,7 +62,7 @@ gem 'em-websocket'
|
||||||
# in production environments by default.
|
# in production environments by default.
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
|
|
||||||
gem 'test-unit'
|
gem 'test-unit'
|
||||||
gem 'spring'
|
gem 'spring'
|
||||||
gem 'sqlite3'
|
gem 'sqlite3'
|
||||||
|
|
||||||
|
|
|
@ -105,13 +105,13 @@ curl http://localhost/api/v1/online_notifications/mark_all_as_read -v -u #{login
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def mark_all_as_read
|
def mark_all_as_read
|
||||||
notifications = OnlineNotification.list(current_user, 100)
|
notifications = OnlineNotification.list(current_user, 100)
|
||||||
notifications.each do |notification|
|
notifications.each do |notification|
|
||||||
if !notification['seen']
|
if !notification['seen']
|
||||||
OnlineNotification.seen( id: notification['id'] )
|
OnlineNotification.seen( id: notification['id'] )
|
||||||
end
|
|
||||||
end
|
end
|
||||||
render json: {}, status: :ok
|
end
|
||||||
|
render json: {}, status: :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,7 +56,7 @@ mark online notification as seen
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.seen(data)
|
def self.seen(data)
|
||||||
notification = OnlineNotification.find(data[:id])
|
notification = OnlineNotification.find(data[:id])
|
||||||
notification.seen = true
|
notification.seen = true
|
||||||
notification.save
|
notification.save
|
||||||
end
|
end
|
||||||
|
@ -139,17 +139,17 @@ mark online notification as seen by object
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.seen_by_object(object_name, o_id)
|
def self.seen_by_object(object_name, o_id)
|
||||||
object_id = ObjectLookup.by_name( object_name )
|
object_id = ObjectLookup.by_name( object_name )
|
||||||
notifications = OnlineNotification.where(
|
notifications = OnlineNotification.where(
|
||||||
object_lookup_id: object_id,
|
object_lookup_id: object_id,
|
||||||
o_id: o_id,
|
o_id: o_id,
|
||||||
seen: false,
|
seen: false,
|
||||||
)
|
)
|
||||||
notifications.each do |notification|
|
notifications.each do |notification|
|
||||||
notification.seen = true
|
notification.seen = true
|
||||||
notification.save
|
notification.save
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
|
@ -117,7 +117,7 @@ module Import::OTRS
|
||||||
|
|
||||||
# check if system is in import mode
|
# check if system is in import mode
|
||||||
if !Setting.get('import_mode')
|
if !Setting.get('import_mode')
|
||||||
raise 'System is not in import mode!'
|
raise 'System is not in import mode!'
|
||||||
end
|
end
|
||||||
|
|
||||||
response = request('public.pl?Action=Export')
|
response = request('public.pl?Action=Export')
|
||||||
|
@ -181,7 +181,7 @@ module Import::OTRS
|
||||||
|
|
||||||
# check if system is in import mode
|
# check if system is in import mode
|
||||||
if !Setting.get('import_mode')
|
if !Setting.get('import_mode')
|
||||||
raise 'System is not in import mode!'
|
raise 'System is not in import mode!'
|
||||||
end
|
end
|
||||||
|
|
||||||
# create states
|
# create states
|
||||||
|
@ -702,48 +702,44 @@ module Import::OTRS
|
||||||
UserEmail: :email,
|
UserEmail: :email,
|
||||||
UserFirstname: :firstname,
|
UserFirstname: :firstname,
|
||||||
UserLastname: :lastname,
|
UserLastname: :lastname,
|
||||||
# :UserTitle =>
|
|
||||||
UserLogin: :login,
|
UserLogin: :login,
|
||||||
UserPw: :password,
|
UserPw: :password,
|
||||||
};
|
};
|
||||||
|
|
||||||
result.each { |user|
|
result.each { |user|
|
||||||
# puts 'USER: ' + user.inspect
|
# puts 'USER: ' + user.inspect
|
||||||
_set_valid(user)
|
_set_valid(user)
|
||||||
|
|
||||||
role = Role.lookup( name: 'Agent' )
|
role = Role.lookup( name: 'Agent' )
|
||||||
# get new attributes
|
# get new attributes
|
||||||
user_new = {
|
user_new = {
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
source: 'OTRS Import',
|
source: 'OTRS Import',
|
||||||
role_ids: [ role.id ],
|
role_ids: [ role.id ],
|
||||||
}
|
}
|
||||||
map.each { |key, value|
|
map.each { |key, value|
|
||||||
if user[key.to_s]
|
if user[key.to_s]
|
||||||
user_new[value] = user[key.to_s]
|
user_new[value] = user[key.to_s]
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
# check if state already exists
|
# check if state already exists
|
||||||
# user_old = User.where( :login => user_new[:login] ).first
|
user_old = User.where( id: user_new[:id] ).first
|
||||||
user_old = User.where( id: user_new[:id] ).first
|
|
||||||
|
|
||||||
# set state types
|
# set state types
|
||||||
if user_old
|
if user_old
|
||||||
puts "update User.find(#{user_new[:id]})"
|
puts "update User.find(#{user_new[:id]})"
|
||||||
# puts 'Update User' + user_new.inspect
|
# puts 'Update User' + user_new.inspect
|
||||||
user_new.delete( :role_ids )
|
user_new.delete( :role_ids )
|
||||||
user_old.update_attributes(user_new)
|
user_old.update_attributes(user_new)
|
||||||
else
|
else
|
||||||
puts "add User.find(#{user_new[:id]})"
|
puts "add User.find(#{user_new[:id]})"
|
||||||
# puts 'Add User' + user_new.inspect
|
# puts 'Add User' + user_new.inspect
|
||||||
user = User.new(user_new)
|
user = User.new(user_new)
|
||||||
user.id = user_new[:id]
|
user.id = user_new[:id]
|
||||||
user.save
|
user.save
|
||||||
end
|
end
|
||||||
|
|
||||||
# end
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
def self.customer
|
def self.customer
|
||||||
|
@ -767,7 +763,6 @@ module Import::OTRS
|
||||||
UserEmail: :email,
|
UserEmail: :email,
|
||||||
UserFirstname: :firstname,
|
UserFirstname: :firstname,
|
||||||
UserLastname: :lastname,
|
UserLastname: :lastname,
|
||||||
# :UserTitle =>
|
|
||||||
UserLogin: :login,
|
UserLogin: :login,
|
||||||
UserPassword: :password,
|
UserPassword: :password,
|
||||||
UserPhone: :phone,
|
UserPhone: :phone,
|
||||||
|
@ -800,7 +795,7 @@ module Import::OTRS
|
||||||
}
|
}
|
||||||
|
|
||||||
# check if state already exists
|
# check if state already exists
|
||||||
# user_old = User.where( :login => user_new[:login] ).first
|
# user_old = User.where( :login => user_new[:login] ).first
|
||||||
user_old = User.where( login: user_new[:login] ).first
|
user_old = User.where( login: user_new[:login] ).first
|
||||||
|
|
||||||
# set state types
|
# set state types
|
||||||
|
@ -819,17 +814,17 @@ module Import::OTRS
|
||||||
end
|
end
|
||||||
def self._set_valid(record)
|
def self._set_valid(record)
|
||||||
# map
|
# map
|
||||||
if record['ValidID'] == '3'
|
if record['ValidID'] == '3'
|
||||||
record['ValidID'] = '2'
|
record['ValidID'] = '2'
|
||||||
end
|
end
|
||||||
if record['ValidID'] == '2'
|
if record['ValidID'] == '2'
|
||||||
record['ValidID'] = false
|
record['ValidID'] = false
|
||||||
end
|
end
|
||||||
if record['ValidID'] == '1'
|
if record['ValidID'] == '1'
|
||||||
record['ValidID'] = true
|
record['ValidID'] = true
|
||||||
end
|
end
|
||||||
if record['ValidID'] == '0'
|
if record['ValidID'] == '0'
|
||||||
record['ValidID'] = false
|
record['ValidID'] = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -346,14 +346,14 @@ module Import::OTRS2
|
||||||
steps = 30
|
steps = 30
|
||||||
run = true
|
run = true
|
||||||
while run
|
while run
|
||||||
count += steps
|
count += steps
|
||||||
records = load('CustomerUser', steps, count - steps)
|
records = load('CustomerUser', steps, count - steps)
|
||||||
if !records || !records[0]
|
if !records || !records[0]
|
||||||
log 'all customers imported.'
|
log 'all customers imported.'
|
||||||
run = false
|
run = false
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
customer(records, organizations)
|
customer(records, organizations)
|
||||||
end
|
end
|
||||||
|
|
||||||
Thread.abort_on_exception = true
|
Thread.abort_on_exception = true
|
||||||
|
@ -944,7 +944,6 @@ module Import::OTRS2
|
||||||
UserEmail: :email,
|
UserEmail: :email,
|
||||||
UserFirstname: :firstname,
|
UserFirstname: :firstname,
|
||||||
UserLastname: :lastname,
|
UserLastname: :lastname,
|
||||||
# :UserTitle =>
|
|
||||||
UserLogin: :login,
|
UserLogin: :login,
|
||||||
UserPw: :password,
|
UserPw: :password,
|
||||||
};
|
};
|
||||||
|
@ -1065,7 +1064,6 @@ module Import::OTRS2
|
||||||
UserEmail: :email,
|
UserEmail: :email,
|
||||||
UserFirstname: :firstname,
|
UserFirstname: :firstname,
|
||||||
UserLastname: :lastname,
|
UserLastname: :lastname,
|
||||||
# :UserTitle =>
|
|
||||||
UserLogin: :login,
|
UserLogin: :login,
|
||||||
UserPassword: :password,
|
UserPassword: :password,
|
||||||
UserPhone: :phone,
|
UserPhone: :phone,
|
||||||
|
@ -1236,20 +1234,20 @@ module Import::OTRS2
|
||||||
|
|
||||||
def self._set_valid(record)
|
def self._set_valid(record)
|
||||||
|
|
||||||
# map
|
# map
|
||||||
if record['ValidID'].to_s == '3'
|
if record['ValidID'].to_s == '3'
|
||||||
record['ValidID'] = false
|
record['ValidID'] = false
|
||||||
elsif record['ValidID'].to_s == '2'
|
elsif record['ValidID'].to_s == '2'
|
||||||
record['ValidID'] = false
|
record['ValidID'] = false
|
||||||
elsif record['ValidID'].to_s == '1'
|
elsif record['ValidID'].to_s == '1'
|
||||||
record['ValidID'] = true
|
record['ValidID'] = true
|
||||||
elsif record['ValidID'].to_s == '0'
|
elsif record['ValidID'].to_s == '0'
|
||||||
record['ValidID'] = false
|
record['ValidID'] = false
|
||||||
|
|
||||||
# fallback
|
# fallback
|
||||||
else
|
else
|
||||||
record['ValidID'] = true
|
record['ValidID'] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# cleanup invalid values
|
# cleanup invalid values
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Sessions::Backend::ActivityStream
|
||||||
|
|
||||||
# update last changed
|
# update last changed
|
||||||
if activity_stream && activity_stream.first
|
if activity_stream && activity_stream.first
|
||||||
@last_change = activity_stream.first['created_at']
|
@last_change = activity_stream.first['created_at']
|
||||||
end
|
end
|
||||||
|
|
||||||
@user.activity_stream( 25, true )
|
@user.activity_stream( 25, true )
|
||||||
|
|
|
@ -22,11 +22,11 @@ put working hours matrix and timezone in function, returns UTC working hours mat
|
||||||
time_diff = 0
|
time_diff = 0
|
||||||
if timezone
|
if timezone
|
||||||
begin
|
begin
|
||||||
time_diff = Time.parse(start_time.to_s).in_time_zone(timezone).utc_offset
|
time_diff = Time.parse(start_time.to_s).in_time_zone(timezone).utc_offset
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
puts "ERROR: Can't fine tomezone #{timezone}"
|
puts "ERROR: Can't fine tomezone #{timezone}"
|
||||||
puts e.inspect
|
puts e.inspect
|
||||||
puts e.backtrace
|
puts e.backtrace
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
beginning_of_workday = Time.parse("1977-10-27 #{config['beginning_of_workday']}")
|
beginning_of_workday = Time.parse("1977-10-27 #{config['beginning_of_workday']}")
|
||||||
|
@ -169,7 +169,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat
|
||||||
diff = end_time - start_time
|
diff = end_time - start_time
|
||||||
|
|
||||||
if diff > 59 * 60
|
if diff > 59 * 60
|
||||||
diff = start_time - start_time.beginning_of_hour
|
diff = start_time - start_time.beginning_of_hour
|
||||||
end
|
end
|
||||||
start_time += diff
|
start_time += diff
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue