social_stream-base 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/LICENSE +1 -1
  2. data/README.rdoc +1 -1
  3. data/app/assets/stylesheets/header.css.scss +9 -7
  4. data/app/controllers/groups_controller.rb +3 -4
  5. data/app/controllers/settings_controller.rb +14 -3
  6. data/app/controllers/users_controller.rb +3 -4
  7. data/app/helpers/permissions_helper.rb +2 -1
  8. data/app/models/activity_object.rb +29 -28
  9. data/app/models/actor.rb +27 -19
  10. data/app/models/channel.rb +48 -0
  11. data/app/views/contacts/_pendings.html.erb +1 -1
  12. data/app/views/devise/registrations/_edit_user.html.erb +0 -25
  13. data/app/views/devise/registrations/edit.html.erb +1 -0
  14. data/app/views/layouts/_footer.html.erb +1 -1
  15. data/app/views/layouts/_header_dropdown_menu_sessions.html.erb +5 -2
  16. data/app/views/settings/_language.html.erb +32 -0
  17. data/app/views/settings/_notifications.html.erb +1 -1
  18. data/config/locales/en.yml +5 -0
  19. data/config/locales/es.yml +7 -0
  20. data/db/migrate/20120103103125_add_channels.rb +88 -0
  21. data/db/migrate/20120109081509_update_notify_permissions.rb +15 -0
  22. data/lib/social_stream/base/engine.rb +10 -2
  23. data/lib/social_stream/base/version.rb +1 -1
  24. data/lib/social_stream/controllers/i18n_integration.rb +29 -0
  25. data/lib/social_stream/controllers/subjects.rb +19 -0
  26. data/lib/social_stream/models/object.rb +12 -26
  27. data/lib/social_stream/models/subject.rb +2 -24
  28. data/lib/social_stream/models/subtype.rb +80 -0
  29. data/lib/social_stream/models/supertype.rb +16 -3
  30. data/lib/social_stream/views/settings/base.rb +5 -0
  31. data/lib/social_stream-base.rb +7 -4
  32. data/lib/tasks/db/populate.rake +1 -0
  33. data/spec/controllers/settings_controller_spec.rb +1 -1
  34. data/spec/spec_helper.rb +3 -0
  35. metadata +67 -61
  36. data/spec/dummy/app/helpers/application_helper.rb +0 -2
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Universidad Politécnica de Madrid
1
+ Copyright (c) 2012 Universidad Politécnica de Madrid
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -10,7 +10,7 @@ network environment see https://github.com/ging/social_stream
10
10
  * Social network infraestructure
11
11
  * Activity streams infraestructure
12
12
  * Subjects: {User} and {Group}
13
- * Objects: {Post} and {Commment}
13
+ * Objects: {Post} and {Comment}
14
14
  * Private messages and notifications, by {Mailboxer}[https://github.com/ging/mailboxer]
15
15
  * Avatars, by {Avatars For Rails}[https://github.com/ging/avatars_for_rails]
16
16
 
@@ -25,11 +25,13 @@
25
25
  .div_login .options{ height:20px; font-size: 11px;}
26
26
  .div_login .a_border{ border-right:thin solid; padding-right:7px; text-decoration:underline; }
27
27
  #new_representation { display: inline-block;}
28
- #header_notifications a{color: white; padding: 4px 10px 6px 11px;
28
+ #header_notifications a{color: $text-over-main; padding: 4px 10px 6px 11px;
29
29
  background: transparent url('btn/header_notifications.png') no-repeat center center;}
30
- #header_inbox_count a{ color: white; background-color: $header-notification-color; padding: 2px 7px 2px 7px;}
30
+ #header_inbox_count a{ color: $text-over-main; background-color: $header-notification-color; padding: 2px 7px 2px 7px;}
31
31
  #representation { display: inline; padding-left:3px; padding-right:3px;}
32
- .switch_pending_count { color: white; background-color: $header-notification-color; padding: 2px 7px 2px 7px !important; margin-left: 5px !important; float: right; }
32
+ .switch_pending_count { color: $text-over-main; text-align: right;
33
+ background: transparent url('btn/header_notifications.png') no-repeat center center;
34
+ padding: 2px 10px 4px 11px !important; margin: 0 5px 0 5px !important; float: right; }
33
35
  .txt_config {color: $text-over-main; vertical-align: top; display: inline; padding-top: 2px;
34
36
  border-right: thin solid; padding-right: 3px;}
35
37
  .txt_config2 {color: $text-over-main; vertical-align: top; display: inline; padding-top: 2px; padding-right: 3px;}
@@ -37,7 +39,7 @@
37
39
 
38
40
  /******** MENU HEADER *******/
39
41
  #menu_home, .menu_home {vertical-align: top; }
40
- #menu_home a {color:white;}
42
+ #menu_home a {color:$text-over-main;}
41
43
  #menu_home a:hover {text-decoration: none;}
42
44
  #menu_home ul {list-style: none; margin: 0px; float:left;}
43
45
  #menu_home ul li {line-height:20px; vertical-align:top;}
@@ -49,9 +51,9 @@
49
51
  #header_dropdown_menu ul li a{padding: .40em 1em .70em 2.5em;}
50
52
  #header_dropdown_menu ul li a:hover{color:$main-color;}
51
53
  #header_dropdown_menu ul li ul li a{padding: .40em 1em .70em 1em;}
52
- #header_dropdown_menu ul li ul li ul li {width: 160px;}
53
- #header_dropdown_menu ul li ul li ul li a{padding: .40em 1em .70em 2.5em;}
54
- #header_dropdown_menu ul li ul li ul{position: absolute; left: -160px;}
54
+ #header_dropdown_menu ul li ul li ul li {width: 170px;}
55
+ #header_dropdown_menu ul li ul li ul li a{padding: .40em 1em .70em 2.5em; display:inline;}
56
+ #header_dropdown_menu ul li ul li ul{position: absolute; left: -170px;}
55
57
  #header_dropdown_menu a.session_change{background: transparent url('btn/arrow_session_change.png') no-repeat 3px 6px;}
56
58
 
57
59
  #menu_home ul li.pipe,#menu_account ul li.pipe{padding:0; margin:0;font-size: 20px;font-weight: bold;}
@@ -1,4 +1,6 @@
1
- class GroupsController < InheritedResources::Base
1
+ class GroupsController < ApplicationController
2
+ include SocialStream::Controllers::Subjects
3
+
2
4
  before_filter :authenticate_user!, :except => [ :index, :show ]
3
5
 
4
6
  # Set group founder to current_subject
@@ -19,9 +21,6 @@ class GroupsController < InheritedResources::Base
19
21
 
20
22
  end
21
23
 
22
- def show
23
- end
24
-
25
24
  def create
26
25
  create! do |success, failure|
27
26
  success.html {
@@ -22,13 +22,22 @@ class SettingsController < ApplicationController
22
22
  end
23
23
  end
24
24
 
25
+ #Updating language
26
+ if section.eql? "language"
27
+ #Preferred language setting
28
+ if params[:language].present?
29
+ lang = params[:language].to_s
30
+ current_user.language = lang[0..1]
31
+ end
32
+ end
33
+
25
34
  #Here sections to add
26
35
  #if section.eql? "section_name"
27
36
  # blah blah blah
28
37
  #end
29
38
 
30
- #Was everything ok?
31
- success = current_subject.save
39
+ # Was everything ok?
40
+ success = current_subject.save && current_user.save
32
41
  end
33
42
 
34
43
  #Flashing and redirecting
@@ -37,7 +46,9 @@ class SettingsController < ApplicationController
37
46
  else
38
47
  flash[:error] = t('settings.error')
39
48
  end
40
- render :action => :index
49
+ # render :action => :index
50
+
51
+ redirect_to settings_path
41
52
  end
42
53
 
43
54
  end
@@ -1,4 +1,6 @@
1
- class UsersController < InheritedResources::Base
1
+ class UsersController < ApplicationController
2
+ include SocialStream::Controllers::Subjects
3
+
2
4
  load_and_authorize_resource
3
5
 
4
6
  respond_to :html, :xml, :js
@@ -13,9 +15,6 @@ class UsersController < InheritedResources::Base
13
15
 
14
16
  end
15
17
 
16
- def show
17
- end
18
-
19
18
  # Supported through devise
20
19
  def new; end; def create; end
21
20
  # Not supported yet
@@ -4,7 +4,8 @@ module PermissionsHelper
4
4
  [ "read", "activity" ],
5
5
  [ "create", "activity" ],
6
6
  [ "follow", nil ],
7
- [ "represent", nil ]
7
+ [ "represent", nil ],
8
+ [ "notify", nil ]
8
9
  ]
9
10
 
10
11
  def default_permissions
@@ -9,27 +9,26 @@
9
9
  # Objects are added to +config/initializers/social_stream.rb+
10
10
  #
11
11
  class ActivityObject < ActiveRecord::Base
12
- @subtypes_name = :object
13
- include SocialStream::Models::Supertype
12
+ # ActivityObject is a subtype of Channel
13
+ # Author, owner and user_author of this ActivityObject are defined in its channel
14
+ subtype_of :channel,
15
+ :belongs => { :dependent => nil }
16
+ # ActivityObject is a supertype of SocialStream.objects
17
+ supertype_of :object
14
18
 
15
19
  acts_as_taggable
16
-
17
- # Author can be any type of Actor: User, Group, etc.
18
- belongs_to :author,
19
- :class_name => "Actor"
20
- # Owner is the wall's subject this object is posted to
21
- belongs_to :owner,
22
- :class_name => "Actor"
23
-
24
- # UserAuthor is the real user behind the Author
25
- belongs_to :user_author,
26
- :class_name => "Actor"
27
20
 
28
21
  has_many :activity_object_activities, :dependent => :destroy
29
22
  has_many :activities, :through => :activity_object_activities
30
23
 
31
24
  validates_presence_of :object_type
32
25
 
26
+ scope :authored_by, lambda { |subject|
27
+ joins(:channel).merge(Channel.authored_by(subject))
28
+ }
29
+
30
+ before_validation :check_existing_channel
31
+
33
32
  # The object of this activity object
34
33
  def object
35
34
  subtype_instance.is_a?(Actor) ?
@@ -37,21 +36,6 @@ class ActivityObject < ActiveRecord::Base
37
36
  subtype_instance
38
37
  end
39
38
 
40
- # The {SocialStream::Models::Subject subject} author
41
- def author_subject
42
- author.subject
43
- end
44
-
45
- # The {SocialStream::Models::Subject subject} owner
46
- def owner_subject
47
- owner.subject
48
- end
49
-
50
- # The {SocialStream::Models::Subject subject} user actor
51
- def user_author_subject
52
- user_author.subject
53
- end
54
-
55
39
  # The activity in which this activity_object was created
56
40
  def post_activity
57
41
  activities.includes(:activity_verb).where('activity_verbs.name' => 'post').first
@@ -61,4 +45,21 @@ class ActivityObject < ActiveRecord::Base
61
45
  def acts_as_actor?
62
46
  object_type == "Actor"
63
47
  end
48
+
49
+ protected
50
+
51
+ def check_existing_channel
52
+ return unless channel!.new_record?
53
+
54
+ existing_channel =
55
+ Channel.
56
+ where(:author_id => author_id,
57
+ :owner_id => owner_id,
58
+ :user_author_id => user_author_id).
59
+ first
60
+
61
+ return if existing_channel.blank?
62
+
63
+ self.channel = existing_channel
64
+ end
64
65
  end
data/app/models/actor.rb CHANGED
@@ -15,11 +15,13 @@
15
15
  #
16
16
  #
17
17
  class Actor < ActiveRecord::Base
18
- @subtypes_name = :subject
19
- include SocialStream::Models::Supertype
18
+ # Actor is a supertype of all subjects defined in SocialStream.subjects
19
+ supertype_of :subject
20
+
20
21
  include SocialStream::Models::Object
21
22
 
22
- validates_presence_of :name, :subject_type
23
+ validates_presence_of :name, :message => ''
24
+ validates_presence_of :subject_type
23
25
 
24
26
  acts_as_messageable
25
27
 
@@ -62,13 +64,13 @@ class Actor < ActiveRecord::Base
62
64
  has_many :relations,
63
65
  :dependent => :destroy
64
66
 
65
- has_many :authored_objects,
66
- :class_name => "ActivityObject",
67
+ has_many :authored_channels,
68
+ :class_name => "Channel",
67
69
  :foreign_key => :author_id,
68
70
  :dependent => :destroy
69
71
 
70
- has_many :owned_objects,
71
- :class_name => "ActivityObject",
72
+ has_many :owned_channels,
73
+ :class_name => "Channel",
72
74
  :foreign_key => :owner_id,
73
75
  :dependent => :destroy
74
76
 
@@ -162,19 +164,20 @@ class Actor < ActiveRecord::Base
162
164
  return "#{name} <#{email}>" if email.present?
163
165
  #If actor is a Group, has enabled emails but no mail we return the highest_rank ones.
164
166
  if (group = self.subject).is_a? Group
165
- relation = group.relation_customs.sort.first
166
- receivers = group.contact_actors(:direction => :sent, :relations => relation)
167
167
  emails = Array.new
168
- receivers.each do |receiver|
169
- next unless Actor.normalize(receiver).subject_type.eql?("User")
170
-
171
- receiver_emails = receiver.mailboxer_email(object)
172
- case receiver_emails
173
- when String
174
- emails << receiver_emails
175
- when Array
176
- receiver_emails.each do |receiver_email|
177
- emails << receiver_email
168
+ group.relation_notifys.each do |relation|
169
+ receivers = group.contact_actors(:direction => :sent, :relations => relation)
170
+ receivers.each do |receiver|
171
+ next unless Actor.normalize(receiver).subject_type.eql?("User")
172
+
173
+ receiver_emails = receiver.mailboxer_email(object)
174
+ case receiver_emails
175
+ when String
176
+ emails << receiver_emails
177
+ when Array
178
+ receiver_emails.each do |receiver_email|
179
+ emails << receiver_email
180
+ end
178
181
  end
179
182
  end
180
183
  end
@@ -197,6 +200,11 @@ class Actor < ActiveRecord::Base
197
200
  relation_customs.find_by_name(name)
198
201
  end
199
202
 
203
+ # All {Relation relations} with the 'notify' permission
204
+ def relation_notifys
205
+ relations.joins(:relation_permissions => :permission).where('permissions.action' => 'notify')
206
+ end
207
+
200
208
  # The {Relation::Public} for this {Actor}
201
209
  def relation_public
202
210
  Relation::Public.of(self)
@@ -0,0 +1,48 @@
1
+ # A {Channel} is the union of the three {Actors} that are involved in an {Activity}:
2
+ #
3
+ # * The author that creates a post, comment, etc. This can be a {User}, {Group}
4
+ # or any kind of {SocialStream::Models::Subject subject}
5
+ # * The user_author representing the author. When users change session and
6
+ # act in behalf of a {Group}, Social Stream still records which user is responsible
7
+ # for an {Activity}
8
+ # * The owner in whose wall the Activity is performed.
9
+ #
10
+ class Channel < ActiveRecord::Base
11
+ # Author can be any type of Actor: User, Group, etc.
12
+ belongs_to :author,
13
+ :class_name => "Actor"
14
+ # Owner is the wall's subject this object is posted to
15
+ belongs_to :owner,
16
+ :class_name => "Actor"
17
+
18
+ # UserAuthor is the real user behind the Author
19
+ belongs_to :user_author,
20
+ :class_name => "Actor"
21
+
22
+ has_many :activity_objects
23
+
24
+ validates_uniqueness_of :author_id, :scope => [ :owner_id, :user_author_id ]
25
+ validates_uniqueness_of :owner_id, :scope => [ :author_id, :user_author_id ]
26
+ validates_uniqueness_of :user_author_id, :scope => [ :author_id, :owner_id ]
27
+
28
+ scope :authored_by, lambda { |subject|
29
+ id = Actor.normalize_id subject
30
+
31
+ where(arel_table[:author_id].eq(id).or(arel_table[:user_author_id].eq(id)))
32
+ }
33
+
34
+ # The {SocialStream::Models::Subject subject} author
35
+ def author_subject
36
+ author.subject
37
+ end
38
+
39
+ # The {SocialStream::Models::Subject subject} owner
40
+ def owner_subject
41
+ owner.subject
42
+ end
43
+
44
+ # The {SocialStream::Models::Subject subject} user actor
45
+ def user_author_subject
46
+ user_author.subject
47
+ end
48
+ end
@@ -7,7 +7,7 @@
7
7
  </div>
8
8
  </div>
9
9
  <div class="content">
10
- <%= render current_subject.pending_contacts.shuffle.first(2) %>
10
+ <%= render :partial => 'contacts/contact', :collection => current_subject.pending_contacts.shuffle.first(2) %>
11
11
  <div class="row more_pending">
12
12
  <%= link_to t('contact.pending.all_n', :count => current_subject.pending_contacts_count), pending_contacts_path %>
13
13
  </div>
@@ -85,29 +85,4 @@ $(".user_edit").validate({errorClass: "validation_error"});
85
85
  <% end%>
86
86
  </div>
87
87
  </div>
88
- <div class="block" id="lang_form">
89
- <div class="header">
90
- <div class="header_text">
91
- <%= t("account.lang.change")%>
92
- </div>
93
- <div class="header_icon_right">
94
- <%= link_to (image_tag('btn/edit.png')), "javascript:showSettings(\"lang_form\");" %>
95
- </div>
96
- </div>
97
- <div id="lang_form_briefing" class="settings_briefing content">
98
- <div class="form_row">
99
- <%= t('settings.lang_change.briefing')%>
100
- </div>
101
- </div>
102
- <div class="content settings_content" id="lang_form_content" style="display:none;">
103
- <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :id => 'form_lang' }) do |f| %>
104
- <div class="form_row">
105
- <div class="form_label"><%= f.label :language %></div>
106
- <div class="form_field">
107
- <%= f.select :language, I18n.available_locales.map{|l| [ l.to_s, l.to_s ] }, { }, { :class => 'form_lang', :onchange => "$(\'#form_lang\').submit();" } %>
108
- </div>
109
- </div>
110
- <% end%>
111
- </div>
112
- </div>
113
88
 
@@ -13,6 +13,7 @@
13
13
  </div>
14
14
  <%= render :partial => "edit_user"%>
15
15
 
16
+ <%= render :partial => "settings/language" %>
16
17
  <%= render :partial => "settings/notifications" %>
17
18
  <% if current_subject.respond_to? :authentication_token%>
18
19
  <%= render :partial => "settings/api_key" %>
@@ -6,7 +6,7 @@
6
6
  <%= link_to(image_tag('HTML5_Semantics.png'),'http://jigsaw.w3.org/css-validator/check/referer') %>
7
7
  </div>
8
8
  <ul>
9
- <li>2011 © </li>
9
+ <li><%= Date.today.year %> © </li>
10
10
  <li id="trade_mark"><%= link_to t('site.name'), 'http://social-stream.dit.upm.es/' %></li>
11
11
  </ul>
12
12
  </div>
@@ -5,8 +5,11 @@
5
5
  <ul>
6
6
  <% representations.each do |representation| %>
7
7
  <li>
8
- <% pending_total = representation.mailbox.notifications.not_trashed.unread.count %>
9
- <%= link_to truncate_name(representation.name, :length => 15) + (content_tag(:span, pending_total.to_s, :class => "switch_pending_count") if pending_total > 0), { :s => representation.slug }, { :style => "background: transparent url('#{ image_path representation.logo.url(:representation)}') no-repeat left center;margin-left:2px;" } %>
8
+ <%= content_tag :span do %>
9
+ <%= link_to truncate_name(representation.name, :length => 15), { :s => representation.slug }, { :style => "background: transparent url('#{ image_path representation.logo.url(:representation)}') no-repeat left center;margin-left:2px;" } %>
10
+ <% pending_total = representation.mailbox.notifications.not_trashed.unread.count %>
11
+ <%= link_to content_tag(:span, pending_total.to_s, :class => "switch_pending_count"), notifications_path(:s => representation.slug), { :style => 'margin: 1px; padding: 0;' } if pending_total > 0 %>
12
+ <% end %>
10
13
  </li>
11
14
  <% end %>
12
15
  </ul>
@@ -0,0 +1,32 @@
1
+ <div class="block" id="language_settings">
2
+ <div class="header">
3
+ <div class="header_text">
4
+ <%= t("account.lang.change")%>
5
+ </div>
6
+ <div class="header_icon_right">
7
+ <%= link_to (image_tag('btn/edit.png')), "javascript:showSettings(\"language_settings\");" %>
8
+ </div>
9
+ </div>
10
+ <div id="lang_form_briefing" class="settings_briefing content">
11
+ <div class="form_row">
12
+ <%= t('settings.lang_change.briefing')%>
13
+ </div>
14
+ </div>
15
+ <div class="content settings_content" id="language_settings_content" style="display:none;">
16
+ <%= form_tag update_all_settings_path, :method => :put, :id => 'form_lang', :remote => false do %>
17
+ <div class="form_row">
18
+ <div class="form_label"><%= label_tag :language, t('settings.lang_change.name') %></div>
19
+ <div class="form_field">
20
+ <%= select_tag(:language, options_for_select(I18n.available_locales.map{|l| [ l.to_s, l.to_s ] }, current_user.language), :class => 'form_tag', :onchange => "$(\'#form_lang\').submit();" )%>
21
+ </div>
22
+ </div>
23
+ <div class="actions center">
24
+ <%= hidden_field_tag :settings_section, :language %>
25
+ <noscript>
26
+ <%= submit_tag "Update Settings", :class => "button" %>
27
+ </noscript>
28
+ </div>
29
+ <% end%>
30
+ </div>
31
+ </div>
32
+
@@ -31,4 +31,4 @@
31
31
  </ul>
32
32
  <% end %>
33
33
  </div>
34
- </div>
34
+ </div>
@@ -372,6 +372,8 @@ en:
372
372
  activity: "Read wall"
373
373
  represent:
374
374
  nil: "Administrate"
375
+ notify:
376
+ nil: "Notify via email"
375
377
  detailed:
376
378
  create:
377
379
  activity: "Post to \"%{relation}\" wall"
@@ -382,6 +384,8 @@ en:
382
384
  tie: "See contacts in levels: %{relations} and %{public}"
383
385
  represent:
384
386
  nil: "Change session to act as %{subject}"
387
+ notify:
388
+ nil: "Updates of contacts at %{relation} will be sent to your email"
385
389
  of_relation:
386
390
  choose: "2. Permissions in <strong>%{name}</strong> sphere"
387
391
  privacy:
@@ -433,6 +437,7 @@ en:
433
437
  briefing: "Change your email"
434
438
  lang_change:
435
439
  briefing: "Change your language"
440
+ name: "Change your language"
436
441
  error: "Some errors raised when saving your changes"
437
442
  for: "Settings for"
438
443
  main: "Settings"
@@ -371,6 +371,8 @@ es:
371
371
  activity: "Leer muro"
372
372
  represent:
373
373
  nil: "Administrar"
374
+ notify:
375
+ nil: "Notificar por email"
374
376
  detailed:
375
377
  create:
376
378
  activity: "Publicar en el muro de\"%{relation}\""
@@ -381,6 +383,8 @@ es:
381
383
  tie: "Ver contactos en los niveles: %{relations} y %{public}"
382
384
  represent:
383
385
  nil: "Cambiar sesión para actuar en nombre de %{subject}"
386
+ notify:
387
+ nil: "Las actividades de los contactos en %{relation} se te enviarán al email"
384
388
  of_relation:
385
389
  choose: "2. Permisos para <strong>%{name}</strong>"
386
390
  privacy:
@@ -430,6 +434,9 @@ es:
430
434
  briefing: "Te permite cancelar tu cuenta"
431
435
  email_change:
432
436
  briefing: "Cambia tu email"
437
+ lang_change:
438
+ briefing: "Cambia tu idioma"
439
+ name: "Cambia tu idioma"
433
440
  error: "Hubo errores al guardar los cambios"
434
441
  for: "Ajustes para"
435
442
  main: "Ajustes"
@@ -0,0 +1,88 @@
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
@@ -0,0 +1,15 @@
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
@@ -14,14 +14,22 @@ module SocialStream
14
14
  end
15
15
  end
16
16
 
17
- initializer "social_stream-base.mime_types" do
17
+ initializer "social_stream-base.mime_types" do
18
18
  Mime::Type.register 'application/xrd+xml', :xrd
19
19
  end
20
20
 
21
- initializer "social_stream-base.controller_helpers" do
21
+ initializer "social_stream-base.model.supertype" do
22
+ ActiveSupport.on_load(:active_record) do
23
+ include SocialStream::Models::Subtype::ActiveRecord
24
+ include SocialStream::Models::Supertype::ActiveRecord
25
+ end
26
+ end
27
+
28
+ initializer "social_stream-base.controller.helpers" do
22
29
  ActiveSupport.on_load(:action_controller) do
23
30
  include SocialStream::Controllers::Helpers
24
31
  include SocialStream::Controllers::CancanDeviseIntegration
32
+ include SocialStream::Controllers::I18nIntegration
25
33
  end
26
34
  end
27
35
 
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Base
3
- VERSION = "0.11.2".freeze
3
+ VERSION = "0.12.0".freeze
4
4
  end
5
5
  end