social_stream-base 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/flags/de.png +0 -0
  3. data/app/assets/images/flags/fr.png +0 -0
  4. data/app/assets/images/flags/hu.png +0 -0
  5. data/app/assets/images/flags/nl.png +0 -0
  6. data/app/assets/javascripts/social_stream/actor.js +34 -0
  7. data/app/assets/javascripts/social_stream/contact.js +40 -5
  8. data/app/assets/javascripts/social_stream/flash.js +6 -1
  9. data/app/assets/javascripts/social_stream/group.js +6 -5
  10. data/app/assets/javascripts/social_stream/relation_customs.js +0 -1
  11. data/app/assets/stylesheets/social_stream/base/adjust/layout/_adjust.css.sass +3 -0
  12. data/app/assets/stylesheets/social_stream/base/buttons/_buttons.scss.sass +0 -2
  13. data/app/assets/stylesheets/social_stream/base/contacts/_contacts.css.sass +1 -11
  14. data/app/assets/stylesheets/social_stream/base/contacts/layouts/_contacts.css.sass +1 -29
  15. data/app/assets/stylesheets/social_stream/base/layouts/_header.css.sass +0 -1
  16. data/app/assets/stylesheets/social_stream/base/mixins/_buttons.css.sass +5 -0
  17. data/app/assets/stylesheets/social_stream/base/mixins/_layout.css.sass +36 -7
  18. data/app/controllers/actors_controller.rb +25 -0
  19. data/app/controllers/contacts_controller.rb +38 -8
  20. data/app/controllers/groups_controller.rb +2 -21
  21. data/app/controllers/profiles_controller.rb +4 -0
  22. data/app/controllers/settings_controller.rb +12 -2
  23. data/app/controllers/users_controller.rb +0 -8
  24. data/app/helpers/contacts_helper.rb +8 -0
  25. data/app/models/activity.rb +19 -6
  26. data/app/models/actor.rb +49 -11
  27. data/app/models/contact.rb +12 -5
  28. data/app/models/group.rb +13 -11
  29. data/app/models/permission.rb +30 -0
  30. data/app/models/relation.rb +17 -7
  31. data/app/models/relation/custom.rb +2 -40
  32. data/app/models/relation/follow.rb +8 -2
  33. data/app/models/relation/owner.rb +10 -0
  34. data/app/models/relation/single.rb +7 -4
  35. data/app/models/site.rb +1 -1
  36. data/app/models/tie.rb +8 -4
  37. data/app/views/contacts/_add_button.html.erb +9 -0
  38. data/app/views/contacts/_button.html.erb +3 -3
  39. data/app/views/contacts/_button_multiple.html.erb +4 -0
  40. data/app/views/contacts/_button_simple.html.erb +17 -0
  41. data/app/views/contacts/_new_modal.html.erb +22 -0
  42. data/app/views/contacts/destroy.js.erb +5 -4
  43. data/app/views/contacts/update.js.erb +5 -4
  44. data/app/views/devise/confirmations/new.html.erb +14 -9
  45. data/app/views/frontpage/_presentation.html.erb +2 -2
  46. data/app/views/groups/_form.html.erb +20 -20
  47. data/app/views/groups/show.html.erb +5 -5
  48. data/app/views/layouts/_header_dropdown_menu.html.erb +3 -5
  49. data/app/views/layouts/_header_signed_in.erb +3 -3
  50. data/app/views/layouts/_logo_in.html.erb +1 -1
  51. data/app/views/layouts/application.html.erb +2 -0
  52. data/app/views/permissions/_list.html.erb +1 -1
  53. data/app/views/profiles/_avatar.html.erb +1 -5
  54. data/app/views/profiles/_avatar_edit.html.erb +5 -0
  55. data/app/views/profiles/_comunication-info.html.erb +2 -36
  56. data/app/views/profiles/_comunication-info_edit.html.erb +27 -0
  57. data/app/views/profiles/_edit_icon.html.erb +0 -1
  58. data/app/views/profiles/_experience.html.erb +1 -6
  59. data/app/views/profiles/_experience_edit.html.erb +5 -0
  60. data/app/views/profiles/_personal.html.erb +1 -39
  61. data/app/views/profiles/_personal_edit.html.erb +31 -0
  62. data/app/views/profiles/_profile_edit.html.erb +7 -0
  63. data/app/views/profiles/_tags.html.erb +1 -4
  64. data/app/views/profiles/_tags_edit.html.erb +4 -0
  65. data/app/views/profiles/edit.html.erb +24 -0
  66. data/app/views/settings/_notifications.html.erb +12 -4
  67. data/app/views/users/show.html.erb +5 -5
  68. data/config/locales/de.yml +654 -0
  69. data/config/locales/en.yml +20 -9
  70. data/config/locales/es.yml +151 -140
  71. data/config/locales/fr.yml +656 -0
  72. data/config/locales/hu.yml +653 -0
  73. data/config/locales/nl.yml +656 -0
  74. data/config/locales/pt.yml +250 -239
  75. data/config/locales/rails.de.yml +203 -0
  76. data/config/locales/rails.fr.yml +222 -0
  77. data/config/locales/rails.hu.yml +199 -0
  78. data/config/locales/rails.nl.yml +199 -0
  79. data/config/locales/zh.yml +214 -202
  80. data/config/routes.rb +22 -30
  81. data/db/migrate/20130708152633_set_group_owners.rb +19 -0
  82. data/db/migrate/20130723133530_actor_notification_settings.rb +10 -0
  83. data/lib/generators/social_stream/base/templates/initializer.rb +13 -7
  84. data/lib/rails/social_stream.rb +2 -0
  85. data/lib/social_stream/base.rb +27 -7
  86. data/lib/social_stream/base/ability.rb +3 -5
  87. data/lib/social_stream/base/autoload.rb +1 -0
  88. data/lib/social_stream/base/version.rb +1 -1
  89. data/lib/social_stream/controllers/authorship.rb +18 -0
  90. data/lib/social_stream/controllers/helpers.rb +18 -4
  91. data/lib/social_stream/controllers/objects.rb +2 -8
  92. data/lib/social_stream/controllers/subjects.rb +9 -2
  93. data/lib/social_stream/models/supertype.rb +2 -0
  94. data/lib/social_stream/population/activity_object.rb +6 -8
  95. data/lib/social_stream/routing/mapper.rb +52 -0
  96. data/social_stream-base.gemspec +4 -7
  97. data/spec/controllers/groups_controller_spec.rb +19 -8
  98. data/spec/controllers/posts_controller_spec.rb +114 -147
  99. data/spec/models/post_authorization_spec.rb +190 -204
  100. data/spec/models/post_spec.rb +17 -63
  101. data/vendor/assets/javascripts/bootstrap-multiselect.js +434 -127
  102. metadata +48 -29
  103. data/app/assets/javascripts/social_stream/follow.js +0 -28
  104. data/app/controllers/followers_controller.rb +0 -34
  105. data/app/helpers/followers_helper.rb +0 -5
  106. data/app/views/contacts/_link_follow.html.erb +0 -16
  107. data/app/views/followers/destroy.js.erb +0 -1
  108. data/app/views/followers/index.html.erb +0 -30
  109. data/app/views/followers/update.js.erb +0 -3
  110. data/app/views/frontpage/_characteristics.html.erb +0 -23
  111. data/lib/social_stream/routing/constraints/custom.rb +0 -11
  112. data/lib/social_stream/routing/constraints/follow.rb +0 -11
  113. data/spec/controllers/followers_controller_spec.rb +0 -37
@@ -1,12 +1,9 @@
1
1
  class GroupsController < ApplicationController
2
2
  include SocialStream::Controllers::Subjects
3
+ include SocialStream::Controllers::Authorship
3
4
 
4
5
  before_filter :authenticate_user!, :except => [ :index, :show ]
5
6
 
6
- # Set group founder to current_subject
7
- # Must do before authorization
8
- before_filter :set_founder, :only => [ :new, :create ]
9
-
10
7
  load_and_authorize_resource
11
8
 
12
9
  respond_to :html, :js
@@ -18,7 +15,7 @@ class GroupsController < ApplicationController
18
15
  def create
19
16
  create! do |success, failure|
20
17
  success.html {
21
- self.current_subject = @group
18
+ self.current_subject = resource
22
19
  redirect_to :home
23
20
  }
24
21
  end
@@ -32,20 +29,4 @@ class GroupsController < ApplicationController
32
29
  }
33
30
  end
34
31
  end
35
-
36
- protected
37
-
38
- # Overwrite resource method to support slug
39
- # See InheritedResources::BaseHelpers#resource
40
- def resource
41
- @group ||= end_of_association_chain.find_by_slug!(params[:id])
42
- end
43
-
44
- private
45
-
46
- def set_founder
47
- params[:group] ||= {}
48
- params[:group][:author_id] ||= current_subject.try(:actor_id)
49
- params[:group][:user_author_id] ||= current_user.try(:actor_id)
50
- end
51
32
  end
@@ -13,6 +13,10 @@ class ProfilesController < ApplicationController
13
13
  end
14
14
  end
15
15
 
16
+ def edit
17
+ current_profile
18
+ end
19
+
16
20
  def update
17
21
  current_profile.update_attributes profile_params
18
22
 
@@ -1,7 +1,7 @@
1
1
  class SettingsController < ApplicationController
2
-
2
+
3
3
  before_filter :authenticate_user!
4
-
4
+
5
5
  def index
6
6
  end
7
7
 
@@ -20,6 +20,16 @@ class SettingsController < ApplicationController
20
20
  current_subject.notify_by_email = false if notify_by_email.eql? "never"
21
21
  current_subject.notify_by_email = true if notify_by_email.eql? "always"
22
22
  end
23
+
24
+ # Custom notification settings
25
+ if params[:notification_settings].present?
26
+ notification_settings = {}
27
+ params[:notification_settings].each_pair do |key, setting|
28
+ notification_settings[key.to_sym] = false if setting.eql? "never"
29
+ notification_settings[key.to_sym] = true if setting.eql? "always"
30
+ end
31
+ current_subject.update_attribute(:notification_settings, notification_settings)
32
+ end
23
33
  end
24
34
 
25
35
  #Updating language
@@ -21,12 +21,4 @@ class UsersController < ApplicationController
21
21
  def new; end; def create; end
22
22
  # Not supported yet
23
23
  def destroy; end
24
-
25
- protected
26
-
27
- # Overwrite resource method to support slug
28
- # See InheritedResources::BaseHelpers#resource
29
- def resource
30
- @user ||= end_of_association_chain.find_by_slug!(params[:id])
31
- end
32
24
  end
@@ -43,4 +43,12 @@ module ContactsHelper
43
43
  def current_contact_section? section
44
44
  params[:type] == section.to_s
45
45
  end
46
+
47
+ def contact_select_options options
48
+ if !options.empty? && options.first.respond_to?(:last) && Array === options.first.last
49
+ grouped_options_for_select(options)
50
+ else
51
+ options_for_select(options)
52
+ end
53
+ end
46
54
  end
@@ -260,12 +260,25 @@ class Activity < ActiveRecord::Base
260
260
  return true unless notificable?
261
261
  #Avaible verbs: follow, like, make-friend, post, update, join
262
262
 
263
- if direct_object.is_a? Comment
264
- participants.each do |p|
265
- p.notify(notification_subject, "Youre not supposed to see this", self) unless p == sender
266
- end
267
- elsif ['like','follow','make-friend','post','update', 'join'].include? verb and !reflexive?
268
- receiver.notify(notification_subject, "Youre not supposed to see this", self)
263
+ case
264
+ when direct_object.is_a?(Comment)
265
+ participants.each do |p|
266
+ send_mail = p.subject.notification_settings[:someone_comments_on_my_post]
267
+ p.notify(notification_subject, "Youre not supposed to see this", self, true, nil, send_mail) unless p == sender
268
+ end
269
+ when reflexive?
270
+ return true
271
+ when ['like'].include?(verb)
272
+ send_mail = receiver.subject.notification_settings[:someone_likes_my_post]
273
+ receiver.notify(notification_subject, "Youre not supposed to see this", self, true, nil, send_mail)
274
+ when ['follow'].include?(verb)
275
+ send_mail = receiver.subject.notification_settings[:someone_adds_me_as_a_contact]
276
+ receiver.notify(notification_subject, "Youre not supposed to see this", self, true, nil, send_mail)
277
+ when ['make-friend'].include?(verb)
278
+ send_mail = receiver.subject.notification_settings[:someone_confirms_my_contact_request]
279
+ receiver.notify(notification_subject, "Youre not supposed to see this", self, true, nil, send_mail)
280
+ when ['post', 'update', 'join'].include?(verb)
281
+ receiver.notify(notification_subject, "Youre not supposed to see this", self)
269
282
  end
270
283
  true
271
284
  end
data/app/models/actor.rb CHANGED
@@ -28,7 +28,9 @@ class Actor < ActiveRecord::Base
28
28
  acts_as_messageable
29
29
 
30
30
  acts_as_url :name, :url_attribute => :slug
31
-
31
+
32
+ serialize :notification_settings
33
+
32
34
  has_one :profile,
33
35
  dependent: :destroy,
34
36
  inverse_of: :actor
@@ -132,6 +134,12 @@ class Actor < ActiveRecord::Base
132
134
  joins(:received_contacts).merge(Contact.active.sent_by(a))
133
135
  }
134
136
 
137
+ scope :not_contacted_from, lambda { |a|
138
+ if a.present?
139
+ where(arel_table[:id].not_in(a.sent_active_contact_ids + [a.id]))
140
+ end
141
+ }
142
+
135
143
  scope :followed, joins(:activity_object).merge(ActivityObject.followed)
136
144
 
137
145
  scope :followed_by, lambda { |a|
@@ -143,7 +151,7 @@ class Actor < ActiveRecord::Base
143
151
 
144
152
  scope :subject_type, lambda { |t|
145
153
  if t.present?
146
- where(subject_type: t.classify)
154
+ where(subject_type: t.split(',').map(&:classify))
147
155
  end
148
156
  }
149
157
 
@@ -217,15 +225,30 @@ class Actor < ActiveRecord::Base
217
225
  # They usually include {Relation::Custom} but may also include other system-defined
218
226
  # relations that are not editable but appear in add contact buttons
219
227
  def relations_list
220
- Relation.extra_list(subject) + relation_customs
228
+ Relation.system_list(subject) + relation_customs
221
229
  end
222
230
 
223
231
  # The relations offered in the "Add contact" button when subjects
224
232
  # add new contacts
225
- def relations_for_button
233
+ def relations_for_select
226
234
  relations_list
227
235
  end
228
236
 
237
+ # Return an object of choices suitable for the contact add button or modal
238
+ def options_for_contact_select
239
+ relations_for_select.map{ |r| [ r.name, r.id ] }
240
+ end
241
+
242
+ # Options for contact select are simple
243
+ def options_for_contact_select_simple?
244
+ relations_list.count == 1
245
+ end
246
+
247
+ # Returns the type for contact select, :simple or :multiple
248
+ def options_for_contact_select_type
249
+ options_for_contact_select_simple? ? :simple : :multiple
250
+ end
251
+
229
252
  # All the {Actor Actors} this one has ties with:
230
253
  #
231
254
  # actor.contact_actors #=> array of actors that sent and receive ties from actor
@@ -293,7 +316,7 @@ class Actor < ActiveRecord::Base
293
316
  if options[:relations].present?
294
317
  as = as.merge(Tie.related_by(options[:relations]))
295
318
  else
296
- as = as.merge(Relation.where(:type => ['Relation::Custom', 'Relation::Public']))
319
+ as = as.merge(Relation.positive)
297
320
  end
298
321
 
299
322
  as
@@ -328,7 +351,7 @@ class Actor < ActiveRecord::Base
328
351
  # Return a contact to subject. Create it if it does not exist
329
352
  def contact_to!(subject)
330
353
  contact_to(subject) ||
331
- sent_contacts.create!(:receiver => Actor.normalize(subject))
354
+ sent_contacts.create!(receiver_id: Actor.normalize_id(subject))
332
355
  end
333
356
 
334
357
  # The {Contact} of this {Actor} to self (totally close!)
@@ -434,11 +457,21 @@ class Actor < ActiveRecord::Base
434
457
 
435
458
  # The default {Relation Relations} for sharing an {Activity} owned
436
459
  # by this {Actor}
460
+ #
461
+ # Activities are shared with all the contacts by default.
462
+ #
463
+ # You can change this behaviour with a decorator, overwriting this method.
464
+ # For example, if you want the activities shared publicly by default, create
465
+ # a decorator in app/decorators/actor_decorator.rb with
466
+ # Actor.class_eval do
467
+ # def activity_relations
468
+ # [ Relation::Public.instance ]
469
+ # end
470
+ # end
471
+ #
437
472
  def activity_relations
438
- SocialStream.relation_model == :custom ?
439
- relations.
440
- allowing('read', 'activity') :
441
- [ Relation::Public.instance ]
473
+ relations.
474
+ allowing('read', 'activity')
442
475
  end
443
476
 
444
477
  # The ids of the default {Relation Relations} for sharing an {Activity}
@@ -516,7 +549,12 @@ class Actor < ActiveRecord::Base
516
549
  }
517
550
  }
518
551
  end
519
-
552
+
553
+ def notification_settings
554
+ self.update_attribute(:notification_settings, SocialStream.default_notification_settings) unless super
555
+ super
556
+ end
557
+
520
558
  private
521
559
 
522
560
  # After create callback
@@ -49,10 +49,10 @@ class Contact < ActiveRecord::Base
49
49
  }
50
50
 
51
51
  scope :in_direction_with, lambda { |subject, d = 'sent'|
52
- if d == 'sent'
53
- sent_by(subject).joins(:receiver)
54
- else
52
+ if d == 'received'
55
53
  received_by(subject).joins(:sender)
54
+ else
55
+ sent_by(subject).joins(:receiver)
56
56
  end
57
57
  }
58
58
 
@@ -180,9 +180,16 @@ class Contact < ActiveRecord::Base
180
180
  end
181
181
  end
182
182
 
183
- # Return an array of options suitable for the contact add button
183
+ # Return an object of choices suitable for the contact add button
184
+ #
184
185
  def options_for_select
185
- sender.relations_for_button.map{ |r| [ r.name, r.id ] }
186
+ sender.options_for_contact_select
187
+ end
188
+
189
+ # Options for select are simple or multiple
190
+ #
191
+ def options_for_select_type
192
+ sender.options_for_contact_select_type
186
193
  end
187
194
 
188
195
  private
data/app/models/group.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  class Group < ActiveRecord::Base
7
7
  include SocialStream::Models::Subject
8
8
 
9
- attr_accessor :_participants
9
+ attr_accessor :owners
10
10
 
11
11
  delegate :description, :description=, :to => :profile!
12
12
 
@@ -19,14 +19,14 @@ class Group < ActiveRecord::Base
19
19
  private
20
20
 
21
21
  # Creates ties from founder to the group, based on _relation_ids,
22
- # and ties from the group to founder and participants.
22
+ # and ties from the group to founder and owners.
23
23
  def create_ties
24
- create_ties_from_founder
25
- create_ties_to_participants
24
+ create_ties_from_author
25
+ create_ties_to_owners
26
26
  end
27
27
 
28
28
  # Creates the ties from the founder to the group
29
- def create_ties_from_founder
29
+ def create_ties_from_author
30
30
  =begin
31
31
  # FIXME: need to define a proper relation for this case. Maybe a system defined relation
32
32
  author.sent_contacts.create! :receiver_id => actor_id,
@@ -39,18 +39,20 @@ class Group < ActiveRecord::Base
39
39
  =end
40
40
  end
41
41
 
42
- # Creates the ties from the group to the participants
43
- def create_ties_to_participants
44
- @_participants ||= ""
42
+ # Creates the ties from the group to the owners added in the group creation form
43
+ #
44
+ # The system-defined Relation::Owner is used for the ties
45
+ def create_ties_to_owners
46
+ @owners ||= ""
45
47
 
46
- participant_ids = ([ author_id, user_author_id ] | @_participants.split(',').map(&:to_i)).uniq
48
+ owner_ids = ([ author_id, user_author_id ] | @owners.split(',').map(&:to_i)).uniq
47
49
 
48
- participant_ids.each do |a|
50
+ owner_ids.each do |a|
49
51
  c =
50
52
  sent_contacts.create! :receiver_id => a,
51
53
  :user_author => user_author
52
54
 
53
- c.relation_ids = Array.wrap(relation_customs.sort.first.id)
55
+ c.relation_ids = Array.wrap(::Relation::Owner.instance.id)
54
56
  end
55
57
  end
56
58
  end
@@ -44,6 +44,36 @@ class Permission < ActiveRecord::Base
44
44
  end
45
45
 
46
46
  class << self
47
+ # Obtains the available permissions for subject, as they are configured
48
+ # in config.available_permissions entry in config/initializers/social_stream.rb
49
+ #
50
+ # It takes STI into account, so it will try to load the permissions of the base_class
51
+ # if the class is not found
52
+ def available(subject)
53
+ class_name = subject.class.to_s.underscore
54
+ base_class_name = subject.class.base_class.to_s.underscore
55
+
56
+ candidates = [ class_name, class_name.to_sym ]
57
+
58
+ if class_name != base_class_name
59
+ candidates += [ base_class_name, base_class_name.to_sym ]
60
+ end
61
+
62
+ list = nil
63
+
64
+ candidates.each do |n|
65
+ list = SocialStream.available_permissions[n]
66
+
67
+ break if list.present?
68
+ end
69
+
70
+ if list.blank?
71
+ raise "You need to configure SocialStream.available_permissions[:#{ class_name }] in config/initializers/social_stream.rb"
72
+ end
73
+
74
+ instances list
75
+ end
76
+
47
77
  # Finds or creates in the database the instances of the permissions described in
48
78
  # {ary} by arrays of [ action, object ]
49
79
  def instances ary
@@ -41,7 +41,7 @@
41
41
  # It sets the {Audience} that has access to it, and the {Permission Permissions} that rule that access.
42
42
  #
43
43
  class Relation < ActiveRecord::Base
44
- Positive = %w{ custom public follow }
44
+ Positive = %w{ custom public follow owner }
45
45
  Negative = %w{ reject }
46
46
 
47
47
  has_many :relation_permissions, :dependent => :destroy
@@ -152,7 +152,7 @@ class Relation < ActiveRecord::Base
152
152
  def ids_shared_with(subject)
153
153
  ids = [Relation::Public.instance.id]
154
154
 
155
- if SocialStream.relation_model == :custom && subject.present?
155
+ if subject.present?
156
156
  # Subject own defined custom relations
157
157
  ids += subject.relation_ids
158
158
  # From Ties sent by other subject
@@ -168,11 +168,14 @@ class Relation < ActiveRecord::Base
168
168
 
169
169
  # Default extra relations that are displayed in {Actor}'s relation list,
170
170
  # typically in /relation/customs
171
- def extra_list subject
172
- l = SocialStream.list_relations[subject.class.to_s.underscore]
173
- return [] if l.blank?
174
-
175
- l.map{ |r| "Relation::#{ r.to_s.classify }".constantize.instance }
171
+ def system_list subject
172
+ name = subject.class.to_s.underscore
173
+ list = SocialStream.system_relations[name] ||
174
+ SocialStream.system_relations[name.to_sym]
175
+
176
+ return [] if list.blank?
177
+
178
+ list.map{ |r| "Relation::#{ r.to_s.classify }".constantize.instance }
176
179
  end
177
180
  end
178
181
 
@@ -181,6 +184,13 @@ class Relation < ActiveRecord::Base
181
184
  Relation.mode(sender_type, receiver_type)
182
185
  end
183
186
 
187
+ # Compare two relations
188
+ def <=> rel
189
+ return -1 if rel.is_a?(Public)
190
+
191
+ permissions.count <=> rel.permissions.count
192
+ end
193
+
184
194
  # Is this {Relation} a Positive one?
185
195
  def positive?
186
196
  self.class.positive_names.include?(self.class.to_s)
@@ -2,7 +2,7 @@
2
2
  # of relations is created for him. Afterwards, the {SocialStream::Models::Subject subject}
3
3
  # can customize them and adapt them to his own preferences.
4
4
  #
5
- # Default relations are defined at config/relations.yml
5
+ # Default relations are defined at config/initializers/social_stream.rb
6
6
  #
7
7
  class Relation::Custom < Relation
8
8
  # This is weird. We must call #inspect before has_ancestry for Relation::Custom
@@ -57,11 +57,6 @@ class Relation::Custom < Relation
57
57
 
58
58
  rels.values
59
59
  end
60
-
61
- # A relation in the top of a strength hierarchy
62
- def strongest
63
- roots
64
- end
65
60
  end
66
61
 
67
62
  # The subject who defined of this relation
@@ -69,41 +64,8 @@ class Relation::Custom < Relation
69
64
  actor.subject
70
65
  end
71
66
 
72
- # Compare two relations
73
- def <=> rel
74
- return -1 if rel.is_a?(Public)
75
-
76
- if ancestor_ids.include?(rel.id)
77
- 1
78
- elsif rel.ancestor_ids.include?(id)
79
- -1
80
- else
81
- 0
82
- end
83
- end
84
-
85
- # Other relations below in the same hierarchy that this relation
86
- def weaker
87
- descendants
88
- end
89
-
90
- # Relations below or at the same level of this relation
91
- def weaker_or_equal
92
- subtree
93
- end
94
-
95
- # Other relations above in the same hierarchy that this relation
96
- def stronger
97
- ancestors
98
- end
99
-
100
- # Relations above or at the same level of this relation
101
- def stronger_or_equal
102
- path
103
- end
104
-
105
67
  def available_permissions
106
- Permission.instances SocialStream.available_permissions[subject.class.to_s.underscore]
68
+ Permission.available(subject)
107
69
  end
108
70
 
109
71
  private