erp_tech_svcs 3.1.8 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +6 -14
  2. data/README.md +15 -9
  3. data/app/controllers/erp_tech_svcs/session_controller.rb +21 -8
  4. data/app/controllers/erp_tech_svcs/user_controller.rb +15 -10
  5. data/app/mailers/user_mailer.rb +3 -0
  6. data/app/models/audit_log.rb +0 -2
  7. data/app/models/extensions/note.rb +1 -2
  8. data/app/models/extensions/party.rb +6 -1
  9. data/app/models/file_asset.rb +80 -38
  10. data/app/models/group.rb +1 -1
  11. data/app/models/notification.rb +49 -0
  12. data/app/models/notification_type.rb +5 -0
  13. data/app/models/user.rb +2 -2
  14. data/app/models/user_defined_data.rb +6 -0
  15. data/app/models/user_defined_field.rb +8 -0
  16. data/app/views/user_mailer/activation_needed_email.html.erb +17 -7
  17. data/config/initializers/file_support.rb +2 -2
  18. data/config/routes.rb +2 -1
  19. data/db/migrate/20130610163240_create_notifications.rb +37 -0
  20. data/db/migrate/20131113213843_add_audit_log_item_old_value.rb +13 -0
  21. data/db/migrate/20131113213844_add_erp_tech_svcs_missing_indexes.rb +31 -0
  22. data/db/migrate/20131129203603_add_user_defined_fields.rb +43 -0
  23. data/db/migrate/20141013060204_add_custom_fields_to_notifications.rb +12 -0
  24. data/db/migrate/20141108182427_add_scoped_by_to_file_assets.rb +14 -0
  25. data/lib/erp_tech_svcs.rb +4 -1
  26. data/lib/erp_tech_svcs/config.rb +5 -2
  27. data/lib/erp_tech_svcs/engine.rb +3 -1
  28. data/lib/erp_tech_svcs/extensions.rb +3 -1
  29. data/lib/erp_tech_svcs/extensions/active_record/has_user_defined_data.rb +147 -0
  30. data/lib/erp_tech_svcs/extensions/active_record/is_json.rb +55 -0
  31. data/lib/erp_tech_svcs/extensions/active_record/scoped_by.rb +64 -0
  32. data/lib/erp_tech_svcs/file_support/file_system_manager.rb +7 -0
  33. data/lib/erp_tech_svcs/file_support/manager.rb +1 -1
  34. data/lib/erp_tech_svcs/file_support/s3_manager.rb +13 -6
  35. data/lib/erp_tech_svcs/utils/default_nested_set_methods.rb +3 -5
  36. data/lib/erp_tech_svcs/version.rb +7 -3
  37. data/lib/tasks/erp_tech_svcs_tasks.rake +23 -4
  38. data/spec/lib/erp_tech_svcs/extensions/active_record/is_json_spec.rb +13 -0
  39. metadata +109 -78
  40. data/app/assets/javascripts/erp_tech_svcs/application.js +0 -9
  41. data/app/assets/stylesheets/erp_tech_svcs/application.css +0 -7
  42. data/app/helpers/erp_tech_svcs/application_helper.rb +0 -4
  43. data/app/views/layouts/application.html.erb +0 -14
  44. data/app/views/layouts/erp_tech_svcs/application.html.erb +0 -14
  45. data/config/initializers/erp_tech_svcs.rb +0 -16
  46. data/db/migrate/20111117183144_create_has_attribute_tables.rb +0 -38
  47. data/lib/erp_tech_svcs/extensions/active_record/has_relational_dynamic_attributes.rb +0 -128
  48. data/spec/dummy/db/data_migrations/20130220143304_add_usd_currency.erp_base_erp_svcs.rb +0 -12
  49. data/spec/dummy/db/data_migrations/20130220143305_add_iso_codes.erp_base_erp_svcs.rb +0 -19
  50. data/spec/dummy/db/data_migrations/20130220143306_setup_compass_ae_instance.erp_base_erp_svcs.rb +0 -21
  51. data/spec/dummy/db/data_migrations/20130220143307_upgrade_compass_ae_instances_data.erp_base_erp_svcs.rb +0 -19
  52. data/spec/dummy/db/data_migrations/20130220143308_create_capability_scope_types.erp_tech_svcs.rb +0 -15
  53. data/spec/dummy/db/data_migrations/20130220143309_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +0 -16
  54. data/spec/dummy/db/data_migrations/20130220143310_setup_audit_log_types.erp_tech_svcs.rb +0 -22
  55. data/spec/dummy/db/data_migrations/20130220143311_create_group_relationship_and_role_types.erp_tech_svcs.rb +0 -20
  56. data/spec/dummy/db/data_migrations/20130220143312_note_capabilities.erp_tech_svcs.rb +0 -24
  57. data/spec/dummy/db/data_migrations/20130422151256_add_guid_to_instances.erp_base_erp_svcs.rb +0 -10
  58. data/spec/dummy/db/migrate/20130220143259_base_erp_services.erp_base_erp_svcs.rb +0 -486
  59. data/spec/dummy/db/migrate/20130220143260_add_txn_status.erp_base_erp_svcs.rb +0 -37
  60. data/spec/dummy/db/migrate/20130220143261_upgrade_compass_ae_instances.erp_base_erp_svcs.rb +0 -34
  61. data/spec/dummy/db/migrate/20130220143262_base_tech_services.erp_tech_svcs.rb +0 -271
  62. data/spec/dummy/db/migrate/20130220143263_create_has_attribute_tables.erp_tech_svcs.rb +0 -39
  63. data/spec/dummy/db/migrate/20130220143264_create_groups.erp_tech_svcs.rb +0 -19
  64. data/spec/dummy/db/migrate/20130220143265_upgrade_security.erp_tech_svcs.rb +0 -54
  65. data/spec/dummy/db/migrate/20130220143266_upgrade_security2.erp_tech_svcs.rb +0 -275
  66. data/spec/dummy/db/migrate/20130422151250_add_uuid_compass_ae_instance.erp_base_erp_svcs.rb +0 -17
  67. data/spec/dummy/db/migrate/20130422151251_add_long_lat_to_address.erp_base_erp_svcs.rb +0 -16
  68. data/spec/dummy/db/migrate/20130422151252_add_queue_to_delayed_jobs.erp_tech_svcs.rb +0 -14
  69. data/spec/dummy/db/schema.rb +0 -665
  70. data/spec/dummy/db/spec.sqlite3 +0 -0
@@ -0,0 +1,5 @@
1
+ class NotificationType < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
4
+ has_many :notifications
5
+ end
data/app/models/user.rb CHANGED
@@ -15,11 +15,11 @@ class User < ActiveRecord::Base
15
15
  validates :password, :presence => true, :password_strength => true, :if => :password
16
16
 
17
17
  #email validations
18
- validates :email, :presence => {:message => 'Email cannot be blank'}, :uniqueness => {:case_sensitive => false}
18
+ validates :email, :presence => {:message => 'cannot be blank'}, :uniqueness => {:case_sensitive => false}
19
19
  validates_format_of :email, :with => /\b[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}\z/
20
20
 
21
21
  #username validations
22
- validates :username, :presence => {:message => 'Username cannot be blank'}, :uniqueness => {:case_sensitive => false}
22
+ validates :username, :presence => {:message => 'cannot be blank'}, :uniqueness => {:case_sensitive => false}
23
23
 
24
24
  validate :email_cannot_match_username_of_other_user
25
25
  def email_cannot_match_username_of_other_user
@@ -0,0 +1,6 @@
1
+ class UserDefinedData < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
4
+ has_many :user_defined_fields
5
+
6
+ end
@@ -0,0 +1,8 @@
1
+ class UserDefinedField < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
4
+ belongs_to :user_defined_data
5
+
6
+ validates_uniqueness_of :field_name, :scope => [:user_defined_data_id]
7
+
8
+ end
@@ -1,14 +1,24 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
5
- </head>
6
- <body>
7
- <h1>Welcome <%= @user.username %></h1>
3
+ <head>
4
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
5
+ </head>
6
+ <body>
7
+ <h1>Welcome <%= @user.username %></h1>
8
+ <% if @temp_password %>
9
+ <p>An account has been created for you, to activate your account follow this link: <a href="<%= @url %>"><%= @url %></a></p>
10
+
11
+ <p>Your username is <%= @user.username %>, your temporary password is <%= @temp_password %>.</p>
12
+
13
+ <p>Please login and update your password.</p>
14
+ <% else %>
8
15
  <p>
9
16
  You have successfully registered, to activate your account follow this link: <a href="<%= @url %>"><%= @url %></a>
10
17
  </p>
11
- <p>Your username is <%=@user.username%>, use the password you set during registration to login.</p>
18
+
19
+ <p>Your username is <%= @user.username %>, use the password you set during registration to login.</p>
20
+
12
21
  <p>Thanks for joining and have a great day!!</p>
13
- </body>
22
+ <% end %>
23
+ </body>
14
24
  </html>
@@ -3,7 +3,7 @@ Rails.application.config.to_prepare do
3
3
  # Rescue here, Compass should not die if it cannot connect to S3
4
4
  begin
5
5
  ErpTechSvcs::FileSupport::S3Manager.setup_connection() if Rails.application.config.erp_tech_svcs.file_storage == :s3
6
- rescue Exception => e
7
- Rails.logger.error "ERROR: Failed to connect to Amazon S3 #{e.inspect}"
6
+ rescue => ex
7
+ Rails.logger.error "ERROR: Failed to connect to Amazon S3 #{ex.inspect}"
8
8
  end
9
9
  end
data/config/routes.rb CHANGED
@@ -2,7 +2,8 @@ Rails.application.routes.draw do
2
2
  #handle login / logout
3
3
  match "/session/sign_in" => 'erp_tech_svcs/session#create'
4
4
  match "/session/sign_out" => 'erp_tech_svcs/session#destroy'
5
- match "/session/keep_alive" => 'erp_tech_svcs/session#keep_alive'
5
+ post "/session/keep_alive" => 'erp_tech_svcs/session#keep_alive'
6
+ get "/session/is_alive" => 'erp_tech_svcs/session#is_alive'
6
7
 
7
8
  #handle activation
8
9
  get "/users/activate/:activation_token" => 'erp_tech_svcs/user#activate'
@@ -0,0 +1,37 @@
1
+ class CreateNotifications < ActiveRecord::Migration
2
+ def up
3
+
4
+ unless table_exists? :notifications
5
+ create_table :notifications do |t|
6
+ t.string :type
7
+ t.references :created_by
8
+ t.text :message
9
+ t.references :notification_type
10
+ t.string :current_state
11
+
12
+ t.timestamps
13
+ end
14
+
15
+ add_index :notifications, :notification_type_id
16
+ add_index :notifications, :created_by_id
17
+ add_index :notifications, :type
18
+ end
19
+
20
+ unless table_exists? :notification_types
21
+ create_table :notification_types do |t|
22
+ t.string :internal_identifier
23
+ t.string :description
24
+
25
+ t.timestamps
26
+ end
27
+
28
+ add_index :notification_types, :internal_identifier
29
+ end
30
+
31
+ end
32
+
33
+ def down
34
+ drop_table :notifications if table_exists? :notifications
35
+ drop_table :notification_types if table_exists? :notification_types
36
+ end
37
+ end
@@ -0,0 +1,13 @@
1
+ class AddAuditLogItemOldValue < ActiveRecord::Migration
2
+ def up
3
+ unless AuditLogItem.columns.include?(:audit_log_item_old_value)
4
+ add_column :audit_log_items, :audit_log_item_old_value, :string
5
+ end
6
+ end
7
+
8
+ def down
9
+ if AuditLogItem.columns.include?(:audit_log_item_old_value)
10
+ remove_column :audit_log_items, :audit_log_item_old_value
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,31 @@
1
+ class AddErpTechSvcsMissingIndexes < ActiveRecord::Migration
2
+ def up
3
+ if indexes(:role_types).select { |index| index.name == 'role_types_parent_id_idx' }.empty?
4
+ add_index :role_types, :parent_id, :name => 'role_types_parent_id_idx'
5
+ add_index :security_roles, :internal_identifier, :name => 'security_roles_internal_identifier_idx'
6
+ add_index :audit_logs, :audit_log_type_id, :name => 'audit_logs_audit_log_type_id_idx'
7
+ add_index :audit_log_types, :internal_identifier, :name => 'audit_log_types_internal_identifier_idx'
8
+ add_index :audit_log_types, :parent_id, :name => 'audit_log_types_parent_id_idx'
9
+ add_index :audit_log_items, :audit_log_id, :name => 'audit_log_items_audit_log_id_idx'
10
+ add_index :audit_log_items, :audit_log_item_type_id, :name => 'audit_log_items_audit_log_item_type_id_idx'
11
+ add_index :audit_log_item_types, :internal_identifier, :name => 'audit_log_item_types_internal_identifier_idx'
12
+ add_index :audit_log_item_types, :parent_id, :name => 'audit_log_item_types_parent_id_idx'
13
+ add_index :capability_types, :internal_identifier, :name => 'capability_types_internal_identifier_idx'
14
+ end
15
+ end
16
+
17
+ def down
18
+ unless indexes(:role_types).select { |index| index.name == 'role_types_parent_id_idx' }.empty?
19
+ remove_index :role_types, :parent_id
20
+ remove_index :security_roles, :internal_identifier
21
+ remove_index :audit_logs, :audit_log_type_id
22
+ remove_index :audit_log_types, :internal_identifier
23
+ remove_index :audit_log_types, :parent_id
24
+ remove_index :audit_log_items, :audit_log_id
25
+ remove_index :audit_log_items, :audit_log_item_type_id
26
+ remove_index :audit_log_item_types, :internal_identifier
27
+ remove_index :audit_log_item_types, :parent_id
28
+ remove_index :capability_types, :internal_identifier
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,43 @@
1
+ class AddUserDefinedFields < ActiveRecord::Migration
2
+ def up
3
+
4
+ unless table_exists? :user_defined_data
5
+ create_table :user_defined_data do |t|
6
+ t.string :scope
7
+ t.string :model_name
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :user_defined_data, :scope
13
+ end
14
+
15
+ unless table_exists? :user_defined_fields
16
+ create_table :user_defined_fields do |t|
17
+ t.string :field_name
18
+ t.string :label
19
+ t.string :data_type
20
+ t.references :user_defined_data
21
+
22
+ t.timestamps
23
+ end
24
+
25
+ add_index :user_defined_fields, :user_defined_data_id
26
+ add_index :user_defined_fields, :field_name
27
+ end
28
+
29
+ end
30
+
31
+ def down
32
+
33
+ if table_exists? :user_defined_data
34
+ drop_table :user_defined_data
35
+ end
36
+
37
+ if table_exists? :user_defined_fields
38
+ drop_table :user_defined_fields
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,12 @@
1
+ class AddCustomFieldsToNotifications < ActiveRecord::Migration
2
+ def change
3
+ if ::ActiveRecord::Base.connection.instance_values["config"][:adapter] == 'postgresql'
4
+ execute('CREATE EXTENSION IF NOT EXISTS hstore;')
5
+
6
+ add_column :notifications, :custom_fields, :hstore
7
+ add_hstore_index :notifications, :custom_fields
8
+ else
9
+ add_column :notifications, :custom_fields, :text
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ class AddScopedByToFileAssets < ActiveRecord::Migration
2
+ def change
3
+
4
+ if ::ActiveRecord::Base.connection.instance_values["config"][:adapter] == 'postgresql'
5
+ execute('CREATE EXTENSION IF NOT EXISTS hstore;')
6
+
7
+ add_column :file_assets, :scoped_by, :hstore
8
+ add_hstore_index :file_assets, :scoped_by
9
+ else
10
+ add_column :file_assets, :scoped_by, :text
11
+ end
12
+
13
+ end
14
+ end
data/lib/erp_tech_svcs.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'aasm'
2
+
1
3
  #compass_ae libraries
2
4
  require 'erp_base_erp_svcs'
3
5
 
@@ -8,6 +10,8 @@ require 'mail_alternatives_with_attachments'
8
10
  require 'sorcery'
9
11
  require 'pdfkit'
10
12
  require 'aws'
13
+ require 'activerecord-postgres-hstore'
14
+ require 'nested-hstore'
11
15
  require "erp_tech_svcs/version"
12
16
  require "erp_tech_svcs/utils/compass_logger"
13
17
  require "erp_tech_svcs/utils/default_nested_set_methods"
@@ -20,6 +24,5 @@ require "erp_tech_svcs/engine"
20
24
  require 'erp_tech_svcs/sessions/delete_expired_sessions_job'
21
25
  require 'erp_tech_svcs/sessions/delete_expired_sessions_service'
22
26
  require 'erp_tech_svcs/erp_tech_svcs_audit_log'
23
-
24
27
  module ErpTechSvcs
25
28
  end
@@ -8,9 +8,11 @@ module ErpTechSvcs
8
8
  :login_url,
9
9
  :email_notifications_from,
10
10
  :email_regex,
11
- :file_assets_location,
11
+ :file_assets_location,
12
+ :file_protocol,
12
13
  :s3_url_expires_in_seconds,
13
14
  :s3_protocol,
15
+ :s3_url,
14
16
  :file_storage,
15
17
  :s3_cache_expires_in_minutes,
16
18
  :session_expires_in_hours,
@@ -26,9 +28,10 @@ module ErpTechSvcs
26
28
  :@email_regex => "^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$",
27
29
  :@file_assets_location => 'file_assets', # relative to Rails.root/
28
30
  :@s3_url_expires_in_seconds => 60,
31
+ :@s3_url => ':s3_path_url',
32
+ :@file_protocol => 'http', # Can be either 'http' or 'https'
29
33
  :@s3_protocol => 'https', # Can be either 'http' or 'https'
30
34
  :@file_storage => :filesystem, # Can be either :s3 or :filesystem
31
- :@s3_cache_expires_in_minutes => 60,
32
35
  :@session_expires_in_hours => 12, # this is used by DeleteExpiredSessionsJob to purge inactive sessions from database
33
36
  :@compass_logger_path => "#{Rails.root}/log"
34
37
  }
@@ -9,7 +9,9 @@ module ErpTechSvcs
9
9
  include ErpTechSvcs::Extensions::ActiveRecord::HasFileAssets
10
10
  include ErpTechSvcs::Extensions::ActiveRecord::ProtectedByCapabilities
11
11
  include ErpTechSvcs::Extensions::ActiveRecord::HasCapabilityAccessors
12
- include ErpTechSvcs::Extensions::ActiveRecord::HasRelationalDynamicAttributes
12
+ include ErpTechSvcs::Extensions::ActiveRecord::HasUserDefinedData
13
+ include ErpTechSvcs::Extensions::ActiveRecord::IsJson
14
+ include ErpTechSvcs::Extensions::ActiveRecord::ScopedBy
13
15
  end
14
16
 
15
17
  ErpBaseErpSvcs.register_as_compass_ae_engine(config, self)
@@ -8,7 +8,9 @@ require 'erp_tech_svcs/extensions/active_record/has_security_roles'
8
8
  require 'erp_tech_svcs/extensions/active_record/protected_with_capabilities'
9
9
  require 'erp_tech_svcs/extensions/active_record/has_capability_accessors'
10
10
  require 'erp_tech_svcs/extensions/active_record/acts_as_versioned'
11
- require 'erp_tech_svcs/extensions/active_record/has_relational_dynamic_attributes'
11
+ require 'erp_tech_svcs/extensions/active_record/has_user_defined_data'
12
+ require 'erp_tech_svcs/extensions/active_record/is_json'
13
+ require 'erp_tech_svcs/extensions/active_record/scoped_by'
12
14
 
13
15
  #sorcery
14
16
  require 'erp_tech_svcs/extensions/sorcery/user_activation'
@@ -0,0 +1,147 @@
1
+ module ErpTechSvcs
2
+ module Extensions
3
+ module ActiveRecord
4
+ module HasUserDefinedData
5
+
6
+ module Errors
7
+ class UserDefinedFieldAlreadyExists < StandardError
8
+ def to_s
9
+ "User defined field already exists."
10
+ end
11
+ end
12
+
13
+ class UserDefinedFieldDoesNotExist < StandardError
14
+ def to_s
15
+ "User defined field does not exist."
16
+ end
17
+ end
18
+
19
+ class UserDefinedDataDoesNotExist < StandardError
20
+ def to_s
21
+ "User defined data does not exist."
22
+ end
23
+ end
24
+ end
25
+
26
+ def self.included(base)
27
+ base.extend(ClassMethods)
28
+ end
29
+
30
+ module ClassMethods
31
+
32
+ def has_user_defined_data
33
+ extend HasUserDefinedData::SingletonMethods
34
+ include HasUserDefinedData::InstanceMethods
35
+ end
36
+
37
+ end
38
+
39
+ module SingletonMethods
40
+
41
+ def remove_all_user_defined_data
42
+ UserDefinedData.destroy_all("model_name = #{self.name}")
43
+ end
44
+
45
+ alias remove_user_fields remove_all_user_defined_data
46
+
47
+ def user_defined_fields(scope=nil)
48
+ user_defined_data = if scope
49
+ # return array and remove nil if none with specified scope
50
+ [UserDefinedData.where('scope = ? and model_name = ?', scope, self.name).first].compact
51
+ else
52
+ UserDefinedData.where('model_name = ?', self.name).all
53
+ end
54
+
55
+ if user_defined_data.empty?
56
+ []
57
+ else
58
+ user_defined_data.collect(&:user_defined_fields).flatten
59
+ end
60
+
61
+ end
62
+
63
+ alias user_fields user_defined_fields
64
+
65
+ def user_defined_field(field_name, scope=nil)
66
+ UserDefinedField.joins(:user_defined_data)
67
+ .where('model_name = ?', self.name)
68
+ .where('scope = ?', scope)
69
+ .where('field_name = ?', field_name).first
70
+ end
71
+
72
+ alias user_field user_defined_field
73
+
74
+ def add_user_defined_field(field_name, label, data_type, scope=nil)
75
+ current_user_field = self.user_field(field_name, scope)
76
+
77
+ if current_user_field
78
+ raise Error::UserDefinedFieldAlreadyExists
79
+ else
80
+ user_defined_field = UserDefinedField.new(field_name: field_name, label: label, data_type: data_type)
81
+
82
+ user_defined_data = if scope
83
+ # return array and remove nil if none with specified scope
84
+ UserDefinedData.where('scope = ? and model_name = ?', scope, self.name).first
85
+ else
86
+ UserDefinedData.where('scope = ? and model_name = ?', nil, self.name)
87
+ end
88
+
89
+ user_defined_data = UserDefinedData.new(scope: scope, model_name: self.name) unless user_defined_data
90
+
91
+ user_defined_data.user_defined_fields << user_defined_field
92
+ user_defined_data.save
93
+
94
+ user_defined_field
95
+ end
96
+
97
+ end
98
+
99
+ alias add_user_field add_user_defined_field
100
+
101
+ def update_user_defined_field(field_name, label, scope=nil)
102
+ current_user_field = self.user_field(field_name, scope)
103
+
104
+ if current_user_field
105
+ current_user_field.label = label
106
+ current_user_field.save
107
+ else
108
+ raise Errors::UserDefinedFieldDoesNotExist
109
+ end
110
+ end
111
+
112
+ alias update_user_field update_user_defined_field
113
+
114
+ def remove_user_defined_field(field_name, scope=nil)
115
+ user_defined_data = if scope
116
+ # return array and remove nil if none with specified scope
117
+ UserDefinedData.where('scope = ? and model_name = ?', scope, self.name).first
118
+ else
119
+ UserDefinedData.where('scope = ? and model_name = ?', nil, self.name)
120
+ end
121
+
122
+ if user_defined_data
123
+ user_defined_field = user_defined_data.user_defined_fields.where('field_name = ?', field_name)
124
+
125
+ if user_defined_field
126
+ user_defined_field.destroy
127
+ else
128
+ raise Errors::UserDefinedFieldDoesNotExist
129
+ end
130
+ else
131
+ raise Errors::UserDefinedDataDoesNotExist
132
+ end
133
+ end
134
+
135
+ alias remove_user_field remove_user_defined_field
136
+
137
+ end
138
+
139
+ module InstanceMethods
140
+
141
+ end
142
+
143
+ end #HasUserDefinedData
144
+ end #ActiveRecord
145
+ end #Extensions
146
+ end #ErpTechSvcs
147
+