social_stream-base 0.18.1 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/social_stream.action.js +40 -0
- data/app/assets/javascripts/social_stream.comments.js +26 -1
- data/app/assets/javascripts/social_stream.timeline.js +15 -7
- data/app/assets/javascripts/social_stream.wall.js.erb +1 -0
- data/app/assets/stylesheets/social_stream-base.css.scss +13 -0
- data/app/models/activity.rb +5 -1
- data/app/models/activity_action.rb +6 -0
- data/app/models/activity_object.rb +131 -9
- data/app/models/actor.rb +2 -0
- data/app/models/channel.rb +0 -1
- data/app/models/comment.rb +0 -6
- data/app/views/activity_actions/_update.js.erb +11 -0
- data/app/views/activity_actions/create.js.erb +1 -1
- data/app/views/activity_actions/update.js.erb +1 -1
- data/app/views/comments/create.js.erb +1 -1
- data/app/views/posts/create.js.erb +1 -1
- data/db/migrate/20120111141717_create_social_stream.rb +265 -0
- data/db/migrate/20120326083509_object_channels_to_actions.rb +45 -0
- data/lib/social_stream/ability/base.rb +2 -2
- data/lib/social_stream/base/version.rb +1 -1
- data/lib/social_stream/controllers/cancan_devise_integration.rb +9 -5
- data/lib/social_stream/models/object.rb +0 -72
- data/lib/social_stream/models/subject.rb +2 -1
- data/lib/social_stream/models/subtype.rb +6 -1
- data/spec/controllers/groups_controller_spec.rb +6 -0
- data/spec/factories/post.rb +6 -0
- data/spec/models/activity_action_spec.rb +35 -0
- metadata +69 -77
- data/app/assets/stylesheets/social_stream-base.css +0 -5
- data/app/views/activity_actions/_update_form.js.erb +0 -2
- data/db/migrate/20110610112023_create_social_stream.rb +0 -319
- data/db/migrate/20110705103202_empty_ties_count.rb +0 -17
- data/db/migrate/20110712090343_remove_spheres.rb +0 -30
- data/db/migrate/20110712142140_remove_permission_function.rb +0 -26
- data/db/migrate/20110912074426_add_reject_relation.rb +0 -29
- data/db/migrate/20111124100618_object_actors.rb +0 -52
- data/db/migrate/20111221103509_add_language_field.rb +0 -13
- data/db/migrate/20120103103125_add_channels.rb +0 -88
- data/db/migrate/20120109081509_update_notify_permissions.rb +0 -15
- data/db/migrate/20120111120920_remove_language_default.rb +0 -9
- data/db/migrate/20120111141717_activity_channels.rb +0 -74
@@ -1,319 +0,0 @@
|
|
1
|
-
class CreateSocialStream < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table "activities", :force => true do |t|
|
4
|
-
t.integer "contact_id"
|
5
|
-
t.integer "activity_verb_id"
|
6
|
-
t.datetime "created_at"
|
7
|
-
t.datetime "updated_at"
|
8
|
-
t.string "ancestry"
|
9
|
-
end
|
10
|
-
|
11
|
-
add_index "activities", "contact_id"
|
12
|
-
add_index "activities", "activity_verb_id"
|
13
|
-
|
14
|
-
create_table "activity_object_activities", :force => true do |t|
|
15
|
-
t.integer "activity_id"
|
16
|
-
t.integer "activity_object_id"
|
17
|
-
t.datetime "created_at"
|
18
|
-
t.datetime "updated_at"
|
19
|
-
t.string "object_type"
|
20
|
-
end
|
21
|
-
|
22
|
-
add_index "activity_object_activities", "activity_id"
|
23
|
-
add_index "activity_object_activities", "activity_object_id"
|
24
|
-
|
25
|
-
create_table "activity_objects", :force => true do |t|
|
26
|
-
t.datetime "created_at"
|
27
|
-
t.datetime "updated_at"
|
28
|
-
t.string "object_type", :limit => 45
|
29
|
-
t.integer "like_count", :default => 0
|
30
|
-
end
|
31
|
-
|
32
|
-
create_table "activity_verbs", :force => true do |t|
|
33
|
-
t.string "name", :limit => 45
|
34
|
-
t.datetime "created_at"
|
35
|
-
t.datetime "updated_at"
|
36
|
-
end
|
37
|
-
|
38
|
-
create_table "actors", :force => true do |t|
|
39
|
-
t.string "name"
|
40
|
-
t.string "email", :default => "", :null => false
|
41
|
-
t.string "slug"
|
42
|
-
t.string "subject_type"
|
43
|
-
t.boolean "notify_by_email", :default => true
|
44
|
-
t.datetime "created_at"
|
45
|
-
t.datetime "updated_at"
|
46
|
-
t.integer "activity_object_id"
|
47
|
-
t.integer "follower_count", :default => 0
|
48
|
-
end
|
49
|
-
|
50
|
-
add_index "actors", "activity_object_id"
|
51
|
-
add_index "actors", "email"
|
52
|
-
add_index "actors", "slug", :unique => true
|
53
|
-
|
54
|
-
create_table "audiences", :force => true do |t|
|
55
|
-
t.integer "relation_id"
|
56
|
-
t.integer "activity_id"
|
57
|
-
end
|
58
|
-
|
59
|
-
add_index "audiences", "relation_id"
|
60
|
-
add_index "audiences", "activity_id"
|
61
|
-
|
62
|
-
create_table :authentications, :force => true do |t|
|
63
|
-
t.integer :user_id
|
64
|
-
t.string :provider
|
65
|
-
t.string :uid
|
66
|
-
t.timestamps
|
67
|
-
end
|
68
|
-
|
69
|
-
add_index "authentications", "user_id"
|
70
|
-
|
71
|
-
create_table "avatars", :force => true do |t|
|
72
|
-
t.integer "actor_id"
|
73
|
-
t.string "logo_file_name"
|
74
|
-
t.string "logo_content_type"
|
75
|
-
t.integer "logo_file_size"
|
76
|
-
t.datetime "logo_updated_at"
|
77
|
-
t.boolean "active", :default => true
|
78
|
-
end
|
79
|
-
|
80
|
-
add_index "avatars", "actor_id"
|
81
|
-
|
82
|
-
create_table "comments", :force => true do |t|
|
83
|
-
t.integer "activity_object_id"
|
84
|
-
t.text "text"
|
85
|
-
t.datetime "created_at"
|
86
|
-
t.datetime "updated_at"
|
87
|
-
end
|
88
|
-
|
89
|
-
add_index "comments", "activity_object_id"
|
90
|
-
|
91
|
-
create_table "contacts", :force => true do |t|
|
92
|
-
t.integer "sender_id"
|
93
|
-
t.integer "receiver_id"
|
94
|
-
t.datetime "created_at"
|
95
|
-
t.datetime "updated_at"
|
96
|
-
t.integer "inverse_id"
|
97
|
-
t.integer "ties_count"
|
98
|
-
end
|
99
|
-
|
100
|
-
add_index "contacts", "receiver_id"
|
101
|
-
add_index "contacts", "sender_id"
|
102
|
-
add_index "contacts", "inverse_id"
|
103
|
-
|
104
|
-
create_table "groups", :force => true do |t|
|
105
|
-
t.integer "actor_id"
|
106
|
-
t.datetime "created_at"
|
107
|
-
t.datetime "updated_at"
|
108
|
-
end
|
109
|
-
|
110
|
-
add_index "groups", "actor_id"
|
111
|
-
|
112
|
-
create_table "permissions", :force => true do |t|
|
113
|
-
t.string "action"
|
114
|
-
t.string "object", :default => nil
|
115
|
-
t.string "function", :default => nil
|
116
|
-
t.datetime "created_at"
|
117
|
-
t.datetime "updated_at"
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
create_table "posts", :force => true do |t|
|
122
|
-
t.integer "activity_object_id"
|
123
|
-
t.datetime "created_at"
|
124
|
-
t.datetime "updated_at"
|
125
|
-
t.text "text"
|
126
|
-
end
|
127
|
-
|
128
|
-
add_index "posts", "activity_object_id"
|
129
|
-
|
130
|
-
create_table "profiles", :force => true do |t|
|
131
|
-
t.integer "actor_id"
|
132
|
-
t.date "birthday"
|
133
|
-
t.datetime "created_at"
|
134
|
-
t.datetime "updated_at"
|
135
|
-
t.string "organization", :limit => 45
|
136
|
-
t.string "phone", :limit => 45
|
137
|
-
t.string "mobile", :limit => 45
|
138
|
-
t.string "fax", :limit => 45
|
139
|
-
t.string "address"
|
140
|
-
t.string "city"
|
141
|
-
t.string "zipcode", :limit => 45
|
142
|
-
t.string "province", :limit => 45
|
143
|
-
t.string "country", :limit => 45
|
144
|
-
t.integer "prefix_key"
|
145
|
-
t.string "description"
|
146
|
-
t.string "experience"
|
147
|
-
t.string "website"
|
148
|
-
t.string "skype", :limit => 45
|
149
|
-
t.string "im", :limit => 45
|
150
|
-
end
|
151
|
-
|
152
|
-
add_index "profiles", "actor_id"
|
153
|
-
|
154
|
-
create_table "relation_permissions", :force => true do |t|
|
155
|
-
t.integer "relation_id"
|
156
|
-
t.integer "permission_id"
|
157
|
-
t.datetime "created_at"
|
158
|
-
t.datetime "updated_at"
|
159
|
-
t.integer "relation_id"
|
160
|
-
end
|
161
|
-
|
162
|
-
add_index "relation_permissions", "relation_id"
|
163
|
-
add_index "relation_permissions", "permission_id"
|
164
|
-
|
165
|
-
create_table "relations", :force => true do |t|
|
166
|
-
t.integer "actor_id"
|
167
|
-
t.string "type"
|
168
|
-
t.string "name"
|
169
|
-
t.datetime "created_at"
|
170
|
-
t.datetime "updated_at"
|
171
|
-
t.string "sender_type"
|
172
|
-
t.string "receiver_type"
|
173
|
-
t.string "ancestry"
|
174
|
-
t.integer "sphere_id"
|
175
|
-
end
|
176
|
-
|
177
|
-
add_index "relations", "actor_id"
|
178
|
-
add_index "relations", "ancestry"
|
179
|
-
add_index "relations", "sphere_id"
|
180
|
-
|
181
|
-
create_table "spheres", :force => true do |t|
|
182
|
-
t.string "name"
|
183
|
-
t.integer "actor_id"
|
184
|
-
t.datetime "created_at"
|
185
|
-
t.datetime "updated_at"
|
186
|
-
end
|
187
|
-
|
188
|
-
add_index "spheres", "actor_id"
|
189
|
-
|
190
|
-
create_table "ties", :force => true do |t|
|
191
|
-
t.integer "contact_id"
|
192
|
-
t.integer "relation_id"
|
193
|
-
t.datetime "created_at"
|
194
|
-
t.datetime "updated_at"
|
195
|
-
end
|
196
|
-
|
197
|
-
add_index "ties", "contact_id"
|
198
|
-
add_index "ties", "relation_id"
|
199
|
-
|
200
|
-
create_table "users", :force => true do |t|
|
201
|
-
t.string :encrypted_password, :null => false, :default => "", :limit => 128
|
202
|
-
t.string :password_salt
|
203
|
-
|
204
|
-
t.recoverable
|
205
|
-
t.rememberable
|
206
|
-
t.trackable
|
207
|
-
|
208
|
-
# t.confirmable
|
209
|
-
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
|
210
|
-
t.token_authenticatable
|
211
|
-
|
212
|
-
t.timestamps
|
213
|
-
t.integer "actor_id"
|
214
|
-
end
|
215
|
-
|
216
|
-
add_index "users", "actor_id"
|
217
|
-
add_index "users", :reset_password_token, :unique => true
|
218
|
-
# add_index :users, :confirmation_token, :unique => true
|
219
|
-
# add_index :users, :unlock_token, :unique => true
|
220
|
-
|
221
|
-
add_foreign_key "activities", "contacts", :name => "index_activities_on_contact_id"
|
222
|
-
add_foreign_key "activities", "activity_verbs", :name => "index_activities_on_activity_verb_id"
|
223
|
-
|
224
|
-
add_foreign_key "activity_object_activities", "activities", :name => "index_activity_object_activities_on_activity_id"
|
225
|
-
add_foreign_key "activity_object_activities", "activity_objects", :name => "activity_object_activities_on_activity_object_id"
|
226
|
-
|
227
|
-
add_foreign_key "actors", "activity_objects", :name => "actors_on_activity_object_id"
|
228
|
-
|
229
|
-
add_foreign_key "audiences", "relations", :name => "audiences_on_relation_id"
|
230
|
-
add_foreign_key "audiences", "activities", :name => "audiences_on_activity_id"
|
231
|
-
|
232
|
-
add_foreign_key "authentications", "users", :name => "authentications_on_user_id"
|
233
|
-
|
234
|
-
add_foreign_key "avatars", "actors", :name => "avatars_on_actor_id"
|
235
|
-
|
236
|
-
add_foreign_key "comments", "activity_objects", :name => "comments_on_activity_object_id"
|
237
|
-
add_foreign_key "contacts", "actors", :name => "contacts_on_receiver_id", :column => "receiver_id"
|
238
|
-
add_foreign_key "contacts", "actors", :name => "contacts_on_sender_id", :column => "sender_id"
|
239
|
-
|
240
|
-
add_foreign_key "groups", "actors", :name => "groups_on_actor_id"
|
241
|
-
|
242
|
-
add_foreign_key "posts", "activity_objects", :name => "posts_on_activity_object_id"
|
243
|
-
|
244
|
-
add_foreign_key "profiles", "actors", :name => "profiles_on_actor_id"
|
245
|
-
|
246
|
-
add_foreign_key "relation_permissions", "relations", :name => "relation_permissions_on_relation_id"
|
247
|
-
add_foreign_key "relation_permissions", "permissions", :name => "relation_permissions_on_permission_id"
|
248
|
-
|
249
|
-
add_foreign_key "relations", "actors", :name => "relations_on_actor_id"
|
250
|
-
add_foreign_key "relations", "spheres", :name => "relations_on_sphere_id"
|
251
|
-
|
252
|
-
add_foreign_key "spheres", "actors", :name => "spheres_on_actor_id"
|
253
|
-
|
254
|
-
add_foreign_key "ties", "contacts", :name => "ties_on_contact_id"
|
255
|
-
add_foreign_key "ties", "relations", :name => "ties_on_relation_id"
|
256
|
-
|
257
|
-
add_foreign_key "users", "actors", :name => "users_on_actor_id"
|
258
|
-
end
|
259
|
-
|
260
|
-
|
261
|
-
def self.down
|
262
|
-
remove_foreign_key "activities", :name => "index_activities_on_activity_verb_id"
|
263
|
-
|
264
|
-
remove_foreign_key "activity_object_activities", :name => "index_activity_object_activities_on_activity_id"
|
265
|
-
remove_foreign_key "activity_object_activities", :name => "activity_object_activities_on_activity_object_id"
|
266
|
-
|
267
|
-
remove_foreign_key "actors", :name => "actors_on_activity_object_id"
|
268
|
-
|
269
|
-
remove_foreign_key "audiences", :name => "audiences_on_relation_id"
|
270
|
-
remove_foreign_key "audiences", :name => "audiences_on_activity_id"
|
271
|
-
|
272
|
-
remove_foreign_key "authentications", :name => "authentications_on_user_id"
|
273
|
-
|
274
|
-
remove_foreign_key "avatars", :name => "avatars_on_actor_id"
|
275
|
-
|
276
|
-
remove_foreign_key "comments", :name => "comments_on_activity_object_id"
|
277
|
-
|
278
|
-
remove_foreign_key "contacts", :name => "contacts_on_receiver_id", :column => "receiver_id"
|
279
|
-
remove_foreign_key "contacts", :name => "contacts_on_sender_id", :column => "sender_id"
|
280
|
-
|
281
|
-
remove_foreign_key "groups", :name => "groups_on_actor_id"
|
282
|
-
|
283
|
-
remove_foreign_key "posts", :name => "posts_on_activity_object_id"
|
284
|
-
|
285
|
-
remove_foreign_key "profiles", :name => "profiles_on_actor_id"
|
286
|
-
|
287
|
-
remove_foreign_key "relation_permissions", :name => "relation_permissions_on_relation_id"
|
288
|
-
remove_foreign_key "relation_permissions", :name => "relation_permissions_on_permission_id"
|
289
|
-
|
290
|
-
remove_foreign_key "relations", :name => "relations_on_actor_id"
|
291
|
-
remove_foreign_key "relations", :name => "relations_on_sphere_id"
|
292
|
-
|
293
|
-
remove_foreign_key "spheres", :name => "spheres_on_actor_id"
|
294
|
-
|
295
|
-
remove_foreign_key "ties", :name => "ties_on_contact_id"
|
296
|
-
remove_foreign_key "ties", :name => "ties_on_relation_id"
|
297
|
-
|
298
|
-
remove_foreign_key "users", :name => "users_on_actor_id"
|
299
|
-
|
300
|
-
drop_table :activities
|
301
|
-
drop_table :activity_object_activities
|
302
|
-
drop_table :activity_objects
|
303
|
-
drop_table :activity_verbs
|
304
|
-
drop_table :actors
|
305
|
-
drop_table :authentications
|
306
|
-
drop_table :avatars
|
307
|
-
drop_table :comments
|
308
|
-
drop_table :contacts
|
309
|
-
drop_table :groups
|
310
|
-
drop_table :permissions
|
311
|
-
drop_table :posts
|
312
|
-
drop_table :profiles
|
313
|
-
drop_table :relation_permissions
|
314
|
-
drop_table :relations
|
315
|
-
drop_table :spheres
|
316
|
-
drop_table :ties
|
317
|
-
drop_table :users
|
318
|
-
end
|
319
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class EmptyTiesCount < ActiveRecord::Migration
|
2
|
-
def up
|
3
|
-
change_column :contacts, :ties_count, :integer, :default => 0
|
4
|
-
|
5
|
-
ts_status = Contact.record_timestamps
|
6
|
-
Contact.record_timestamps = false
|
7
|
-
|
8
|
-
Contact.all.each do |c|
|
9
|
-
c.update_attribute(:ties_count, 0) if c.ties_count.nil?
|
10
|
-
end
|
11
|
-
|
12
|
-
Contact.record_timestamps = ts_status
|
13
|
-
end
|
14
|
-
|
15
|
-
def down
|
16
|
-
end
|
17
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
class RemoveSpheres < ActiveRecord::Migration
|
2
|
-
def up
|
3
|
-
remove_foreign_key "relations", :name => "relations_on_sphere_id"
|
4
|
-
|
5
|
-
remove_foreign_key "spheres", :name => "spheres_on_actor_id"
|
6
|
-
|
7
|
-
remove_column :relations, :sphere_id
|
8
|
-
|
9
|
-
drop_table :spheres
|
10
|
-
end
|
11
|
-
|
12
|
-
def down
|
13
|
-
add_column :relations, :sphere_id, :integer
|
14
|
-
|
15
|
-
add_index "relations", "sphere_id"
|
16
|
-
|
17
|
-
create_table "spheres", :force => true do |t|
|
18
|
-
t.string "name"
|
19
|
-
t.integer "actor_id"
|
20
|
-
t.datetime "created_at"
|
21
|
-
t.datetime "updated_at"
|
22
|
-
end
|
23
|
-
|
24
|
-
add_index "spheres", "actor_id"
|
25
|
-
|
26
|
-
add_foreign_key "relations", "spheres", :name => "relations_on_sphere_id"
|
27
|
-
|
28
|
-
add_foreign_key "spheres", "actors", :name => "spheres_on_actor_id"
|
29
|
-
end
|
30
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
class RemovePermissionFunction < ActiveRecord::Migration
|
2
|
-
def up
|
3
|
-
remove_column :permissions, :function
|
4
|
-
|
5
|
-
ts = RelationPermission.record_timestamps
|
6
|
-
RelationPermission.record_timestamps = false
|
7
|
-
|
8
|
-
Permission.all.each do |p|
|
9
|
-
q = Permission.find_by_action_and_object p.action, p.object
|
10
|
-
|
11
|
-
next if p == q
|
12
|
-
|
13
|
-
p.relation_permissions.each do |rp|
|
14
|
-
rp.update_attribute :permission_id, q.id
|
15
|
-
end
|
16
|
-
|
17
|
-
p.reload.destroy
|
18
|
-
end
|
19
|
-
|
20
|
-
RelationPermission.record_timestamps = ts
|
21
|
-
end
|
22
|
-
|
23
|
-
def down
|
24
|
-
add_column :permissions, :function, :string
|
25
|
-
end
|
26
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
class AddRejectRelation < ActiveRecord::Migration
|
2
|
-
def up
|
3
|
-
Actor.all.each do |a|
|
4
|
-
Relation::Reject.default_for(a)
|
5
|
-
end
|
6
|
-
|
7
|
-
Tie.
|
8
|
-
includes(:relation, :contact, :sender).
|
9
|
-
merge(Relation.where(:type => 'Relation::Public')).
|
10
|
-
each do |t|
|
11
|
-
if t.contact.ties_count != 1
|
12
|
-
logger.warn "Public contact #{ t.contact_id } has #{ contact.ties_count }, when expecting 1"
|
13
|
-
end
|
14
|
-
|
15
|
-
t.update_attribute :relation_id, Relation::Reject.instance.id
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def down
|
20
|
-
Tie.
|
21
|
-
includes(:relation, :contact).
|
22
|
-
merge(Relation.where(:type => 'Relation::Reject')).
|
23
|
-
each do |t|
|
24
|
-
t.update_attribute :relation_id, Relation::Public.instance.id
|
25
|
-
end
|
26
|
-
|
27
|
-
Relation::Reject.destroy_all
|
28
|
-
end
|
29
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
class ObjectActors < ActiveRecord::Migration
|
2
|
-
def up
|
3
|
-
change_table :activity_objects do |t|
|
4
|
-
t.integer :author_id
|
5
|
-
t.integer :owner_id
|
6
|
-
t.integer :user_author_id
|
7
|
-
end
|
8
|
-
|
9
|
-
add_index "activity_objects", "author_id"
|
10
|
-
add_index "activity_objects", "owner_id"
|
11
|
-
add_index "activity_objects", "user_author_id"
|
12
|
-
|
13
|
-
add_foreign_key "activity_objects", "actors", :name => "index_activity_objects_on_author_id", :column => :author_id
|
14
|
-
add_foreign_key "activity_objects", "actors", :name => "index_activity_objects_on_owner_id", :column => :owner_id
|
15
|
-
add_foreign_key "activity_objects", "actors", :name => "index_activity_objects_on_user_author_id", :column => :user_author_id
|
16
|
-
|
17
|
-
ActivityObject.record_timestamps = false
|
18
|
-
|
19
|
-
ActivityObject.all.each do |a|
|
20
|
-
if a.object_type == "Actor"
|
21
|
-
next if a.object.is_a? User
|
22
|
-
|
23
|
-
author = user_author = a.object.sent_ties.order(:created_at).first.receiver
|
24
|
-
|
25
|
-
until user_author.subject_type == "User"
|
26
|
-
user_author = user_author.sent_ties.order(:created_at).first.receiver
|
27
|
-
end
|
28
|
-
|
29
|
-
a.author = author
|
30
|
-
a.user_author = user_author
|
31
|
-
else
|
32
|
-
next if a.post_activity.blank?
|
33
|
-
|
34
|
-
a.author = a.post_activity.sender
|
35
|
-
a.owner = a.post_activity.receiver
|
36
|
-
a.user_author = (a.author.subject.is_a?(User) ? a.author : a.author.sent_ties.order(:created_at).first.receiver)
|
37
|
-
end
|
38
|
-
|
39
|
-
a.save!
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def down
|
44
|
-
remove_foreign_key "activity_objects", :name => "index_activity_objects_on_author_id"
|
45
|
-
remove_foreign_key "activity_objects", :name => "index_activity_objects_on_owner_id"
|
46
|
-
remove_foreign_key "activity_objects", :name => "index_activity_objects_on_user_author_id"
|
47
|
-
|
48
|
-
remove_column :activity_objects, :author_id
|
49
|
-
remove_column :activity_objects, :owner_id
|
50
|
-
remove_column :activity_objects, :user_author_id
|
51
|
-
end
|
52
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
class AddChannels < ActiveRecord::Migration
|
2
|
-
def up
|
3
|
-
create_table :channels do |t|
|
4
|
-
t.integer :author_id
|
5
|
-
t.integer :owner_id
|
6
|
-
t.integer :user_author_id
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
|
11
|
-
add_index "channels", "author_id"
|
12
|
-
add_index "channels", "owner_id"
|
13
|
-
add_index "channels", "user_author_id"
|
14
|
-
|
15
|
-
add_foreign_key "channels", "actors", :name => "index_channels_on_author_id", :column => :author_id
|
16
|
-
add_foreign_key "channels", "actors", :name => "index_channels_on_owner_id", :column => :owner_id
|
17
|
-
add_foreign_key "channels", "actors", :name => "index_channels_on_user_author_id", :column => :user_author_id
|
18
|
-
|
19
|
-
change_table :activity_objects do |t|
|
20
|
-
t.integer :channel_id
|
21
|
-
end
|
22
|
-
|
23
|
-
add_index "activity_objects", "channel_id"
|
24
|
-
|
25
|
-
add_foreign_key "activity_objects", "channels", :name => "index_activity_objects_on_channel_id"
|
26
|
-
|
27
|
-
ActivityObject.record_timestamps = false
|
28
|
-
|
29
|
-
ActivityObject.reset_column_information
|
30
|
-
|
31
|
-
ActivityObject.all.each do |a|
|
32
|
-
%w( author user_author owner ).each do |m|
|
33
|
-
a.channel!.__send__ "#{ m }_id=", a.read_attribute("#{ m }_id") # a.channel!.author_id = a.read_attribute("author_id")
|
34
|
-
end
|
35
|
-
|
36
|
-
a.save!
|
37
|
-
end
|
38
|
-
|
39
|
-
remove_foreign_key "activity_objects", :name => "index_activity_objects_on_author_id"
|
40
|
-
remove_foreign_key "activity_objects", :name => "index_activity_objects_on_owner_id"
|
41
|
-
remove_foreign_key "activity_objects", :name => "index_activity_objects_on_user_author_id"
|
42
|
-
|
43
|
-
remove_column :activity_objects, :author_id
|
44
|
-
remove_column :activity_objects, :owner_id
|
45
|
-
remove_column :activity_objects, :user_author_id
|
46
|
-
|
47
|
-
ActivityObject.reset_column_information
|
48
|
-
end
|
49
|
-
|
50
|
-
def down
|
51
|
-
change_table :activity_objects do |t|
|
52
|
-
t.integer :author_id
|
53
|
-
t.integer :owner_id
|
54
|
-
t.integer :user_author_id
|
55
|
-
end
|
56
|
-
|
57
|
-
add_index "activity_objects", "author_id"
|
58
|
-
add_index "activity_objects", "owner_id"
|
59
|
-
add_index "activity_objects", "user_author_id"
|
60
|
-
|
61
|
-
add_foreign_key "activity_objects", "actors", :name => "index_activity_objects_on_author_id", :column => :author_id
|
62
|
-
add_foreign_key "activity_objects", "actors", :name => "index_activity_objects_on_owner_id", :column => :owner_id
|
63
|
-
add_foreign_key "activity_objects", "actors", :name => "index_activity_objects_on_user_author_id", :column => :user_author_id
|
64
|
-
|
65
|
-
ActivityObject.reset_column_information
|
66
|
-
ActivityObject.record_timestamps = false
|
67
|
-
|
68
|
-
ActivityObject.all.each do |a|
|
69
|
-
next if a.channel.blank?
|
70
|
-
|
71
|
-
a.author_id = a.channel.author_id
|
72
|
-
a.owner_id = a.channel.owner_id
|
73
|
-
a.user_author_id = a.channel.user_author_id
|
74
|
-
|
75
|
-
a.save!
|
76
|
-
end
|
77
|
-
|
78
|
-
remove_foreign_key "activity_objects", :name => "index_activity_objects_on_channel_id"
|
79
|
-
|
80
|
-
remove_column :activity_objects, :channel_id
|
81
|
-
|
82
|
-
remove_foreign_key "channels", :name => "index_channels_on_author_id"
|
83
|
-
remove_foreign_key "channels", :name => "index_channels_on_owner_id"
|
84
|
-
remove_foreign_key "channels", :name => "index_channels_on_user_author_id"
|
85
|
-
|
86
|
-
drop_table :channels
|
87
|
-
end
|
88
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# Before the 'notify' permission was added, only users with the first relation in each group where notified by email
|
2
|
-
# This migration preserves the old behavior by granting the 'notify' permission to the first relation in each group
|
3
|
-
class UpdateNotifyPermissions < ActiveRecord::Migration
|
4
|
-
def up
|
5
|
-
perm_notify = Permission.find_or_create_by_action('notify')
|
6
|
-
Group.all.each do |g|
|
7
|
-
r = g.relation_customs.first
|
8
|
-
next if r.blank?
|
9
|
-
r.permissions << perm_notify
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def down
|
14
|
-
end
|
15
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
class ActivityChannels < ActiveRecord::Migration
|
2
|
-
class ActivityMigration < ActiveRecord::Base
|
3
|
-
self.record_timestamps = false
|
4
|
-
set_table_name "activities"
|
5
|
-
end
|
6
|
-
|
7
|
-
def up
|
8
|
-
change_table :activities do |t|
|
9
|
-
t.integer :channel_id
|
10
|
-
end
|
11
|
-
|
12
|
-
add_index "activities", "channel_id"
|
13
|
-
|
14
|
-
add_foreign_key "activities", "channels", :name => "index_activities_on_channel_id"
|
15
|
-
|
16
|
-
ActivityMigration.reset_column_information
|
17
|
-
|
18
|
-
ActivityMigration.all.each do |a|
|
19
|
-
activity = Activity.find(a.id)
|
20
|
-
|
21
|
-
case activity.verb
|
22
|
-
|
23
|
-
when "post", "update"
|
24
|
-
a.channel_id = activity.direct_object.channel_id
|
25
|
-
else
|
26
|
-
contact = Contact.find activity.contact_id
|
27
|
-
|
28
|
-
author_id = contact.sender_id
|
29
|
-
owner_id = contact.receiver_id
|
30
|
-
|
31
|
-
user_author_id =
|
32
|
-
(contact.sender_subject.is_a?(User) ?
|
33
|
-
contact.sender :
|
34
|
-
contact.sender.sent_ties.order(:created_at).first.receiver).id
|
35
|
-
|
36
|
-
a.channel_id =
|
37
|
-
Channel.find_or_create_by_author_id_and_user_author_id_and_owner_id(author_id,
|
38
|
-
user_author_id,
|
39
|
-
owner_id).id
|
40
|
-
end
|
41
|
-
|
42
|
-
a.save!
|
43
|
-
end
|
44
|
-
|
45
|
-
remove_foreign_key "activities", :name => "index_activities_on_contact_id"
|
46
|
-
|
47
|
-
remove_column :activities, :contact_id
|
48
|
-
|
49
|
-
Activity.reset_column_information
|
50
|
-
end
|
51
|
-
|
52
|
-
def down
|
53
|
-
change_table :activities do |t|
|
54
|
-
t.integer :contact_id
|
55
|
-
end
|
56
|
-
|
57
|
-
add_index "activities", "contact_id"
|
58
|
-
|
59
|
-
add_foreign_key "activities", "contacts", :name => "index_activities_on_contact_id"
|
60
|
-
|
61
|
-
ActivityMigration.reset_column_information
|
62
|
-
|
63
|
-
ActivityMigration.all.each do |a|
|
64
|
-
channel = Channel.find a.channel_id
|
65
|
-
a.contact_id = Contact.find_by_sender_id_and_receiver_id(channel.author_id, channel.owner_id)
|
66
|
-
|
67
|
-
a.save!
|
68
|
-
end
|
69
|
-
|
70
|
-
remove_foreign_key "activities", :name => "index_activities_on_channel_id"
|
71
|
-
|
72
|
-
remove_column :activities, :channel_id
|
73
|
-
end
|
74
|
-
end
|