users: add /profile page (fix #4151).

* Add /profile, /profile.json endpoints.
* Make "My Account" link to /profile.
* Add 'User ID' field to profile page.
This commit is contained in:
evazion
2019-09-01 14:08:55 -05:00
parent a932b25608
commit ff92b32f02
9 changed files with 51 additions and 8 deletions

View File

@@ -9,7 +9,7 @@ module Maintenance
def create
CurrentUser.user.refresh_counts!
flash[:notice] = "Counts have been refreshed"
redirect_to user_path(CurrentUser.id)
redirect_to profile_path
end
end
end

View File

@@ -36,10 +36,21 @@ class UsersController < ApplicationController
def show
@user = User.find(params[:id])
@presenter = UserPresenter.new(@user)
respond_with(@user, methods: @user.full_attributes)
end
def profile
@user = CurrentUser.user
if @user.is_member?
respond_with(@user, methods: @user.full_attributes, template: "users/show")
elsif request.format.html?
redirect_to new_session_path
else
raise ActiveRecord::RecordNotFound
end
end
def create
@user = User.new(user_params(:create))
if !Danbooru.config.enable_recaptcha? || verify_recaptcha(model: @user)

View File

@@ -2,7 +2,7 @@
<% if CurrentUser.is_anonymous? %>
<%= nav_link_to("Sign in", new_session_path) %>
<% else %>
<%= nav_link_to("My Account #{CurrentUser.dmail_count}", user_path(CurrentUser.user)) %>
<%= nav_link_to("My Account #{CurrentUser.dmail_count}", profile_path) %>
<% end %>
<%= nav_link_to("Posts", posts_path) %>
<%= nav_link_to("Comments", comments_path(:group_by => "post")) %>

View File

@@ -119,7 +119,7 @@
<li><%= link_to "Sign in", new_session_path %></li>
<li><%= link_to "Sign up", new_user_path %></li>
<% else %>
<li><%= link_to "Profile", CurrentUser.user %></li>
<li><%= link_to "Profile", profile_path %></li>
<li><%= link_to "Settings", edit_user_path(CurrentUser.user) %></li>
<% if CurrentUser.is_gold? %>
<li><%= link_to "Change name", new_user_name_change_request_path %></li>

View File

@@ -12,7 +12,7 @@
<li>|</li>
<% if @user.id == CurrentUser.user.id %>
<%= subnav_link_to "Settings", edit_user_path(CurrentUser.user) %>
<%= subnav_link_to "Profile", user_path(CurrentUser.user) %>
<%= subnav_link_to "Profile", profile_path %>
<%= subnav_link_to "Messages #{CurrentUser.user.dmail_count}", dmails_current_folder_path %>
<% if !@user.is_platinum? %>

View File

@@ -2,6 +2,10 @@
<h2>Statistics</h2>
<table width="100%" class="user-statistics">
<tbody>
<tr>
<th>User ID</th>
<td><%= user.id %></td>
</tr>
<tr>
<th>Join Date</th>
<td><%= presenter.join_date %></td>

View File

@@ -2,11 +2,11 @@
<div id="a-show">
<h1><%= link_to_user @user %></h1>
<%= render "statistics", :presenter => @presenter, :user => @user %>
<%= render "statistics", presenter: @user.presenter, user: @user %>
<% if !CurrentUser.is_admin? && !@user.enable_privacy_mode? || CurrentUser.id == @user.id %>
<%= render "posts/partials/common/inline_blacklist" %>
<%= render "post_summary", :presenter => @presenter, :user => @user %>
<%= render "post_summary", presenter: @user.presenter, user: @user %>
<% end %>
</div>
</div>
@@ -14,7 +14,7 @@
<%= render "secondary_links" %>
<% content_for(:page_title) do %>
User - <%= @presenter.name %> - <%= Danbooru.config.app_name %>
User - <%= @user.presenter.name %> - <%= Danbooru.config.app_name %>
<% end %>
<% content_for(:html_header, auto_discovery_link_tag(:atom, comments_url(:atom, search: { post_tags_match: "user:#{@user.name}" }), title: "Comments on #{@user.name}'s uploads")) %>