erp_search 3.0.4 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/models/extensions/dynamic_form_document.rb +3 -0
- data/app/models/extensions/ticket.rb +3 -0
- data/app/models/extensions/website_inquiry.rb +3 -0
- data/app/models/party_search_fact.rb +2 -0
- data/config/sunspot.yml +11 -4
- data/lib/erp_search.rb +7 -0
- data/lib/erp_search/engine.rb +5 -2
- data/lib/erp_search/extensions.rb +2 -0
- data/lib/erp_search/extensions/active_record/has_dynamic_solr_search.rb +116 -0
- data/lib/erp_search/version.rb +2 -2
- data/lib/tasks/dynamic_form_models.rake +42 -0
- data/spec/dummy/config/application.rb +6 -0
- data/spec/dummy/config/environments/spec.rb +3 -0
- data/spec/dummy/config/sunspot.yml +36 -0
- data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb +15 -0
- data/spec/dummy/db/data_migrations/20110509223702_add_publisher_role.knitkit.rb +22 -0
- data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/data_migrations/20110608185830_create_default_dynamic_models_and_forms.erp_forms.rb +33 -0
- data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +19 -0
- data/spec/dummy/db/data_migrations/20110728201729_erp_app_setup.erp_app.rb +252 -0
- data/spec/dummy/db/data_migrations/20110728201733_update_preferences.erp_app.rb +53 -0
- data/spec/dummy/db/data_migrations/20110802200222_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +16 -0
- data/spec/dummy/db/data_migrations/20110816153456_add_knitkit_application.knitkit.rb +32 -0
- data/spec/dummy/db/data_migrations/20110816161238_create_desktop_app_audit_log_viewer.erp_app.rb +21 -0
- data/spec/dummy/db/data_migrations/20110817160743_add_file_manager_application.erp_app.rb +32 -0
- data/spec/dummy/db/data_migrations/20110828190913_create_desktop_app_dynamic_forms.erp_forms.rb +19 -0
- data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +12 -0
- data/spec/dummy/db/data_migrations/20111108183739_add_default_capabilities.erp_app.rb +23 -0
- data/spec/dummy/db/data_migrations/20111108183740_add_new_contact_widgets.erp_app.rb +42 -0
- data/spec/dummy/db/data_migrations/20111111144706_setup_audit_log_types.erp_tech_svcs.rb +22 -0
- data/spec/dummy/db/data_migrations/20111118182910_setup_knitkit_capabilities.knitkit.rb +128 -0
- data/spec/dummy/db/data_migrations/20120109173616_create_download_capability_type.erp_tech_svcs.rb +14 -0
- data/spec/dummy/db/data_migrations/20120127144444_create_website_role_types.knitkit.rb +14 -0
- data/spec/dummy/db/data_migrations/20120127150505_create_website_default_configuration.knitkit.rb +73 -0
- data/spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb +34 -0
- data/spec/dummy/db/data_migrations/20120229160222_add_userinfo_widget.erp_app.rb +29 -0
- data/spec/dummy/db/data_migrations/20120316150424_add_is_template_to_default_website_config.knitkit.rb +17 -0
- data/spec/dummy/db/data_migrations/20120405193721_create_party_and_role_type_for_communication_events.erp_app.rb +11 -0
- data/spec/dummy/db/data_migrations/20120411180756_create_user_management_mobile_application.erp_app.rb +19 -0
- data/spec/dummy/db/data_migrations/20120418164215_create_configuration_management_desktop_application.erp_app.rb +23 -0
- data/spec/dummy/db/data_migrations/20120809020508_update_website_and_configuration.knitkit.rb +78 -0
- data/spec/dummy/db/data_migrations/20120824013449_create_ticket_form.erp_forms.rb +67 -0
- data/spec/dummy/db/data_migrations/20121026013449_update_ticket_form.erp_forms.rb +65 -0
- data/spec/dummy/db/data_migrations/20121026191738_update_contact_form.erp_forms.rb +27 -0
- data/spec/dummy/db/data_migrations/20121116155018_create_group_relationship_and_role_types.erp_tech_svcs.rb +20 -0
- data/spec/dummy/db/data_migrations/20121129185611_upgrade_website_role_iid.knitkit.rb +21 -0
- data/spec/dummy/db/data_migrations/20121130201859_upgrade_remove_system_mgmt_app.erp_app.rb +16 -0
- data/spec/dummy/db/data_migrations/20121130212146_note_capabilities.erp_tech_svcs.rb +24 -0
- data/spec/dummy/db/data_migrations/20121218175028_create_security_management_desktop_application.erp_app.rb +23 -0
- data/spec/dummy/db/migrate/20121219182151_base_erp_services.erp_base_erp_svcs.rb +461 -0
- data/spec/dummy/db/migrate/20121219182152_recreate_party_search_facts_table.erp_search.rb +40 -0
- data/spec/dummy/db/migrate/20121219182153_base_tech_services.erp_tech_svcs.rb +255 -0
- data/spec/dummy/db/migrate/20121219182154_create_has_attribute_tables.erp_tech_svcs.rb +39 -0
- data/spec/dummy/db/migrate/20121219182155_base_app_framework.erp_app.rb +276 -0
- data/spec/dummy/db/migrate/20121219182156_dynamic_forms.erp_forms.rb +95 -0
- data/spec/dummy/db/migrate/20121219182157_create_tickets.erp_forms.rb +19 -0
- data/spec/dummy/db/migrate/20121219182158_upgrade_dynamic_forms_table.erp_forms.rb +32 -0
- data/spec/dummy/db/migrate/20121219182159_setup_knitkit.knitkit.rb +316 -0
- data/spec/dummy/db/migrate/20130107181410_create_groups.erp_tech_svcs.rb +19 -0
- data/spec/dummy/db/migrate/20130107181411_upgrade_security.erp_tech_svcs.rb +54 -0
- data/spec/dummy/db/migrate/20130107181412_upgrade_security2.erp_tech_svcs.rb +270 -0
- data/spec/dummy/db/schema.rb +1172 -0
- data/spec/dummy/db/spec.sqlite3 +0 -0
- data/spec/dummy/log/development.log +3 -0
- data/spec/dummy/log/spec.log +26839 -0
- data/spec/dummy/log/sunspot-solr-spec.log +24338 -0
- data/spec/dummy/solr/conf/admin-extra.html +31 -0
- data/spec/dummy/solr/conf/elevate.xml +36 -0
- data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/spec/dummy/solr/conf/protwords.txt +21 -0
- data/spec/dummy/solr/conf/schema.xml +238 -0
- data/spec/dummy/solr/conf/scripts.conf +24 -0
- data/spec/dummy/solr/conf/solrconfig.xml +934 -0
- data/spec/dummy/solr/conf/spellings.txt +2 -0
- data/spec/dummy/solr/conf/stopwords.txt +58 -0
- data/spec/dummy/solr/conf/synonyms.txt +31 -0
- data/spec/dummy/solr/data/spec/index/segments.gen +0 -0
- data/spec/dummy/solr/data/spec/index/segments_av +0 -0
- data/spec/dummy/solr/data/spec/spellchecker/segments.gen +0 -0
- data/spec/dummy/solr/data/spec/spellchecker/segments_1 +0 -0
- data/spec/dummy/solr/pids/spec/sunspot-solr-spec.pid +1 -0
- data/spec/spec_helper.rb +19 -10
- metadata +171 -80
data/config/sunspot.yml
CHANGED
|
@@ -6,18 +6,25 @@ development:
|
|
|
6
6
|
port: 8982
|
|
7
7
|
path: /solr
|
|
8
8
|
log_level: INFO
|
|
9
|
+
|
|
10
|
+
production:
|
|
11
|
+
solr:
|
|
12
|
+
hostname: 127.0.0.1
|
|
13
|
+
port: 8983
|
|
14
|
+
path: /solr
|
|
15
|
+
log_level: WARNING
|
|
9
16
|
|
|
10
|
-
|
|
17
|
+
spec:
|
|
11
18
|
solr:
|
|
12
19
|
hostname: 127.0.0.1
|
|
13
20
|
port: 8981
|
|
14
21
|
path: /solr
|
|
15
22
|
log_level: WARNING
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
|
|
24
|
+
test:
|
|
18
25
|
solr:
|
|
19
26
|
hostname: 127.0.0.1
|
|
20
|
-
port:
|
|
27
|
+
port: 8981
|
|
21
28
|
path: /solr
|
|
22
29
|
log_level: WARNING
|
|
23
30
|
|
data/lib/erp_search.rb
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
require 'erp_base_erp_svcs'
|
|
2
|
+
|
|
3
|
+
require 'sunspot'
|
|
4
|
+
|
|
5
|
+
require "erp_search/extensions"
|
|
1
6
|
require "erp_search/version"
|
|
2
7
|
require "erp_search/engine"
|
|
3
8
|
|
|
9
|
+
|
|
4
10
|
$USE_SOLR_FOR_CONTENT = true
|
|
11
|
+
$USE_SOLR_FOR_DYNAMIC_FORM_MODELS = true
|
|
5
12
|
|
|
6
13
|
module ErpSearch
|
|
7
14
|
end
|
data/lib/erp_search/engine.rb
CHANGED
|
@@ -3,13 +3,16 @@ require 'sunspot_rails'
|
|
|
3
3
|
module ErpSearch
|
|
4
4
|
class Engine < Rails::Engine
|
|
5
5
|
isolate_namespace ErpSearch
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
ActiveSupport.on_load(:active_record) do
|
|
8
|
+
include ErpSearch::Extensions::ActiveRecord::HasDynamicSolrSearch
|
|
9
|
+
end
|
|
10
|
+
|
|
7
11
|
#add observers
|
|
8
12
|
#this is ugly need a better way
|
|
9
13
|
observers = [:party_observer, :contact_observer]
|
|
10
14
|
(config.active_record.observers.nil?) ? config.active_record.observers = observers : config.active_record.observers += observers
|
|
11
15
|
|
|
12
16
|
ErpBaseErpSvcs.register_as_compass_ae_engine(config, self)
|
|
13
|
-
|
|
14
17
|
end
|
|
15
18
|
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# require 'sunspot'
|
|
2
|
+
# Sunspot::Setup.class_eval do
|
|
3
|
+
# def self.clear_setup_for_class(klass)
|
|
4
|
+
# Rails.logger.info "clear_setup_for_class"
|
|
5
|
+
# Sunspot.searchable.delete!(klass)
|
|
6
|
+
# Rails.logger.info "searchable #{Sunspot.searchable.inspect}"
|
|
7
|
+
# #Rails.logger.info "field_factories #{field_factories.inspect}"
|
|
8
|
+
# Rails.logger.info "setups[klass.name.to_sym] #{setups.keys}"
|
|
9
|
+
# setups.delete_if{|key, value| key == klass.name.to_sym }
|
|
10
|
+
# #setups[klass.name.to_sym] = new(clazz)
|
|
11
|
+
# Rails.logger.info "setups[klass.name.to_sym] #{setups.keys}"
|
|
12
|
+
# end
|
|
13
|
+
# end
|
|
14
|
+
|
|
15
|
+
# Sunspot::ClassSet.class_eval do
|
|
16
|
+
# def delete!(klass)
|
|
17
|
+
# @name_to_klass.delete_if{|key, value| key == klass.name.to_sym }
|
|
18
|
+
# end
|
|
19
|
+
# end
|
|
20
|
+
|
|
21
|
+
module ErpSearch
|
|
22
|
+
module Extensions
|
|
23
|
+
module ActiveRecord
|
|
24
|
+
module HasDynamicSolrSearch
|
|
25
|
+
def self.included(base)
|
|
26
|
+
base.extend(ClassMethods)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
module ClassMethods
|
|
30
|
+
def is_searchable?
|
|
31
|
+
respond_to?(:solr_search)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def has_dynamic_solr_search
|
|
35
|
+
include HasDynamicSolrSearch::InstanceMethods
|
|
36
|
+
|
|
37
|
+
extend Sunspot::Rails::Searchable::ClassMethods
|
|
38
|
+
include Sunspot::Rails::Searchable::InstanceMethods
|
|
39
|
+
|
|
40
|
+
class_attribute :sunspot_options
|
|
41
|
+
|
|
42
|
+
before_save :mark_for_auto_indexing_or_removal
|
|
43
|
+
after_save :perform_index_tasks
|
|
44
|
+
|
|
45
|
+
after_destroy do |searchable|
|
|
46
|
+
searchable.remove_from_index
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# init search setup
|
|
50
|
+
self.sunspot_setup
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def sunspot_setup(options={})
|
|
54
|
+
klass = DynamicFormModel.get_constant(self.name)
|
|
55
|
+
#Sunspot::Setup.clear_setup_for_class(klass)
|
|
56
|
+
definition = DynamicForm.get_form(self.name).definition_object rescue nil
|
|
57
|
+
|
|
58
|
+
unless definition.nil?
|
|
59
|
+
#Rails.logger.info "calling sunspot setup"
|
|
60
|
+
Sunspot.setup(klass) do
|
|
61
|
+
integer :id
|
|
62
|
+
date :created_at do data.created_at end
|
|
63
|
+
date :updated_at do data.updated_at end
|
|
64
|
+
string :created_by do data.created_by.username rescue nil end
|
|
65
|
+
string :updated_by do data.updated_by.username rescue nil end
|
|
66
|
+
definition.each do |f|
|
|
67
|
+
next unless f[:searchable]
|
|
68
|
+
atype = convert_xtype_to_attribute_type(f[:xtype])
|
|
69
|
+
# respond_to allows us to support both static and dynamic attributes on model
|
|
70
|
+
if self.respond_to?(f[:name].to_sym)
|
|
71
|
+
send('text', f[:name].to_sym) if atype == 'string' # enable full text search for strings
|
|
72
|
+
send(atype, f[:name].to_sym) # configure attribute fields for scoping, faceting, ordering, etc
|
|
73
|
+
else
|
|
74
|
+
dyn_attr_key = DynamicDatum::DYNAMIC_ATTRIBUTE_PREFIX + f[:name]
|
|
75
|
+
if f[:xtype] == 'related_combobox'
|
|
76
|
+
extraction_block = proc { DynamicDatum.related_data_value(f[:extraParams]['model'], data.send(dyn_attr_key), f[:displayField]) }
|
|
77
|
+
else
|
|
78
|
+
extraction_block = proc { data.send(dyn_attr_key) }
|
|
79
|
+
end
|
|
80
|
+
send('text', f[:name].to_sym, &extraction_block) if atype == 'string' # enable full text search for strings
|
|
81
|
+
send(atype, f[:name].to_sym, &extraction_block) # configure attribute fields for scoping, faceting, ordering, etc
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
self.sunspot_options = options
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def convert_xtype_to_attribute_type(xtype)
|
|
91
|
+
case xtype
|
|
92
|
+
when 'numberfield'
|
|
93
|
+
return 'integer'
|
|
94
|
+
when 'checkbox'
|
|
95
|
+
return 'boolean'
|
|
96
|
+
when 'datefield'
|
|
97
|
+
return 'date'
|
|
98
|
+
when 'timefield'
|
|
99
|
+
return 'time'
|
|
100
|
+
else
|
|
101
|
+
return 'string'
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
module InstanceMethods
|
|
107
|
+
|
|
108
|
+
def sunspot_setup(options={})
|
|
109
|
+
self.class.sunspot_setup(options)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
data/lib/erp_search/version.rb
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'action_controller'
|
|
2
|
+
require 'sunspot/rails/tasks'
|
|
3
|
+
|
|
4
|
+
namespace :sunspot do
|
|
5
|
+
task :reindex_dynamic_form_models => :environment do
|
|
6
|
+
if use_solr?
|
|
7
|
+
DynamicFormModel.order('id asc').all.each do |m|
|
|
8
|
+
next if m.model_name == 'DynamicFormDocument'
|
|
9
|
+
if m.get_constant.is_searchable?
|
|
10
|
+
m.get_constant.sunspot_setup
|
|
11
|
+
puts "Indexing #{m.model_name} ..."
|
|
12
|
+
m.get_constant.solr_reindex
|
|
13
|
+
puts "Done."
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
task :delete_dynamic_form_models => :environment do
|
|
20
|
+
if use_solr?
|
|
21
|
+
DynamicFormModel.all.each do |m|
|
|
22
|
+
next if m.model_name == 'DynamicFormDocument'
|
|
23
|
+
if m.get_constant.is_searchable?
|
|
24
|
+
m.get_constant.sunspot_setup
|
|
25
|
+
puts "Removing Indexes for #{m.model_name} ..."
|
|
26
|
+
m.get_constant.solr_remove_all_from_index!
|
|
27
|
+
puts "Done."
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def use_solr?
|
|
35
|
+
if $USE_SOLR_FOR_DYNAMIC_FORM_MODELS
|
|
36
|
+
return true
|
|
37
|
+
else
|
|
38
|
+
puts "USE_SOLR_FOR_DYNAMIC_FORM_MODELS is off. You likely need to install erp_search."
|
|
39
|
+
return false
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -41,6 +41,12 @@ module Dummy
|
|
|
41
41
|
|
|
42
42
|
# Enable the asset pipeline
|
|
43
43
|
config.assets.enabled = true
|
|
44
|
+
|
|
45
|
+
# Enforce whitelist mode for mass assignment.
|
|
46
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
|
47
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
|
48
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
|
49
|
+
config.active_record.whitelist_attributes = true
|
|
44
50
|
end
|
|
45
51
|
end
|
|
46
52
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
Dummy::Application.configure do
|
|
2
2
|
# Settings specified here will take precedence over those in config/application.rb
|
|
3
3
|
|
|
4
|
+
# Raise exception on mass assignment protection for Active Record models
|
|
5
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
|
6
|
+
|
|
4
7
|
# In the development environment your application's code is reloaded on
|
|
5
8
|
# every request. This slows down response time but is perfect for development
|
|
6
9
|
# since you don't have to restart the web server when you make code changes.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#Defaults to 8981 in test, 8982 in development and 8983 in production.
|
|
2
|
+
|
|
3
|
+
development:
|
|
4
|
+
solr:
|
|
5
|
+
hostname: 127.0.0.1
|
|
6
|
+
port: 8982
|
|
7
|
+
path: /solr
|
|
8
|
+
log_level: INFO
|
|
9
|
+
|
|
10
|
+
production:
|
|
11
|
+
solr:
|
|
12
|
+
hostname: 127.0.0.1
|
|
13
|
+
port: 8983
|
|
14
|
+
path: /solr
|
|
15
|
+
log_level: WARNING
|
|
16
|
+
|
|
17
|
+
spec:
|
|
18
|
+
solr:
|
|
19
|
+
hostname: 127.0.0.1
|
|
20
|
+
port: 8981
|
|
21
|
+
path: /solr
|
|
22
|
+
log_level: WARNING
|
|
23
|
+
|
|
24
|
+
test:
|
|
25
|
+
solr:
|
|
26
|
+
hostname: 127.0.0.1
|
|
27
|
+
port: 8981
|
|
28
|
+
path: /solr
|
|
29
|
+
log_level: WARNING
|
|
30
|
+
|
|
31
|
+
adam:
|
|
32
|
+
solr:
|
|
33
|
+
port: 8982
|
|
34
|
+
hostname: 127.0.0.1
|
|
35
|
+
path: /solr
|
|
36
|
+
log_level: INFO
|
data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# This migration comes from erp_tech_svcs (originally 20110109173616)
|
|
2
|
+
class CreateCapabilityScopeTypes
|
|
3
|
+
|
|
4
|
+
def self.up
|
|
5
|
+
CapabilityType.create(:internal_identifier => 'download', :description => 'Download') if CapabilityType.where("internal_identifier = 'download'").first.nil?
|
|
6
|
+
|
|
7
|
+
ScopeType.create(:description => 'Instance', :internal_identifier => 'instance') if ScopeType.where("internal_identifier = 'instance'").first.nil?
|
|
8
|
+
ScopeType.create(:description => 'Class', :internal_identifier => 'class') if ScopeType.where("internal_identifier = 'class'").first.nil?
|
|
9
|
+
ScopeType.create(:description => 'Query', :internal_identifier => 'query') if ScopeType.where("internal_identifier = 'query'").first.nil?
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.down
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# This migration comes from knitkit (originally 20110509223702)
|
|
2
|
+
class AddPublisherRole
|
|
3
|
+
|
|
4
|
+
def self.up
|
|
5
|
+
SecurityRole.create(:internal_identifier => 'publisher', :description => 'Publisher')
|
|
6
|
+
SecurityRole.create(:internal_identifier => 'content_author', :description => 'Content Author')
|
|
7
|
+
SecurityRole.create(:internal_identifier => 'layout_author', :description => 'Layout Author')
|
|
8
|
+
SecurityRole.create(:internal_identifier => 'editor', :description => 'Editor')
|
|
9
|
+
SecurityRole.create(:internal_identifier => 'designer', :description => 'Designer')
|
|
10
|
+
SecurityRole.create(:internal_identifier => 'website_author', :description => 'Website Author')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.down
|
|
14
|
+
SecurityRole.iid('publisher').destroy
|
|
15
|
+
SecurityRole.iid('content_author').destroy
|
|
16
|
+
SecurityRole.iid('layout_author').destroy
|
|
17
|
+
SecurityRole.iid('editor').destroy
|
|
18
|
+
SecurityRole.iid('designer').destroy
|
|
19
|
+
SecurityRole.iid('website_author').destroy
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# This migration comes from erp_base_erp_svcs (originally 20110525001935)
|
|
2
|
+
class AddUsdCurrency
|
|
3
|
+
|
|
4
|
+
def self.up
|
|
5
|
+
Currency.create(:name => 'US Dollar', :internal_identifier => 'USD', :major_unit_symbol => "$")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.down
|
|
9
|
+
Currency.usd.destroy
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# This migration comes from erp_forms (originally 20110608185830)
|
|
2
|
+
class CreateDefaultDynamicModelsAndForms
|
|
3
|
+
|
|
4
|
+
def self.up
|
|
5
|
+
#insert data here
|
|
6
|
+
DynamicFormModel.create(:model_name => 'DynamicFormDocument')
|
|
7
|
+
|
|
8
|
+
fields = []
|
|
9
|
+
|
|
10
|
+
fields << DynamicFormField.textfield({:fieldLabel => 'First Name', :name => 'first_name', :width => 250, :allowBlank => false })
|
|
11
|
+
fields << DynamicFormField.textfield({:fieldLabel => 'Last Name', :name => 'last_name', :width => 250, :allowBlank => false })
|
|
12
|
+
fields << DynamicFormField.email({:fieldLabel => 'Email', :name => 'email', :width => 250, :allowBlank => false })
|
|
13
|
+
fields << DynamicFormField.textarea({:fieldLabel => 'Message', :name => 'message', :width => 400, :height => 200, :allowBlank => false })
|
|
14
|
+
|
|
15
|
+
d = DynamicForm.new
|
|
16
|
+
d.description = 'Contact Form'
|
|
17
|
+
d.definition = fields.to_json
|
|
18
|
+
d.model_name = 'WebsiteInquiry'
|
|
19
|
+
d.internal_identifier = 'contact_us'
|
|
20
|
+
d.default = true
|
|
21
|
+
d.dynamic_form_model = DynamicFormModel.create(:model_name => 'WebsiteInquiry')
|
|
22
|
+
d.comment = "This is the default form used by Knitkit's Contact Us Widget for Website Inquiries. NOTE: The Contact Us Widget uses Knitkit's website configuration options for email behavior & not the Dynamic Forms Widget Action setting."
|
|
23
|
+
d.msg_target = 'qtip'
|
|
24
|
+
d.save
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.down
|
|
28
|
+
#remove data here
|
|
29
|
+
DynamicFormModel.delete_all
|
|
30
|
+
DynamicForm.delete_all
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# This migration comes from erp_base_erp_svcs (originally 20110609150135)
|
|
2
|
+
require 'yaml'
|
|
3
|
+
|
|
4
|
+
class AddIsoCodes
|
|
5
|
+
|
|
6
|
+
def self.up
|
|
7
|
+
#find the erp_base_erp_svcs engine
|
|
8
|
+
engine_path = Rails::Application::Railties.engines.find{|item| item.engine_name == 'erp_base_erp_svcs'}.config.root.to_s
|
|
9
|
+
|
|
10
|
+
GeoCountry.load_from_file(File.join(engine_path,'db/data_sets/geo_countries.yml'))
|
|
11
|
+
GeoZone.load_from_file(File.join(engine_path,'db/data_sets/geo_zones.yml'))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.down
|
|
15
|
+
GeoCountry.delete_all
|
|
16
|
+
GeoZone.delete_all
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# This migration comes from erp_app (originally 20110728201729)
|
|
2
|
+
class ErpAppSetup
|
|
3
|
+
|
|
4
|
+
def self.up
|
|
5
|
+
if(ContactPurpose.find_by_internal_identifier('default').nil?)
|
|
6
|
+
|
|
7
|
+
#######################################
|
|
8
|
+
#contact purposes
|
|
9
|
+
#######################################
|
|
10
|
+
[
|
|
11
|
+
{:description => 'Default', :internal_identifier => 'default'},
|
|
12
|
+
{:description => 'Home', :internal_identifier => 'home'},
|
|
13
|
+
{:description => 'Work', :internal_identifier => 'work'},
|
|
14
|
+
{:description => 'Billing', :internal_identifier => 'billing'},
|
|
15
|
+
{:description => 'Temporary', :internal_identifier => 'temporary'},
|
|
16
|
+
{:description => 'Tax Reporting', :internal_identifier => 'tax_reporting'},
|
|
17
|
+
{:description => 'Recruiting', :internal_identifier => 'recruiting'},
|
|
18
|
+
{:description => 'Employment Offer', :internal_identifier => 'employment_offer'},
|
|
19
|
+
{:description => 'Business', :internal_identifier => 'business'},
|
|
20
|
+
{:description => 'Personal', :internal_identifier => 'personal'},
|
|
21
|
+
{:description => 'Fax', :internal_identifier => 'fax'},
|
|
22
|
+
{:description => 'Mobile', :internal_identifier => 'mobile'},
|
|
23
|
+
{:description => 'Emergency', :internal_identifier => 'emergency'},
|
|
24
|
+
{:description => 'Shipping', :internal_identifier => 'shipping'},
|
|
25
|
+
{:description => 'Other', :internal_identifier => 'other'},
|
|
26
|
+
].each do |item|
|
|
27
|
+
contact_purpose = ContactPurpose.find_by_internal_identifier(item[:internal_identifier])
|
|
28
|
+
ContactPurpose.create(:description => item[:description], :internal_identifier => item[:internal_identifier]) if contact_purpose.nil?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
#######################################
|
|
32
|
+
#roles
|
|
33
|
+
#######################################
|
|
34
|
+
SecurityRole.create(:description => 'Admin', :internal_identifier => 'admin')
|
|
35
|
+
SecurityRole.create(:description => 'Employee', :internal_identifier => 'employee')
|
|
36
|
+
|
|
37
|
+
#######################################
|
|
38
|
+
#desktop setup
|
|
39
|
+
#######################################
|
|
40
|
+
#create preference types
|
|
41
|
+
desktop_backgroud_pt = PreferenceType.create(:description => 'Desktop Background', :internal_identifier => 'desktop_background')
|
|
42
|
+
extjs_theme_pt = PreferenceType.create(:description => 'Theme', :internal_identifier => 'extjs_theme')
|
|
43
|
+
desktop_shortcut_pt = PreferenceType.create(:description => 'Desktop Shortcut', :internal_identifier => 'desktop_shortcut')
|
|
44
|
+
auto_load_app_pt = PreferenceType.create(:description => 'Autoload Application', :internal_identifier => 'autoload_application')
|
|
45
|
+
|
|
46
|
+
#create preference options
|
|
47
|
+
#yes no options
|
|
48
|
+
yes_po = PreferenceOption.create(:description => 'Yes', :internal_identifier => 'yes', :value => 'yes')
|
|
49
|
+
no_po = PreferenceOption.create(:description => 'No', :internal_identifier => 'no', :value => 'no')
|
|
50
|
+
|
|
51
|
+
#desktop background options
|
|
52
|
+
truenorth_background_po = PreferenceOption.create(:description => 'TrueNorth Logo', :internal_identifier => 'truenorth_logo_background', :value => 'truenorth.png')
|
|
53
|
+
blue_background_po = PreferenceOption.create(:description => 'Blue', :internal_identifier => 'blue_desktop_background', :value => 'blue.gif')
|
|
54
|
+
gradient_background_po = PreferenceOption.create(:description => 'Grey Gradient', :internal_identifier => 'grey_gradient_desktop_background', :value => 'gradient.png')
|
|
55
|
+
purple_background_po = PreferenceOption.create(:description => 'Purple', :internal_identifier => 'purple_desktop_background', :value => 'purple.jpg')
|
|
56
|
+
planet_background_po = PreferenceOption.create(:description => 'Planet', :internal_identifier => 'planet_desktop_background', :value => 'planet.jpg')
|
|
57
|
+
portablemind_background_po = PreferenceOption.create(:description => 'Portablemind', :internal_identifier => 'portablemind_desktop_background', :value => 'portablemind.png')
|
|
58
|
+
|
|
59
|
+
#desktop theme options
|
|
60
|
+
access_extjs_theme_po = PreferenceOption.create(:description => 'Access', :internal_identifier => 'access_extjs_theme', :value => 'ext-all-access.css')
|
|
61
|
+
gray_extjs_theme_po = PreferenceOption.create(:description => 'Gray', :internal_identifier => 'gray_extjs_theme', :value => 'ext-all-gray.css')
|
|
62
|
+
blue_extjs_theme_po = PreferenceOption.create(:description => 'Blue', :internal_identifier => 'blue_extjs_theme', :value => 'ext-all.css')
|
|
63
|
+
|
|
64
|
+
#associate options
|
|
65
|
+
desktop_shortcut_pt.preference_options << yes_po
|
|
66
|
+
desktop_shortcut_pt.preference_options << no_po
|
|
67
|
+
desktop_shortcut_pt.default_preference_option = no_po
|
|
68
|
+
desktop_shortcut_pt.save
|
|
69
|
+
|
|
70
|
+
auto_load_app_pt.preference_options << yes_po
|
|
71
|
+
auto_load_app_pt.preference_options << no_po
|
|
72
|
+
auto_load_app_pt.default_preference_option = no_po
|
|
73
|
+
auto_load_app_pt.save
|
|
74
|
+
|
|
75
|
+
desktop_backgroud_pt.preference_options << blue_background_po
|
|
76
|
+
desktop_backgroud_pt.preference_options << truenorth_background_po
|
|
77
|
+
desktop_backgroud_pt.preference_options << gradient_background_po
|
|
78
|
+
desktop_backgroud_pt.preference_options << purple_background_po
|
|
79
|
+
desktop_backgroud_pt.preference_options << planet_background_po
|
|
80
|
+
desktop_backgroud_pt.preference_options << portablemind_background_po
|
|
81
|
+
desktop_backgroud_pt.default_preference_option = truenorth_background_po
|
|
82
|
+
desktop_backgroud_pt.save
|
|
83
|
+
|
|
84
|
+
extjs_theme_pt.preference_options << access_extjs_theme_po
|
|
85
|
+
extjs_theme_pt.preference_options << gray_extjs_theme_po
|
|
86
|
+
extjs_theme_pt.preference_options << blue_extjs_theme_po
|
|
87
|
+
extjs_theme_pt.default_preference_option = blue_extjs_theme_po
|
|
88
|
+
extjs_theme_pt.save
|
|
89
|
+
|
|
90
|
+
#######################################
|
|
91
|
+
#notes widget
|
|
92
|
+
#######################################
|
|
93
|
+
NoteType.create(:description => 'Basic Note', :internal_identifier => 'basic_note')
|
|
94
|
+
|
|
95
|
+
notes_grid = ::Widget.create(
|
|
96
|
+
:description => 'Notes',
|
|
97
|
+
:icon => 'icon-documents',
|
|
98
|
+
:xtype => 'shared_notesgrid',
|
|
99
|
+
:internal_identifier => 'shared_notes_grid'
|
|
100
|
+
)
|
|
101
|
+
notes_grid.save
|
|
102
|
+
|
|
103
|
+
#######################################
|
|
104
|
+
#user management app
|
|
105
|
+
#######################################
|
|
106
|
+
app_mgr = ::Widget.create(
|
|
107
|
+
:description => 'Application Management',
|
|
108
|
+
:icon => 'icon-user',
|
|
109
|
+
:xtype => 'controlpanel_userapplicationmgtpanel',
|
|
110
|
+
:internal_identifier => 'application_management'
|
|
111
|
+
)
|
|
112
|
+
app_mgr.save
|
|
113
|
+
|
|
114
|
+
role_mgr = ::Widget.create(
|
|
115
|
+
:description => 'Role Management',
|
|
116
|
+
:icon => 'icon-user',
|
|
117
|
+
:xtype => 'usermanagement_rolemanagementpanel',
|
|
118
|
+
:internal_identifier => 'role_management'
|
|
119
|
+
)
|
|
120
|
+
role_mgr.save
|
|
121
|
+
|
|
122
|
+
personal_info = ::Widget.create(
|
|
123
|
+
:description => 'User Personal Info',
|
|
124
|
+
:icon => 'icon-user',
|
|
125
|
+
:xtype => 'usermanagement_personalinfopanel',
|
|
126
|
+
:internal_identifier => 'user_personal_info'
|
|
127
|
+
)
|
|
128
|
+
personal_info.save
|
|
129
|
+
|
|
130
|
+
#create application and assign widgets
|
|
131
|
+
user_mgr_app = DesktopApplication.create(
|
|
132
|
+
:description => 'User Management',
|
|
133
|
+
:icon => 'icon-user',
|
|
134
|
+
:javascript_class_name => 'Compass.ErpApp.Desktop.Applications.UserManagement',
|
|
135
|
+
:internal_identifier => 'user_management',
|
|
136
|
+
:shortcut_id => 'user-management-win'
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
user_mgr_app.preference_types << desktop_shortcut_pt
|
|
140
|
+
user_mgr_app.preference_types << auto_load_app_pt
|
|
141
|
+
|
|
142
|
+
user_mgr_app.widgets << role_mgr
|
|
143
|
+
user_mgr_app.widgets << personal_info
|
|
144
|
+
user_mgr_app.widgets << app_mgr
|
|
145
|
+
user_mgr_app.widgets << notes_grid
|
|
146
|
+
user_mgr_app.save
|
|
147
|
+
|
|
148
|
+
#######################################
|
|
149
|
+
#scaffold app
|
|
150
|
+
#######################################
|
|
151
|
+
scaffold_app = DesktopApplication.create(
|
|
152
|
+
:description => 'Scaffold',
|
|
153
|
+
:icon => 'icon-data',
|
|
154
|
+
:javascript_class_name => 'Compass.ErpApp.Desktop.Applications.Scaffold',
|
|
155
|
+
:internal_identifier => 'scaffold',
|
|
156
|
+
:shortcut_id => 'scaffold-win'
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
scaffold_app.preference_types << PreferenceType.iid('desktop_shortcut')
|
|
160
|
+
scaffold_app.preference_types << PreferenceType.iid('autoload_application')
|
|
161
|
+
scaffold_app.save
|
|
162
|
+
|
|
163
|
+
#######################################
|
|
164
|
+
#organizer setup
|
|
165
|
+
#######################################
|
|
166
|
+
|
|
167
|
+
party_contact_mgm_widget = ::Widget.create(
|
|
168
|
+
:description => 'Party Contact Management',
|
|
169
|
+
:icon => 'icon-grid',
|
|
170
|
+
:xtype => 'contactmechanismgrid',
|
|
171
|
+
:internal_identifier => 'party_contact_management'
|
|
172
|
+
)
|
|
173
|
+
party_contact_mgm_widget.save
|
|
174
|
+
|
|
175
|
+
party_mgm_widget = ::Widget.create(
|
|
176
|
+
:description => 'Party Management',
|
|
177
|
+
:icon => 'icon-grid',
|
|
178
|
+
:xtype => 'partygrid',
|
|
179
|
+
:internal_identifier => 'party_management_widget'
|
|
180
|
+
)
|
|
181
|
+
party_mgm_widget.save
|
|
182
|
+
|
|
183
|
+
#create application
|
|
184
|
+
crm_app = OrganizerApplication.create(
|
|
185
|
+
:description => 'CRM',
|
|
186
|
+
:icon => 'icon-user',
|
|
187
|
+
:internal_identifier => 'crm'
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
crm_app.widgets << party_contact_mgm_widget
|
|
191
|
+
crm_app.widgets << party_mgm_widget
|
|
192
|
+
crm_app.widgets << notes_grid
|
|
193
|
+
crm_app.save
|
|
194
|
+
|
|
195
|
+
#######################################
|
|
196
|
+
#parties
|
|
197
|
+
#######################################
|
|
198
|
+
|
|
199
|
+
#Admins
|
|
200
|
+
Individual.create(:current_first_name => 'Admin',:current_last_name => 'Istrator',:gender => 'm')
|
|
201
|
+
|
|
202
|
+
#Organization
|
|
203
|
+
Organization.create(:description => 'TrueNorth')
|
|
204
|
+
|
|
205
|
+
#######################################
|
|
206
|
+
#users
|
|
207
|
+
#######################################
|
|
208
|
+
admin_indvidual = Individual.where('current_first_name = ?',"Admin").first
|
|
209
|
+
admin_user = User.create(
|
|
210
|
+
:username => "admin",
|
|
211
|
+
:email => "admin@portablemind.com"
|
|
212
|
+
)
|
|
213
|
+
admin_user.password = 'password'
|
|
214
|
+
admin_user.password_confirmation = 'password'
|
|
215
|
+
admin_user.party = admin_indvidual.party
|
|
216
|
+
admin_user.activate!
|
|
217
|
+
admin_user.save
|
|
218
|
+
admin_user.add_role('admin')
|
|
219
|
+
admin_user.save
|
|
220
|
+
|
|
221
|
+
truenorth = Organization.where('description = ?', 'TrueNorth').first
|
|
222
|
+
truenorth_user = User.create(
|
|
223
|
+
:username => truenorth.description.downcase,
|
|
224
|
+
:email => "#{truenorth.description.downcase}@gmail.com"
|
|
225
|
+
)
|
|
226
|
+
truenorth_user.password = 'password'
|
|
227
|
+
truenorth_user.password_confirmation = 'password'
|
|
228
|
+
truenorth_user.party = truenorth.party
|
|
229
|
+
truenorth_user.save
|
|
230
|
+
truenorth_user.activate!
|
|
231
|
+
truenorth_user.add_role('admin')
|
|
232
|
+
truenorth_user.save
|
|
233
|
+
|
|
234
|
+
admin_user.desktop.applications << user_mgr_app
|
|
235
|
+
admin_user.desktop.applications << scaffold_app
|
|
236
|
+
admin_user.desktop.save
|
|
237
|
+
admin_user.organizer.applications << crm_app
|
|
238
|
+
admin_user.organizer.save
|
|
239
|
+
|
|
240
|
+
truenorth_user.desktop.applications << user_mgr_app
|
|
241
|
+
truenorth_user.desktop.applications << scaffold_app
|
|
242
|
+
truenorth_user.desktop.save
|
|
243
|
+
truenorth_user.organizer.applications << crm_app
|
|
244
|
+
truenorth_user.organizer.save
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def self.down
|
|
249
|
+
#remove data here
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
end
|