erp_app 3.1.11 → 3.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/app/controllers/erp_app/desktop/tail/base_controller.rb +33 -0
  2. data/config/routes.rb +3 -0
  3. data/db/data_migrations/20130703181549_create_tail_desktop_application.rb +22 -0
  4. data/lib/erp_app/version.rb +1 -1
  5. data/public/javascripts/erp_app/desktop/applications/tail/module.js +36 -0
  6. data/public/javascripts/erp_app/desktop/applications/tail/tail_panel.js +145 -0
  7. data/public/javascripts/erp_app/mobile/applications/job_tracker/view/templates.js +16 -16
  8. data/public/stylesheets/erp_app/shared/compass-ext-all.css +5 -0
  9. data/spec/dummy/db/data_migrations/20130422163128_add_usd_currency.erp_base_erp_svcs.rb +12 -0
  10. data/spec/dummy/db/data_migrations/20130422163129_add_iso_codes.erp_base_erp_svcs.rb +19 -0
  11. data/spec/dummy/db/data_migrations/20130422163130_setup_compass_ae_instance.erp_base_erp_svcs.rb +21 -0
  12. data/spec/dummy/db/data_migrations/20130422163131_upgrade_compass_ae_instances_data.erp_base_erp_svcs.rb +19 -0
  13. data/spec/dummy/db/data_migrations/20130422163132_add_guid_to_instances.erp_base_erp_svcs.rb +10 -0
  14. data/spec/dummy/db/data_migrations/20130422163133_create_capability_scope_types.erp_tech_svcs.rb +15 -0
  15. data/spec/dummy/db/data_migrations/20130422163134_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +16 -0
  16. data/spec/dummy/db/data_migrations/20130422163135_setup_audit_log_types.erp_tech_svcs.rb +22 -0
  17. data/spec/dummy/db/data_migrations/20130422163136_create_group_relationship_and_role_types.erp_tech_svcs.rb +20 -0
  18. data/spec/dummy/db/data_migrations/20130422163137_note_capabilities.erp_tech_svcs.rb +24 -0
  19. data/spec/dummy/db/data_migrations/20130422163138_erp_app_setup.erp_app.rb +252 -0
  20. data/spec/dummy/db/data_migrations/20130422163139_update_preferences.erp_app.rb +53 -0
  21. data/spec/dummy/db/data_migrations/20130422163140_create_desktop_app_audit_log_viewer.erp_app.rb +24 -0
  22. data/spec/dummy/db/data_migrations/20130422163141_add_file_manager_application.erp_app.rb +32 -0
  23. data/spec/dummy/db/data_migrations/20130422163142_add_default_capabilities.erp_app.rb +23 -0
  24. data/spec/dummy/db/data_migrations/20130422163143_add_new_contact_widgets.erp_app.rb +42 -0
  25. data/spec/dummy/db/data_migrations/20130422163144_add_userinfo_widget.erp_app.rb +29 -0
  26. data/spec/dummy/db/data_migrations/20130422163145_create_party_and_role_type_for_communication_events.erp_app.rb +11 -0
  27. data/spec/dummy/db/data_migrations/20130422163146_create_user_management_mobile_application.erp_app.rb +17 -0
  28. data/spec/dummy/db/data_migrations/20130422163147_create_configuration_management_desktop_application.erp_app.rb +27 -0
  29. data/spec/dummy/db/data_migrations/20130422163148_create_job_tracker_desktop_application.erp_app.rb +23 -0
  30. data/spec/dummy/db/data_migrations/20130422163149_created_tracked_jobs.erp_app.rb +15 -0
  31. data/spec/dummy/db/data_migrations/20130422163150_upgrade_remove_system_mgmt_app.erp_app.rb +16 -0
  32. data/spec/dummy/db/data_migrations/20130422163151_create_security_management_desktop_application.erp_app.rb +29 -0
  33. data/spec/dummy/db/data_migrations/20130422163152_add_job_tracker_mobile_app.erp_app.rb +17 -0
  34. data/spec/dummy/db/migrate/20130422163121_base_erp_services.erp_base_erp_svcs.rb +486 -0
  35. data/spec/dummy/db/migrate/20130422163122_add_txn_status.erp_base_erp_svcs.rb +37 -0
  36. data/spec/dummy/db/migrate/20130422163123_upgrade_compass_ae_instances.erp_base_erp_svcs.rb +34 -0
  37. data/spec/dummy/db/migrate/20130422163124_add_uuid_compass_ae_instance.erp_base_erp_svcs.rb +17 -0
  38. data/spec/dummy/db/migrate/20130422163125_add_long_lat_to_address.erp_base_erp_svcs.rb +16 -0
  39. data/spec/dummy/db/migrate/20130422163126_base_tech_services.erp_tech_svcs.rb +271 -0
  40. data/spec/dummy/db/migrate/20130422163127_create_has_attribute_tables.erp_tech_svcs.rb +39 -0
  41. data/spec/dummy/db/migrate/20130422163128_create_groups.erp_tech_svcs.rb +19 -0
  42. data/spec/dummy/db/migrate/20130422163129_upgrade_security.erp_tech_svcs.rb +54 -0
  43. data/spec/dummy/db/migrate/20130422163130_upgrade_security2.erp_tech_svcs.rb +275 -0
  44. data/spec/dummy/db/migrate/20130422163131_add_queue_to_delayed_jobs.erp_tech_svcs.rb +14 -0
  45. data/spec/dummy/db/migrate/20130422163132_base_app_framework.erp_app.rb +276 -0
  46. data/spec/dummy/db/migrate/20130422163133_add_job_tracker.erp_app.rb +20 -0
  47. data/spec/dummy/db/migrate/20130422163134_update_mobile_application.erp_app.rb +28 -0
  48. data/spec/dummy/db/schema.rb +883 -0
  49. data/spec/dummy/db/spec.sqlite3 +0 -0
  50. metadata +89 -3
@@ -0,0 +1,271 @@
1
+ # This migration comes from erp_tech_svcs (originally 20080805000010)
2
+ class BaseTechServices < ActiveRecord::Migration
3
+ def self.up
4
+ unless table_exists?(:users)
5
+ # Create the users table
6
+ create_table :users do |t|
7
+ t.string :username
8
+ t.string :email
9
+ t.references :party
10
+ t.string :type
11
+ t.string :salt, :default => nil
12
+ t.string :crypted_password, :default => nil
13
+
14
+ #activity logging
15
+ t.datetime :last_login_at, :default => nil
16
+ t.datetime :last_logout_at, :default => nil
17
+ t.datetime :last_activity_at, :default => nil
18
+
19
+ #brute force protection
20
+ t.integer :failed_logins_count, :default => 0
21
+ t.datetime :lock_expires_at, :default => nil
22
+
23
+ #remember me
24
+ t.string :remember_me_token, :default => nil
25
+ t.datetime :remember_me_token_expires_at, :default => nil
26
+
27
+ #reset password
28
+ t.string :reset_password_token, :default => nil
29
+ t.datetime :reset_password_token_expires_at, :default => nil
30
+ t.datetime :reset_password_email_sent_at, :default => nil
31
+
32
+ #user activation
33
+ t.string :activation_state, :default => nil
34
+ t.string :activation_token, :default => nil
35
+ t.datetime :activation_token_expires_at, :default => nil
36
+
37
+ t.string :security_question_1
38
+ t.string :security_answer_1
39
+ t.string :security_question_2
40
+ t.string :security_answer_2
41
+
42
+ t.timestamps
43
+ end
44
+ add_index :users, :email, :unique => true
45
+ add_index :users, :username, :unique => true
46
+ add_index :users, [:last_logout_at, :last_activity_at], :name => 'activity_idx'
47
+ add_index :users, :remember_me_token
48
+ add_index :users, :reset_password_token
49
+ add_index :users, :activation_token
50
+
51
+ end
52
+
53
+ unless table_exists?(:groups)
54
+ create_table :groups do |t|
55
+ t.column :description, :string
56
+ t.timestamps
57
+ end
58
+ end
59
+
60
+ unless table_exists?(:security_roles)
61
+ # create the roles table
62
+ create_table :security_roles do |t|
63
+ t.column :description, :string
64
+ t.column :internal_identifier, :string
65
+ t.column :external_identifier, :string
66
+ t.column :external_id_source, :string
67
+
68
+ t.timestamps
69
+ end
70
+ end
71
+
72
+ unless table_exists?(:sessions)
73
+ # Create sessions table
74
+ create_table :sessions do |t|
75
+ t.string :session_id, :null => false
76
+ t.text :data
77
+ t.timestamps
78
+ end
79
+ add_index :sessions, :session_id
80
+ add_index :sessions, :updated_at
81
+ end
82
+
83
+ unless table_exists?(:audit_logs)
84
+ # Create audit_logs
85
+ create_table :audit_logs do |t|
86
+ t.string :application
87
+ t.string :description
88
+ t.integer :party_id
89
+ t.text :additional_info
90
+ t.references :audit_log_type
91
+
92
+ #polymorphic columns
93
+ t.references :event_record, :polymorphic => true
94
+
95
+ t.timestamps
96
+ end
97
+ add_index :audit_logs, :party_id
98
+ add_index :audit_logs, [:event_record_id, :event_record_type], :name => 'event_record_index'
99
+ end
100
+
101
+ unless table_exists?(:audit_log_types)
102
+ # Create audit_logs
103
+ create_table :audit_log_types do |t|
104
+ t.string :description
105
+ t.string :error_code
106
+ t.string :comments
107
+ t.string :internal_identifier
108
+ t.string :external_identifier
109
+ t.string :external_id_source
110
+
111
+ #better nested set columns
112
+ t.integer :parent_id
113
+ t.integer :lft
114
+ t.integer :rgt
115
+
116
+ t.timestamps
117
+ end
118
+ end
119
+
120
+ unless table_exists?(:audit_log_items)
121
+ # Create audit_log_items
122
+ create_table :audit_log_items do |t|
123
+ t.references :audit_log
124
+ t.references :audit_log_item_type
125
+ t.string :audit_log_item_value
126
+ t.string :description
127
+
128
+ t.timestamps
129
+ end
130
+ end
131
+
132
+ unless table_exists?(:audit_log_item_types)
133
+ # Create audit_log_item_types
134
+ create_table :audit_log_item_types do |t|
135
+ t.string :internal_identifier
136
+ t.string :external_identifier
137
+ t.string :external_id_source
138
+ t.string :description
139
+ t.string :comments
140
+
141
+ #better nested set columns
142
+ t.integer :parent_id
143
+ t.integer :lft
144
+ t.integer :rgt
145
+
146
+ t.timestamps
147
+ end
148
+ end
149
+
150
+ unless table_exists?(:file_assets)
151
+ create_table :file_assets do |t|
152
+ t.references :file_asset_holder, :polymorphic => true
153
+ t.string :type
154
+ t.string :name
155
+ t.string :directory
156
+ t.string :data_file_name
157
+ t.string :data_content_type
158
+ t.integer :data_file_size
159
+ t.datetime :data_updated_at
160
+ t.string :width
161
+ t.string :height
162
+
163
+ t.timestamps
164
+ end
165
+ add_index :file_assets, :type
166
+ add_index :file_assets, [:file_asset_holder_id, :file_asset_holder_type], :name => 'file_asset_holder_idx'
167
+ add_index :file_assets, :name
168
+ add_index :file_assets, :directory
169
+ end
170
+
171
+ unless table_exists?(:delayed_jobs)
172
+ create_table :delayed_jobs, :force => true do |table|
173
+ table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
174
+ table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
175
+ table.text :handler # YAML-encoded string of the object that will do work
176
+ table.text :last_error # reason for last failure (See Note below)
177
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
178
+ table.datetime :locked_at # Set when a client is working on this object
179
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
180
+ table.string :locked_by # Who is working on this object (if locked)
181
+ table.string :queue
182
+ table.timestamps
183
+ end
184
+ add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
185
+ end
186
+
187
+ unless table_exists?(:capable_models)
188
+ # create the roles table
189
+ create_table :capable_models do |t|
190
+ t.references :capable_model_record, :polymorphic => true
191
+
192
+ t.timestamps
193
+ end
194
+
195
+ add_index :capable_models, [:capable_model_record_id, :capable_model_record_type], :name => 'capable_model_record_idx'
196
+ end
197
+
198
+ unless table_exists?(:capability_types)
199
+ # create the roles table
200
+ create_table :capability_types do |t|
201
+ t.string :internal_identifier
202
+ t.string :description
203
+ t.timestamps
204
+ end
205
+ end
206
+
207
+ unless table_exists?(:capabilities)
208
+ # create the roles table
209
+ create_table :capabilities do |t|
210
+ t.string :description
211
+ t.references :capability_type
212
+ t.string :capability_resource_type
213
+ t.integer :capability_resource_id
214
+ t.integer :scope_type_id
215
+ t.text :scope_query
216
+ t.timestamps
217
+ end
218
+
219
+ add_index :capabilities, :capability_type_id
220
+ add_index :capabilities, :scope_type_id
221
+ add_index :capabilities, [:capability_resource_id, :capability_resource_type], :name => 'capability_resource_index'
222
+ end
223
+
224
+ unless table_exists?(:capability_accessors)
225
+ create_table :capability_accessors do |t|
226
+ t.string :capability_accessor_record_type
227
+ t.integer :capability_accessor_record_id
228
+ t.integer :capability_id
229
+ t.timestamps
230
+ end
231
+
232
+ add_index :capability_accessors, :capability_id
233
+ add_index :capability_accessors, [:capability_accessor_record_id, :capability_accessor_record_type], :name => 'capability_accessor_record_index'
234
+ end
235
+
236
+ unless table_exists?(:scope_types)
237
+ create_table :scope_types do |t|
238
+ t.string :description
239
+ t.string :internal_identifier
240
+ t.timestamps
241
+ end
242
+
243
+ add_index :scope_types, :internal_identifier
244
+ end
245
+
246
+ unless table_exists?(:parties_security_roles)
247
+ create_table :parties_security_roles, :id => false do |t|
248
+ t.integer :party_id
249
+ t.integer :security_role_id
250
+ end
251
+
252
+ add_index :parties_security_roles, :party_id
253
+ add_index :parties_security_roles, :security_role_id
254
+ end
255
+
256
+ end
257
+
258
+ def self.down
259
+ # check that each table exists before trying to delete it.
260
+ [ :groups,
261
+ :audit_logs, :sessions, :simple_captcha_data,
262
+ :capability_accessors, :capability_types, :capabilities,:scope_types,
263
+ :parties_security_roles, :roles, :audit_log_items, :audit_log_item_types,
264
+ :users, :file_assets, :delayed_jobs
265
+ ].each do |tbl|
266
+ if table_exists?(tbl)
267
+ drop_table tbl
268
+ end
269
+ end
270
+ end
271
+ end
@@ -0,0 +1,39 @@
1
+ # This migration comes from erp_tech_svcs (originally 20111117183144)
2
+ class CreateHasAttributeTables < ActiveRecord::Migration
3
+ def up
4
+ unless table_exists?(:attribute_types)
5
+ create_table :attribute_types do |t|
6
+ t.string :internal_identifier
7
+ t.string :description
8
+ t.string :data_type
9
+
10
+ t.timestamps
11
+ end
12
+
13
+ add_index :attribute_types, :internal_identifier, :name => ':attribute_types_iid_idx'
14
+ end
15
+ unless table_exists?(:attribute_values)
16
+ create_table :attribute_values do |t|
17
+ t.integer :attributed_record_id
18
+ t.string :attributed_record_type
19
+ t.references :attribute_type
20
+ t.string :value
21
+
22
+ t.timestamps
23
+ end
24
+
25
+ add_index :attribute_values, [:attributed_record_id, :attributed_record_type], :name => 'attribute_values_attributed_record_idx'
26
+ add_index :attribute_values, :attribute_type_id, :name => 'attribute_values_attributed_type_idx'
27
+ add_index :attribute_values, :value, :name => 'attribute_values_value_idx'
28
+ end
29
+ end
30
+
31
+ def down
32
+ if table_exists?(:attribute_types)
33
+ drop_table :attribute_types
34
+ end
35
+ if table_exists?(:attribute_values)
36
+ drop_table :attribute_values
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ # This migration comes from erp_tech_svcs (originally 20121116151510)
2
+ class CreateGroups < ActiveRecord::Migration
3
+ def self.up
4
+ unless table_exists?(:groups)
5
+ create_table :groups do |t|
6
+ t.column :description, :string
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ [ :groups ].each do |tbl|
14
+ if table_exists?(tbl)
15
+ drop_table tbl
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,54 @@
1
+ # This migration comes from erp_tech_svcs (originally 20121126171612)
2
+ class UpgradeSecurity < ActiveRecord::Migration
3
+
4
+ def self.up
5
+ unless table_exists?(:capability_accessors)
6
+ create_table :capability_accessors do |t|
7
+ t.string :capability_accessor_record_type
8
+ t.integer :capability_accessor_record_id
9
+ t.integer :capability_id
10
+ t.timestamps
11
+ end
12
+
13
+ add_index :capability_accessors, :capability_id
14
+ add_index :capability_accessors, [:capability_accessor_record_id, :capability_accessor_record_type], :name => 'capability_accessor_record_index'
15
+ end
16
+
17
+ unless columns(:capabilities).collect {|c| c.name}.include?('scope_query')
18
+ add_column :capabilities, :description, :string
19
+ add_column :capabilities, :capability_resource_type, :string
20
+ add_column :capabilities, :capability_resource_id, :integer
21
+ add_column :capabilities, :scope_type_id, :integer
22
+ add_column :capabilities, :scope_query, :text
23
+
24
+ add_index :capabilities, :scope_type_id
25
+ add_index :capabilities, [:capability_resource_id, :capability_resource_type], :name => 'capability_resource_index'
26
+ end
27
+
28
+ unless table_exists?(:scope_types)
29
+ create_table :scope_types do |t|
30
+ t.string :description
31
+ t.string :internal_identifier
32
+ t.timestamps
33
+ end
34
+
35
+ add_index :scope_types, :internal_identifier
36
+ end
37
+
38
+ unless table_exists?(:parties_security_roles)
39
+ create_table :parties_security_roles, :id => false do |t|
40
+ t.integer :party_id
41
+ t.integer :security_role_id
42
+ end
43
+
44
+ add_index :parties_security_roles, :party_id
45
+ add_index :parties_security_roles, :security_role_id
46
+ end
47
+
48
+ rename_table :roles, :security_roles unless table_exists?(:security_roles)
49
+
50
+ end
51
+
52
+ def self.down
53
+ end
54
+ end
@@ -0,0 +1,275 @@
1
+ # This migration comes from erp_tech_svcs (originally 20121126173506)
2
+ class UpgradeSecurity2 < ActiveRecord::Migration
3
+ def self.up
4
+ if table_exists?(:secured_models)
5
+ Website.all.each do |w|
6
+ old_role_iid = "website_#{w.name.underscore.gsub("'","").gsub(",","")}_access"
7
+
8
+ r = SecurityRole.find_by_internal_identifier(old_role_iid)
9
+ unless r.nil?
10
+ r.internal_identifier = w.website_role_iid
11
+ r.save
12
+ end
13
+ end
14
+ instance = ScopeType.create(:description => 'Instance', :internal_identifier => 'instance')
15
+ class_scope_type = ScopeType.create(:description => 'Class', :internal_identifier => 'class')
16
+ ScopeType.create(:description => 'Query', :internal_identifier => 'query')
17
+
18
+ execute('BEGIN TRANSACTION')
19
+ puts "populating parties_security_roles"
20
+ sql =
21
+ "INSERT INTO parties_security_roles (
22
+ party_id,
23
+ security_role_id
24
+ )
25
+ SELECT
26
+ u.party_id AS party_id,
27
+ rsm.role_id AS security_role_id
28
+ FROM secured_models sm
29
+ JOIN roles_secured_models rsm ON sm.id=rsm.secured_model_id
30
+ JOIN users u ON sm.secured_record_id=u.id
31
+ WHERE sm.secured_record_type='User'"
32
+
33
+ execute(sql)
34
+ execute('COMMIT')
35
+
36
+ execute('BEGIN TRANSACTION')
37
+ puts "populating capabilities with secure File Assets"
38
+ sql =
39
+ "INSERT INTO capabilities (
40
+ capability_type_id,
41
+ capability_resource_type,
42
+ capability_resource_id,
43
+ scope_type_id
44
+ )
45
+ SELECT
46
+ c.capability_type_id AS capability_type_id,
47
+ 'FileAsset' AS capability_resource_type,
48
+ cm.capable_model_record_id AS capability_resource_id,
49
+ #{instance.id} AS scope_type_id
50
+ FROM capable_models AS cm
51
+ JOIN capabilities_capable_models AS ccm ON ccm.capable_model_id = cm.id
52
+ JOIN capabilities AS c ON ccm.capability_id = c.id
53
+ JOIN secured_models AS sm ON sm.secured_record_id = c.id AND sm.secured_record_type = 'Capability'
54
+ JOIN roles_secured_models AS rsm ON rsm.secured_model_id = sm.id
55
+ JOIN security_roles AS r ON r.id = rsm.role_id
56
+ WHERE cm.capable_model_record_type = 'FileAsset'"
57
+
58
+ execute(sql)
59
+ execute('COMMIT')
60
+
61
+ view = CapabilityType.find_by_internal_identifier('view')
62
+
63
+ execute('BEGIN TRANSACTION')
64
+ puts "populating capabilities with secure Website Sections"
65
+ sql =
66
+ "INSERT INTO capabilities (
67
+ capability_type_id,
68
+ capability_resource_type,
69
+ capability_resource_id,
70
+ scope_type_id
71
+ )
72
+ SELECT
73
+ #{view.id} AS capability_type_id,
74
+ 'WebsiteSection' AS capability_resource_type,
75
+ ws.id AS capability_resource_id,
76
+ #{instance.id} AS scope_type_id
77
+ FROM secured_models sm
78
+ JOIN roles_secured_models rsm ON sm.id=rsm.secured_model_id
79
+ JOIN website_sections ws ON sm.secured_record_id=ws.id
80
+ WHERE sm.secured_record_type='WebsiteSection'"
81
+
82
+ execute(sql)
83
+ execute('COMMIT')
84
+
85
+ execute('BEGIN TRANSACTION')
86
+ puts "populating capabilities with secure Website Nav Items"
87
+ sql =
88
+ "INSERT INTO capabilities (
89
+ capability_type_id,
90
+ capability_resource_type,
91
+ capability_resource_id,
92
+ scope_type_id
93
+ )
94
+ SELECT
95
+ #{view.id} AS capability_type_id,
96
+ 'WebsiteNavItem' AS capability_resource_type,
97
+ ws.id AS capability_resource_id,
98
+ #{instance.id} AS scope_type_id
99
+ FROM secured_models sm
100
+ JOIN roles_secured_models rsm ON sm.id=rsm.secured_model_id
101
+ JOIN website_sections ws ON sm.secured_record_id=ws.id
102
+ WHERE sm.secured_record_type='WebsiteNavItem'"
103
+
104
+ execute(sql)
105
+ execute('COMMIT')
106
+
107
+ # delete obsolete records: Application, Widget, dupes?
108
+ Capability.where("capability_resource_type IS NULL").delete_all
109
+
110
+ admin = SecurityRole.find_by_internal_identifier('admin')
111
+ website_author = SecurityRole.find_by_internal_identifier('website_author')
112
+ layout_author = SecurityRole.find_by_internal_identifier('layout_author')
113
+ content_author = SecurityRole.find_by_internal_identifier('content_author')
114
+ designer = SecurityRole.find_by_internal_identifier('designer')
115
+ publisher = SecurityRole.find_by_internal_identifier('publisher')
116
+
117
+ # add instance capabilities to roles
118
+ instance_capabilities = Capability.where(:scope_type_id => instance.id).all
119
+ instance_capabilities.each do |c|
120
+ case c.capability_resource_type
121
+ when 'FileAsset'
122
+ admin.add_capability(c)
123
+ website_author.add_capability(c)
124
+ content_author.add_capability(c)
125
+ if c.capability_resource.file_asset_holder_type == 'Website'
126
+ website_role = c.capability_resource.file_asset_holder.role
127
+ website_role.add_capability(c)
128
+ end
129
+ when 'WebsiteSection'
130
+ admin.add_capability(c)
131
+ website_author.add_capability(c)
132
+ website_role = c.capability_resource.website.role
133
+ website_role.add_capability(c)
134
+ when 'WebsiteNavItem'
135
+ admin.add_capability(c)
136
+ website_author.add_capability(c)
137
+ website_role = c.capability_resource.website_nav.website.role
138
+ website_role.add_capability(c)
139
+ end
140
+ end
141
+
142
+ # adding user mgmt capabilities to admin role
143
+ admin.add_capability('create', 'User')
144
+ admin.add_capability('delete', 'User')
145
+ admin.add_capability('edit', 'User')
146
+
147
+ # add knitkit class capabilities to roles
148
+ admin.add_capability('create', 'WebsiteNav')
149
+ admin.add_capability('delete', 'WebsiteNav')
150
+ admin.add_capability('edit', 'WebsiteNav')
151
+
152
+ website_author.add_capability('create', 'WebsiteNav')
153
+ website_author.add_capability('delete', 'WebsiteNav')
154
+ website_author.add_capability('edit', 'WebsiteNav')
155
+
156
+ admin.add_capability('create', 'Website')
157
+ admin.add_capability('delete', 'Website')
158
+ admin.add_capability('edit', 'Website')
159
+ admin.add_capability('import', 'Website')
160
+ admin.add_capability('publish', 'Website')
161
+ admin.add_capability('activate', 'Website')
162
+
163
+ website_author.add_capability('create', 'Website')
164
+ website_author.add_capability('delete', 'Website')
165
+ website_author.add_capability('edit', 'Website')
166
+ website_author.add_capability('import', 'Website')
167
+ publisher.add_capability('publish', 'Website')
168
+ publisher.add_capability('activate', 'Website')
169
+
170
+ admin.add_capability('create', 'WebsiteHost')
171
+ admin.add_capability('delete', 'WebsiteHost')
172
+ admin.add_capability('edit', 'WebsiteHost')
173
+
174
+ website_author.add_capability('create', 'WebsiteHost')
175
+ website_author.add_capability('delete', 'WebsiteHost')
176
+ website_author.add_capability('edit', 'WebsiteHost')
177
+
178
+ admin.add_capability('create', 'WebsiteSection')
179
+ admin.add_capability('delete', 'WebsiteSection')
180
+ admin.add_capability('edit', 'WebsiteSection')
181
+ admin.add_capability('secure', 'WebsiteSection')
182
+ admin.add_capability('unsecure', 'WebsiteSection')
183
+
184
+ website_author.add_capability('create', 'WebsiteSection')
185
+ website_author.add_capability('delete', 'WebsiteSection')
186
+ website_author.add_capability('edit', 'WebsiteSection')
187
+ website_author.add_capability('secure', 'WebsiteSection')
188
+ website_author.add_capability('unsecure', 'WebsiteSection')
189
+
190
+ admin.add_capability('create', 'WebsiteSectionLayout')
191
+ admin.add_capability('edit', 'WebsiteSectionLayout')
192
+
193
+ layout_author.add_capability('create', 'WebsiteSectionLayout')
194
+ layout_author.add_capability('edit', 'WebsiteSectionLayout')
195
+
196
+ admin.add_capability('create', 'Content')
197
+ admin.add_capability('delete', 'Content')
198
+ admin.add_capability('edit', 'Content')
199
+ admin.add_capability('publish', 'Content')
200
+ admin.add_capability('revert_version', 'Content')
201
+ admin.add_capability('add_existing', 'Content')
202
+ admin.add_capability('edit_html', 'Content')
203
+ admin.add_capability('edit_excerpt', 'Content')
204
+
205
+ content_author.add_capability('create', 'Content')
206
+ content_author.add_capability('delete', 'Content')
207
+ content_author.add_capability('edit', 'Content')
208
+ content_author.add_capability('publish', 'Content')
209
+ content_author.add_capability('revert_version', 'Content')
210
+ content_author.add_capability('add_existing', 'Content')
211
+ content_author.add_capability('edit_html', 'Content')
212
+ content_author.add_capability('edit_excerpt', 'Content')
213
+
214
+ admin.add_capability('create', 'WebsiteNavItem')
215
+ admin.add_capability('delete', 'WebsiteNavItem')
216
+ admin.add_capability('edit', 'WebsiteNavItem')
217
+ admin.add_capability('secure', 'WebsiteNavItem')
218
+ admin.add_capability('unsecure', 'WebsiteNavItem')
219
+
220
+ website_author.add_capability('create', 'WebsiteNavItem')
221
+ website_author.add_capability('delete', 'WebsiteNavItem')
222
+ website_author.add_capability('edit', 'WebsiteNavItem')
223
+ website_author.add_capability('secure', 'WebsiteNavItem')
224
+ website_author.add_capability('unsecure', 'WebsiteNavItem')
225
+
226
+ admin.add_capability('view', 'Theme')
227
+ designer.add_capability('view', 'Theme')
228
+
229
+ admin.add_capability('view', 'SiteImageAsset')
230
+ website_author.add_capability('view', 'SiteImageAsset')
231
+ content_author.add_capability('view', 'SiteImageAsset')
232
+
233
+ content_author.add_capability('view', 'GlobalImageAsset')
234
+
235
+ admin.add_capability('view', 'GlobalImageAsset')
236
+ admin.add_capability('upload', 'GlobalImageAsset')
237
+ admin.add_capability('delete', 'GlobalImageAsset')
238
+
239
+ website_author.add_capability('view', 'GlobalImageAsset')
240
+ website_author.add_capability('upload', 'GlobalImageAsset')
241
+ website_author.add_capability('delete', 'GlobalImageAsset')
242
+
243
+ admin.add_capability('view', 'SiteFileAsset')
244
+ website_author.add_capability('view', 'SiteFileAsset')
245
+ content_author.add_capability('view', 'SiteFileAsset')
246
+
247
+ content_author.add_capability('view', 'GlobalFileAsset')
248
+
249
+ admin.add_capability('view', 'GlobalFileAsset')
250
+ admin.add_capability('upload', 'GlobalFileAsset')
251
+ admin.add_capability('delete', 'GlobalFileAsset')
252
+
253
+ website_author.add_capability('view', 'GlobalFileAsset')
254
+ website_author.add_capability('upload', 'GlobalFileAsset')
255
+ website_author.add_capability('delete', 'GlobalFileAsset')
256
+
257
+ admin.add_capability('drag_item', 'WebsiteTree')
258
+ website_author.add_capability('drag_item', 'WebsiteTree')
259
+
260
+ # update capability descriptions
261
+ Capability.all.each do |c|
262
+ c.update_description
263
+ end
264
+
265
+ drop_table :capable_models
266
+ drop_table :capabilities_capable_models
267
+ drop_table :secured_models
268
+ drop_table :roles_secured_models
269
+ remove_column :capabilities, :resource
270
+ end
271
+ end
272
+
273
+ def self.down
274
+ end
275
+ end
@@ -0,0 +1,14 @@
1
+ # This migration comes from erp_tech_svcs (originally 20130410135419)
2
+ class AddQueueToDelayedJobs < ActiveRecord::Migration
3
+ def up
4
+ unless columns(:delayed_jobs).collect {|c| c.name}.include?('queue')
5
+ add_column :delayed_jobs, :queue, :string
6
+ end
7
+ end
8
+
9
+ def down
10
+ if columns(:delayed_jobs).collect {|c| c.name}.include?('queue')
11
+ remove_column :delayed_jobs, :queue, :string
12
+ end
13
+ end
14
+ end