Skip to content
Extraits de code Groupes Projets
Valider eef054dc rédigé par maxwell's avatar maxwell Validation de Maxwell Salzberg
Parcourir les fichiers

wip

parent c2bb483b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -31,11 +31,13 @@ module CommentsHelper
end
end
def commenting_disabled?
def commenting_disabled?(post)
return true unless user_signed_in?
if defined?(@commenting_disabled)
return @commenting_disabled
else
@commenting_disabled
elsif defined?(@stream)
!@stream.can_comment?(post)
else
false
end
end
......
......@@ -22,7 +22,7 @@
.likes_container
= render "likes/likes_container", :target_id => comment.id, :likes_count => comment.likes_count, :target_type => "Comment"
- unless commenting_disabled?
- unless commenting_disabled?(post)
%span.like_action
= like_action(comment, current_user)
......@@ -13,6 +13,6 @@
-else
= render :partial => 'comments/comment', :collection => post.comments, :locals => {:post => post}
- unless commenting_disabled?
- unless commenting_disabled?(post)
.new_comment_form_wrapper{:class => comment_form_wrapper_class(post)}
= new_comment_form(post.id, current_user)
......@@ -31,7 +31,7 @@
= render 'photos/index', :photos => @posts
- else
#main_stream.stream
= render 'shared/stream', :posts => @posts, :commenting_disabled => commenting_disabled?
= render 'shared/stream', :posts => @posts
#pagination
=link_to(t('more'), next_page_path, :class => 'paginate')
......
......@@ -8,7 +8,7 @@
- if @post.is_a?(Photo)
= render 'posts/photo', :post => @post
- else
= render 'shared/stream_element', :post => @post, :commenting_disabled => commenting_disabled?
= render 'shared/stream_element', :post => @post, :commenting_disabled => commenting_disabled?(@post)
%br
%br
%br
......@@ -4,4 +4,4 @@
.stream
= render :partial => 'shared/stream_element',
:locals => {:post => @post, :commenting_disabled => commenting_disabled?, :expanded_info => true}
:locals => {:post => @post, :commenting_disabled => commenting_disabled?(@post), :expanded_info => true}
......@@ -4,6 +4,4 @@
= render :partial => 'shared/stream_element',
:collection => posts,
:as => :post,
:locals => { :commenting_disabled => commenting_disabled?}
:as => :post
......@@ -68,7 +68,7 @@
–
- unless commenting_disabled?
- unless commenting_disabled?(post)
%span.like_action
= like_action(post, current_user)
......@@ -84,4 +84,4 @@
.likes_container
= render "likes/likes_container", :target_id => post.id, :likes_count => post.likes_count, :current_user => current_user, :target_type => "Post"
= render "comments/comments", :post => post, :current_user => current_user, :commenting_disabled => commenting_disabled?
= render "comments/comments", :post => post, :current_user => current_user, :commenting_disabled => commenting_disabled?(post)
Fichier ajouté
Fichier ajouté
......@@ -14,6 +14,10 @@ class BaseStream
Rails.application.routes.url_helpers.mentions_path(opts)
end
def can_comment?(post)
true
end
def title
'a title'
end
......
......@@ -14,16 +14,12 @@ class TagStream < BaseStream
# @return [ActiveRecord::Association<Post>] AR association of posts
def posts
if tag_string.empty?
[]
else
@posts ||= StatusMessage.owned_or_visible_by_user(user).
joins(:tags).where(:tags => {:name => tag_array}).
for_a_stream(@max_time, @order)
end
return [] if tag_string.empty?
@posts ||= StatusMessage.owned_or_visible_by_user(user).
joins(:tags).where(:tags => {:name => tag_array}).
for_a_stream(@max_time, @order)
end
# @return [ActiveRecord::Association<Person>] AR association of people within stream's given aspects
def people
@people ||= posts.map{|p| p.author}.uniq
end
......@@ -32,6 +28,16 @@ class TagStream < BaseStream
I18n.translate('streams.tags.contacts_title')
end
def can_comment_on?(post)
@can_comment_cache ||= {}
@can_comment_cache[post.id] ||= contacts_in_stream.find{|contact| contact.person_id == post.author.id}.present?
@can_comment_cache[post.id]
end
def contacts_in_stream
@contacts_in_stream ||= Contact.where(:user => user, :person => people).all
end
private
def tag_string
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter