From ec309de27353187eb84a7173cda23b75c2af0f1b Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 29 Aug 2017 13:12:04 +0200 Subject: [PATCH] Add partial with participants on community show page. --- app/helpers/communities_helper.rb | 4 ++ app/views/communities/_participants.html.erb | 41 ++++++++++++++++++++ app/views/communities/show.html.erb | 37 ++---------------- 3 files changed, 49 insertions(+), 33 deletions(-) create mode 100644 app/views/communities/_participants.html.erb diff --git a/app/helpers/communities_helper.rb b/app/helpers/communities_helper.rb index fd70df758..beba4bf23 100644 --- a/app/helpers/communities_helper.rb +++ b/app/helpers/communities_helper.rb @@ -17,4 +17,8 @@ module CommunitiesHelper community.from_proposal? ? t("community.show.description.proposal") : t("community.show.description.investment") end + def is_author?(community, participant) + community.topics.pluck(:author_id).include?(participant.id) + end + end diff --git a/app/views/communities/_participants.html.erb b/app/views/communities/_participants.html.erb new file mode 100644 index 000000000..931ebf105 --- /dev/null +++ b/app/views/communities/_participants.html.erb @@ -0,0 +1,41 @@ +
+ + + + <% @participants.each do |participant| %> +
+
+ + <%= avatar_image( participant, seed: participant.id, size: 32, class: 'author-photo') %> + +
+ + + <%= link_to participant.name, user_path(participant)%> + + + <% if is_author?(@community, participant) %> +  •  + + <%= t("comments.comment.author") %> + + <% end %> + +
+ +
+
+ <% end %> + +
diff --git a/app/views/communities/show.html.erb b/app/views/communities/show.html.erb index 30cf7b7e0..6b07595ec 100644 --- a/app/views/communities/show.html.erb +++ b/app/views/communities/show.html.erb @@ -1,4 +1,5 @@
+
@@ -29,39 +30,9 @@

<%= t("community.show.sidebar.participate") %>

<%= link_to t("community.show.sidebar.new_topic"), new_community_topic_path(@community.id), class: "button expanded #{disabled_create_topic}", title: "#{disabled_info_title}" %> +
+
-
-
    -
  • - <%= link_to "#tab-participants" do %> -

    - <%= t("community.show.tab.participants") %> - (<%= @participants.count %>) -

    - <% end %> -
  • -
- - - - <% @participants.each do |participant| %> -
-
- <%= avatar_image( participant, seed: participant.id, size: 32, class: 'author-photo') %> -
- - <%= link_to participant.name, user_path(participant)%> - - <% if @community.topics.pluck(:author_id).include?(participant.id) %> -  •  - - <%= t("comments.comment.author") %> - - <% end %> -
-
-
- <% end %> -
+<%= render 'participants' %>