Skip to content

Commit

Permalink
added count of research notes and comments on profile page (publiclab…
Browse files Browse the repository at this point in the history
…#2263)

* added count of research notes and comments on profile page

fixes publiclab#2262

* minor changes
  • Loading branch information
ViditChitkara authored and Souravirus committed Mar 12, 2018
1 parent 9e8fb19 commit f9290a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def profile
.limit(20)
@wikis = wikis.collect(&:parent).uniq

@comment_count = Comment.where(status: 0, uid: @user.uid).count

# User's social links
@github = @profile_user.social_link("github")
@twitter = @profile_user.social_link("twitter")
Expand Down
12 changes: 7 additions & 5 deletions app/views/users/profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@
</div>
<hr />

<span style="float:right;"><small><%= raw t('users.profile.joined_time_ago', :time_ago => distance_of_time_in_words(@user.created_at, Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' })) %></small></span>
<br>

<ul class="nav nav-tabs">
<span style="float:right;"><small><%= raw t('users.profile.joined_time_ago', :time_ago => distance_of_time_in_words(@user.created_at, Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' })) %></small></span>
<li class="active"><a href="#research" data-toggle="tab"><%= t('users.profile.research') %></a></li>
<li><a href="#coauthored" data-toggle="tab"><span class="hidden-sm hidden-xs"> <%= t('users.profile.Coauthored') %> (<%= @coauthored.size %>)</span></a></li>
<li><a href="#questions" data-toggle="tab"><i class="fa fa-comments"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.questions') %> (<%= Node.questions.where(status: 1, uid: @user.id).length %>)</span></a></li>
<li><a href="#comments" id="comments-tab" data-toggle="tab"><i class="fa fa-comment"></i><span class="hidden-sm hidden-xs"> Comments</span></a></li>
<li class="active"><a href="#research" data-toggle="tab"><i class="fa fa-file"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.research') %></span> <%= "(#{@notes.count})" %></a></li>
<li><a href="#coauthored" data-toggle="tab"><i class="fa fa-file-o"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.Coauthored') %></span> (<%= @coauthored.size %>)</a></li>
<li><a href="#questions" data-toggle="tab"><i class="fa fa-question-circle"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.questions') %></span> (<%= Node.questions.where(status: 1, uid: @user.id).length %>)</a></li>
<li><a href="#comments" id="comments-tab" data-toggle="tab"><i class="fa fa-comment"></i><span class="hidden-sm hidden-xs"> Comments</span> (<%= @comment_count %>)</a></li>
<li><a href="/profile/<%= @user.username %>/likes"><i class="fa fa-star"></i><span class="hidden-sm hidden-xs"> <%= t('users.profile.liked') %></span> (<%= @user.like_count %>)</a></li>
<li><a href="#barnstars" data-toggle="tab"><i class="fa fa-certificate"></i><span class="hidden-sm hidden-xs"> Barnstars</span> (<%= @user.user.try(:barnstars).try(:length) %>)</a></li>
</ul>
Expand Down

0 comments on commit f9290a4

Please sign in to comment.