Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add drafts link to profile page #9837

Merged
merged 1 commit into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = 5, order = 'last_updated DESC')
end
end

def drafts
Node.where(uid: uid)
TildaDares marked this conversation as resolved.
Show resolved Hide resolved
.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?
TildaDares marked this conversation as resolved.
Show resolved Hide resolved
end
end