Small code improvements.
This commit is contained in:
parent
1f266e3110
commit
6ea8e8e9ea
4 changed files with 34 additions and 14 deletions
|
@ -23,7 +23,8 @@ class App.Run extends App.Controller
|
|||
new App.Content( el: @el.find('#content') )
|
||||
|
||||
# start chat
|
||||
new App.ChatWidget( el: @el.find('#chat') )
|
||||
if App.ChatWidget
|
||||
new App.ChatWidget( el: @el.find('#chat') )
|
||||
|
||||
# bind to fill selected text into
|
||||
App.ClipBoard.bind( @el )
|
||||
|
|
|
@ -4,7 +4,7 @@ class User < ApplicationModel
|
|||
include Gmaps
|
||||
|
||||
before_create :check_name, :check_email, :check_login, :check_image, :check_geo, :check_password
|
||||
before_update :check_password, :check_image, :check_geo, :check_email, :check_login
|
||||
before_update :check_password, :check_image, :check_geo, :check_email, :check_login_update
|
||||
|
||||
has_and_belongs_to_many :groups, :after_add => :cache_update, :after_remove => :cache_update
|
||||
has_and_belongs_to_many :roles, :after_add => :cache_update, :after_remove => :cache_update
|
||||
|
@ -449,6 +449,22 @@ Your #{config.product_name} Team
|
|||
end
|
||||
|
||||
def check_login
|
||||
if self.login
|
||||
self.login = self.login.downcase
|
||||
check = true
|
||||
while check
|
||||
exists = User.where( :login => self.login ).first
|
||||
if exists
|
||||
self.login = self.login + rand(99).to_s
|
||||
else
|
||||
check = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# FIXME: Remove me later
|
||||
def check_login_update
|
||||
if self.login
|
||||
self.login = self.login.downcase
|
||||
end
|
||||
|
|
|
@ -122,6 +122,13 @@ module Import::OTRS
|
|||
return
|
||||
end
|
||||
|
||||
def self.diff_loop
|
||||
while true
|
||||
self.diff
|
||||
sleep 30
|
||||
end
|
||||
end
|
||||
|
||||
def self.diff
|
||||
puts 'Start diff...'
|
||||
|
||||
|
|
|
@ -82,16 +82,12 @@ module Session
|
|||
def self.send( client_id, data )
|
||||
path = @path + '/' + client_id.to_s + '/'
|
||||
filename = 'send-' + Time.new().to_i.to_s + '-' + rand(99999999).to_s
|
||||
if File::exists?( path + filename )
|
||||
filename = filename + '-1'
|
||||
check = true
|
||||
while check
|
||||
if File::exists?( path + filename )
|
||||
filename = filename + '-1'
|
||||
if File::exists?( path + filename )
|
||||
filename = filename + '-1'
|
||||
if File::exists?( path + filename )
|
||||
filename = filename + '-' + rand(99999999).to_s
|
||||
end
|
||||
end
|
||||
filename = filename + '-' + rand(99999).to_s
|
||||
else
|
||||
check = false
|
||||
end
|
||||
end
|
||||
return false if !File.directory? path
|
||||
|
@ -101,8 +97,8 @@ module Session
|
|||
file.flock( File::LOCK_UN )
|
||||
file.close
|
||||
}
|
||||
|
||||
FileUtils.mv( path + 'a-' + filename, path + filename)
|
||||
# return false if !File.exists?( path + 'a-' + filename )
|
||||
FileUtils.mv( path + 'a-' + filename, path + filename )
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue