Skip to content

Commit

Permalink
added drafts link to profile page (#9837)
Browse files Browse the repository at this point in the history
  • Loading branch information
TildaDares authored Jun 29, 2021
1 parent d092648 commit 78bf29f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,12 @@ def self.recently_active_users(limit = 15, order = 'last_updated DESC')
end
end

def drafts
Node.where(uid: uid)
.where(status: 3, type: 'note')
.order('created DESC')
end

private

def decrease_likes_banned
Expand Down
3 changes: 3 additions & 0 deletions app/views/users/profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@
<li><h5><a href="/wikis/author/<%= @profile_user.name %>"><%= pluralize(@profile_user.revisions.count, 'wiki edit', plural: 'wiki edits') %></a></h5></li>
<li><h5><a href = "/tag/question:*/author/<%= params[:id] %>"><%= pluralize(Node.questions.where(status: 1, uid: @profile_user.id).length, 'question', plural:'questions') %></a></h5></li>
<li><h5><a href = "/profile/comments/<%= params[:id] %>"><%= pluralize(Comment.where(uid: @profile_user.id).count, 'comment', plural: 'comments') %></a></h5></li>
<% if current_user&.can_moderate? || @profile_user == current_user %>
<li><h5><a href='#'><%= pluralize(@profile_user.drafts.size, 'draft', plural: 'drafts' )%></a></h5></li>
<% end %>
<li><h5><a href = "/tag/activity:*/author/<%= params[:id] %>"><%= pluralize(@count_activities_posted, 'activity posted', plural:'activities posted') %> </a></h5></li>
<li><h5><a href = "/tag/replication:*/author/<%= params[:id] %>"><%= pluralize(@count_activities_attempted, 'activity attempted', plural:'activities attempted')%></a> </h5></li>
<li><h5><a href = "/tag/with:<%= @profile_user.username %>"><%= pluralize(Tag.find_nodes_by_type("with:#{@profile_user.username}").count, 'note co-authored', plural: 'notes co-authored')%></a> </h5></li>
Expand Down
5 changes: 5 additions & 0 deletions test/unit/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,9 @@ class UserTest < ActiveSupport::TestCase
user = users(:bob)
assert_equal user.subscriptions(:tag).size, 4
end

test 'user drafts' do
user = users(:jeff)
assert_not user.drafts.empty?
end
end

0 comments on commit 78bf29f

Please sign in to comment.