summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-05 23:10:07 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-05 23:10:07 +0100
commit3862734b5e0833ed108300102c68159e40ffd93a (patch)
tree4491044dbf48aea515303382e7664cf9be2cb182 /lib
parent380a4cdfe5cfa573fb916ca7c2145a6062ef8198 (diff)
parent57196d838691aeba38ad7e088e83c0881a213861 (diff)
Merge branch 'replace_constants' into develop
Diffstat (limited to 'lib')
-rw-r--r--lib/activerecord_extensions.rb6
-rw-r--r--lib/tasks/cvs_user_import.rake26
-rw-r--r--lib/tasks/fax.rake2
-rw-r--r--lib/tasks/gs_cluster.rake8
-rw-r--r--lib/tasks/send_fax_notifications.rake2
5 files changed, 22 insertions, 22 deletions
diff --git a/lib/activerecord_extensions.rb b/lib/activerecord_extensions.rb
index 50c44be..102ddd8 100644
--- a/lib/activerecord_extensions.rb
+++ b/lib/activerecord_extensions.rb
@@ -16,7 +16,7 @@ class ActiveRecord::Base
#
def populate_gs_node_id
if self.attribute_names.include?('gs_node_id') && self.gs_node_id.blank?
- self.gs_node_id = GsNode.where(:ip_address => HOMEBASE_IP_ADDRESS).first.try(:id)
+ self.gs_node_id = GsNode.where(:ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS')).first.try(:id)
end
end
@@ -47,7 +47,7 @@ class ActiveRecord::Base
logger.error "Couldn't #{action} #{self.class} with the ID #{self.id} on other GsNodes because #{self.class} doesn't have a is_native attribute."
else
if self.is_native != false
- if defined? WRITE_GS_CLUSTER_SYNC_LOG && WRITE_GS_CLUSTER_SYNC_LOG == true
+ if defined? GsParameter.get('WRITE_GS_CLUSTER_SYNC_LOG') && GsParameter.get('WRITE_GS_CLUSTER_SYNC_LOG') == true
if !(defined? $gs_cluster_loop_protection) || $gs_cluster_loop_protection != true
begin
GsClusterSyncLogEntry.create(
@@ -55,7 +55,7 @@ class ActiveRecord::Base
:action => action,
:content => content,
:history => history,
- :homebase_ip_address => HOMEBASE_IP_ADDRESS,
+ :homebase_ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS'),
:waiting_to_be_synced => true,
:association_method => association_method,
:association_uuid => association_uuid
diff --git a/lib/tasks/cvs_user_import.rake b/lib/tasks/cvs_user_import.rake
index 2475a43..81959d5 100644
--- a/lib/tasks/cvs_user_import.rake
+++ b/lib/tasks/cvs_user_import.rake
@@ -24,14 +24,14 @@ namespace :user_import do
# Read the CSV data and store them in the new_users hash.
#
- csv_data = CSV.read(IMPORT_CSV_FILE, encoding: IMPORT_CSV_ENCODING)
+ csv_data = CSV.read(GsParameter.get('IMPORT_CSV_FILE'), encoding: GsParameter.get('IMPORT_CSV_ENCODING'))
headers = csv_data.shift.map {|i| i.to_s }
string_data = csv_data.map {|row| row.map {|cell| cell.to_s } }
new_users = string_data.map {|row| Hash[*headers.zip(row).flatten] }
- gs_node_id = GsNode.where(:ip_address => HOMEBASE_IP_ADDRESS).first.try(:id)
+ gs_node_id = GsNode.where(:ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS')).first.try(:id)
- if File.exists?(DOUBLE_CHECK_POSITIVE_USERS_CSV)
- csv_data = CSV.read(DOUBLE_CHECK_POSITIVE_USERS_CSV, encoding: IMPORT_CSV_ENCODING)
+ if File.exists?(GsParameter.get('DOUBLE_CHECK_POSITIVE_USERS_CSV'))
+ csv_data = CSV.read(GsParameter.get('DOUBLE_CHECK_POSITIVE_USERS_CSV'), encoding: GsParameter.get('IMPORT_CSV_ENCODING'))
if csv_data.blank?
double_checked_user_names = []
else
@@ -45,13 +45,13 @@ namespace :user_import do
double_checked_user_names = new_users.map{|user| user['UserName']}
end
- tenant = Tenant.find(DEFAULT_API_TENANT_ID)
+ tenant = Tenant.find(GsParameter.get('DEFAULT_API_TENANT_ID'))
# Destroy deleted user by making a diff of where(:importer_checksum)
# and users in the CSV file.
#
- if defined?(USER_NAME_PREFIX) && !USER_NAME_PREFIX.blank?
- new_users_user_names = new_users.map{|x| USER_NAME_PREFIX.to_s + x['UserName'].to_s}
+ if defined?(GsParameter.get('USER_NAME_PREFIX')) && !GsParameter.get('USER_NAME_PREFIX').blank?
+ new_users_user_names = new_users.map{|x| GsParameter.get('USER_NAME_PREFIX').to_s + x['UserName'].to_s}
else
new_users_user_names = new_users.map{|x| x['UserName']}
end
@@ -67,8 +67,8 @@ namespace :user_import do
new_users.each do |csv_user|
if !(csv_user['UserName'].blank? || csv_user['Email'].blank?) && double_checked_user_names.include?(csv_user['UserName'])
csv_user['Email'] = csv_user['Email'].downcase
- if defined?(USER_NAME_PREFIX) && !USER_NAME_PREFIX.blank?
- csv_user['UserName'] = USER_NAME_PREFIX.to_s + csv_user['UserName']
+ if defined?(GsParameter.get('USER_NAME_PREFIX')) && !GsParameter.get('USER_NAME_PREFIX').blank?
+ csv_user['UserName'] = GsParameter.get('USER_NAME_PREFIX').to_s + csv_user['UserName']
end
md5_sum = Digest::MD5.hexdigest(csv_user.to_yaml)
@@ -177,7 +177,7 @@ namespace :user_import do
if phone_numbers_count < sip_account.phone_numbers.count
call_forward_case_offline = CallForwardCase.find_by_value('offline')
if call_forward_case_offline
- sip_account.phone_numbers.first.call_forwards.create(:call_forward_case_id => call_forward_case_offline.id, :call_forwardable_type => 'Voicemail', :active => true, :depth => DEFAULT_CALL_FORWARD_DEPTH)
+ sip_account.phone_numbers.first.call_forwards.create(:call_forward_case_id => call_forward_case_offline.id, :call_forwardable_type => 'Voicemail', :active => true, :depth => GsParameter.get('DEFAULT_CALL_FORWARD_DEPTH'))
end
end
else
@@ -280,8 +280,8 @@ namespace :user_import do
conference.start = nil
conference.end = nil
conference.open_for_anybody = true
- conference.max_members = DEFAULT_MAX_CONFERENCE_MEMBERS
- conference.pin = (1..MINIMUM_PIN_LENGTH).map{|i| (0 .. 9).to_a.sample}.join
+ conference.max_members = GsParameter.get('DEFAULT_MAX_CONFERENCE_MEMBERS')
+ conference.pin = (1..GsParameter.get('MINIMUM_PIN_LENGTH')).map{|i| (0 .. 9).to_a.sample}.join
conference.save
end
@@ -314,7 +314,7 @@ namespace :user_import do
cell_phone_number = csv_user['CellPhone'].to_s.gsub(/[^0-9\+]/, '')
if !cell_phone_number.blank?
- callthrough = tenant.callthroughs.find_or_create_by_name(CALLTHROUGH_NAME_TO_BE_USED_FOR_DEFAULT_ACTIVATION)
+ callthrough = tenant.callthroughs.find_or_create_by_name(GsParameter.get('CALLTHROUGH_NAME_TO_BE_USED_FOR_DEFAULT_ACTIVATION'))
access_authorization = callthrough.access_authorizations.find_or_create_by_name('Cellphones')
diff --git a/lib/tasks/fax.rake b/lib/tasks/fax.rake
index 1f1c282..41ae7cf 100644
--- a/lib/tasks/fax.rake
+++ b/lib/tasks/fax.rake
@@ -37,7 +37,7 @@ task :import_inbound_fax, [
-o \"#{pdf_file}\" \\
-p #{paper_size} \\
-a \"#{fax_arguments[:remote_station_id]}\" \\
- -c \"AMOOMA Gemeinschaft version #{GEMEINSCHAFT_VERSION}\" \\
+ -c \"AMOOMA Gemeinschaft version #{GsParameter.get('GEMEINSCHAFT_VERSION')}\" \\
-t \"#{fax_arguments[:remote_station_id]}\" \"#{tiff_file}\""
if !File.exists?( pdf_file )
diff --git a/lib/tasks/gs_cluster.rake b/lib/tasks/gs_cluster.rake
index 565fd83..7b49ebb 100644
--- a/lib/tasks/gs_cluster.rake
+++ b/lib/tasks/gs_cluster.rake
@@ -1,15 +1,15 @@
namespace :gs_cluster do
desc "Sync local data to other gs cluster nodes."
task :push_waiting_data_to_other_nodes => :environment do
- infinity_loop_protection_counter = GsClusterSyncLogEntry.where(:homebase_ip_address => HOMEBASE_IP_ADDRESS,
+ infinity_loop_protection_counter = GsClusterSyncLogEntry.where(:homebase_ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS'),
:waiting_to_be_synced => true).count + 10
# One bite at a time.
#
- while GsClusterSyncLogEntry.where(:homebase_ip_address => HOMEBASE_IP_ADDRESS,
+ while GsClusterSyncLogEntry.where(:homebase_ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS'),
:waiting_to_be_synced => true).any? &&
infinity_loop_protection_counter > 0
- GsClusterSyncLogEntry.where(:homebase_ip_address => HOMEBASE_IP_ADDRESS,
+ GsClusterSyncLogEntry.where(:homebase_ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS'),
:waiting_to_be_synced => true).first.populate_other_cluster_nodes
infinity_loop_protection_counter -= 1
end
@@ -38,7 +38,7 @@ namespace :gs_cluster do
desc "Pull objects from nodes."
task :pull => :environment do
- local_node = GsNode.where(:ip_address => HOMEBASE_IP_ADDRESS).first
+ local_node = GsNode.where(:ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS')).first
GsNode.where(:accepts_updates_from => true).each do |remote_node|
if remote_node.id == local_node.id
next
diff --git a/lib/tasks/send_fax_notifications.rake b/lib/tasks/send_fax_notifications.rake
index 039c509..2ac74c8 100644
--- a/lib/tasks/send_fax_notifications.rake
+++ b/lib/tasks/send_fax_notifications.rake
@@ -23,7 +23,7 @@ task :send_fax_notifications => :environment do
-o \"#{pdf_file}\" \\
-p #{paper_size} \\
-a \"#{fax_document.remote_station_id}\" \\
- -c \"AMOOMA Gemeinschaft version #{GEMEINSCHAFT_VERSION}\" \\
+ -c \"AMOOMA Gemeinschaft version #{GsParameter.get('GEMEINSCHAFT_VERSION')}\" \\
-t \"#{fax_document.remote_station_id}\" \"#{TMP_DIR}#{tiff_file}\""
if !File.exists?( pdf_file )