around_action :api_call_handle_error, :only => [:api_read, :api_users, :api_details, :api_gpx_files]
before_action :lookup_user_by_id, :only => [:api_read]
before_action :lookup_user_by_name, :only => [:set_status, :delete]
- before_action :allow_thirdparty_images, :only => [:view, :account]
+ before_action :allow_thirdparty_images, :only => [:show, :account]
def terms
@legale = params[:legale] || OSM.ip_to_country(request.remote_ip) || DEFAULT_LEGALE
render :xml => doc.to_s
end
- def view
+ def show
@user = User.find_by(:display_name => params[:display_name])
if @user &&
if params[:referer]
redirect_to params[:referer]
else
- redirect_to :action => "view"
+ redirect_to :action => "show"
end
end
else
if params[:referer]
redirect_to params[:referer]
else
- redirect_to :action => "view"
+ redirect_to :action => "show"
end
end
else
def set_status
@user.status = params[:status]
@user.save
- redirect_to :action => "view", :display_name => params[:display_name]
+ redirect_to user_path(:display_name => params[:display_name])
end
##
# delete a user, marking them as deleted and removing personal data
def delete
@user.delete
- redirect_to :action => "view", :display_name => params[:display_name]
+ redirect_to user_path(:display_name => params[:display_name])
end
##
flash[:error] = t("user.filter.not_an_administrator")
if params[:display_name]
- redirect_to :action => "view", :display_name => params[:display_name]
+ redirect_to user_path(:display_name => params[:display_name])
else
redirect_to :action => "login", :referer => request.fullpath
end
when DiaryEntry
url_for(:controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.user.display_name, :id => reportable.id)
when User
- url_for(:controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.display_name)
+ user_url(reportable)
when DiaryComment
url_for(:controller => reportable.diary_entry.class.name.underscore, :action => :view, :display_name => reportable.diary_entry.user.display_name, :id => reportable.diary_entry.id, :anchor => "comment#{reportable.id}")
when Note
elsif author.status == "deleted"
t("user.no_such_user.deleted")
else
- link_to h(author.display_name), link_options.merge(:controller => "user", :action => "view", :display_name => author.display_name)
+ link_to h(author.display_name), link_options.merge(:controller => "user", :action => "show", :display_name => author.display_name)
end
end
end
if current_user && current_user.administrator?
if user.has_role?(role)
image = "roles/#{role}"
- alt = t("user.view.role.revoke.#{role}")
- title = t("user.view.role.revoke.#{role}")
+ alt = t("user.show.role.revoke.#{role}")
+ title = t("user.show.role.revoke.#{role}")
url = revoke_role_path(:display_name => user.display_name, :role => role)
confirm = t("user_role.revoke.are_you_sure", :name => user.display_name, :role => role)
else
image = "roles/blank_#{role}"
- alt = t("user.view.role.grant.#{role}")
- title = t("user.view.role.grant.#{role}")
+ alt = t("user.show.role.grant.#{role}")
+ title = t("user.show.role.grant.#{role}")
url = grant_role_path(:display_name => user.display_name, :role => role)
confirm = t("user_role.grant.are_you_sure", :name => user.display_name, :role => role)
end
elsif user.has_role?(role)
image = "roles/#{role}"
- alt = t("user.view.role.#{role}")
- title = t("user.view.role.#{role}")
+ alt = t("user.show.role.#{role}")
+ title = t("user.show.role.#{role}")
end
if image
def friend_notification(friend)
with_recipient_locale friend.befriendee do
@friend = friend
- @viewurl = url_for(:controller => "user", :action => "view",
- :display_name => @friend.befriender.display_name)
+ @viewurl = user_url(@friend.befriender)
@friendurl = url_for(:controller => "user", :action => "make_friend",
:display_name => @friend.befriender.display_name)
@author = @friend.befriender.display_name
<%
set_title(changeset_list_title(params, current_user))
if params[:display_name]
- @heading = t('changeset.list.title_user', :user => link_to(params[:display_name], :controller => "user", :action => "view", :display_name => params[:display_name])).html_safe
+ @heading = t('changeset.list.title_user', :user => link_to(params[:display_name], user_path(:display_name => params[:display_name]))).html_safe
else
@heading = @title
end
if changeset.user.data_public?
entry.author do |author|
author.name changeset.user.display_name
- author.uri url_for(:controller => "user", :action => "view", :display_name => changeset.user.display_name, :only_path => false)
+ author.uri user_url(changeset.user, :only_path => false)
end
end
table.tr do |tr|
tr.th t("browse.changeset.belongs_to")
tr.td do |td|
- td.a h(changeset.user.display_name), :href => url_for(:controller => "user", :action => "view", :display_name => changeset.user.display_name, :only_path => false)
+ td.a h(changeset.user.display_name), :href => user_url(changeset.user, :only_path => false)
end
end
end
<li>
<%= link_to inbox_messages_path do %>
<span class='count-number'><%= number_with_delimiter(current_user.new_messages.size) %></span>
- <%= t('user.view.my messages') %>
+ <%= t('user.show.my messages') %>
<% end %>
</li>
<li>
- <%= link_to t('user.view.my profile'), user_path(:display_name => current_user.display_name) %>
+ <%= link_to t('user.show.my profile'), user_path(:display_name => current_user.display_name) %>
</li>
<li>
- <%= link_to t('user.view.my settings'), :controller => 'user', :action => 'account', :display_name => current_user.display_name %>
+ <%= link_to t('user.show.my settings'), :controller => 'user', :action => 'account', :display_name => current_user.display_name %>
</li>
<li class="divider"></li>
<li>
<h1><%= t ".title" %></h1>
<% end %>
-<p><%= raw t(".request_access", :app_name => link_to(@token.client_application.name, @token.client_application.url), :user => link_to(current_user.display_name, :controller => :user, :action => :view, :display_name => current_user.display_name)) %></p>
+<p><%= raw t(".request_access", :app_name => link_to(@token.client_application.name, @token.client_application.url), :user => link_to(current_user.display_name, user_path(current_user))) %></p>
<%= form_tag authorize_url do %>
<%= hidden_field_tag "oauth_token", @token.token %>
<p>
<% if user.creation_ip %>
<%= raw t 'user.list.summary',
- :name => link_to(h(user.display_name), :action => "view", :display_name => user.display_name),
+ :name => link_to(h(user.display_name), user_path(user)),
:ip_address => link_to(user.creation_ip, :ip => user.creation_ip),
:date => l(user.creation_time, :format => :friendly)
%>
<% else %>
<%= raw t 'user.list.summary_no_ip',
- :name => link_to(h(user.display_name), :action => "view", :display_name => user.display_name),
+ :name => link_to(h(user.display_name), user_path(user)),
:date => l(user.creation_time, :format => :friendly)
%>
<% end %>
<h1><%= t '.my settings' %></h1>
<ul class='secondary-actions clearfix'>
<li><%= link_to t('.return to profile'), user_path(current_user) %></li>
- <li><%= link_to t('user.view.oauth settings'), :controller => 'oauth_clients', :action => 'index' %></li>
+ <li><%= link_to t('user.show.oauth settings'), :controller => 'oauth_clients', :action => 'index' %></li>
</ul>
<% end %>
heading: "The user %{user} does not exist"
body: "Sorry, there is no user with the name %{user}. Please check your spelling, or maybe the link you clicked is wrong."
deleted: "deleted"
- view:
+ show:
my diary: My Diary
new diary entry: new diary entry
my edits: My Edits
post "/user/:display_name/diary/:id/unsubscribe" => "diary_entry#unsubscribe", :as => :diary_entry_unsubscribe, :id => /\d+/
# user pages
- get "/user/:display_name" => "user#view", :as => "user"
+ get "/user/:display_name" => "user#show", :as => "user"
match "/user/:display_name/make_friend" => "user#make_friend", :via => [:get, :post], :as => "make_friend"
match "/user/:display_name/remove_friend" => "user#remove_friend", :via => [:get, :post], :as => "remove_friend"
match "/user/:display_name/account" => "user#account", :via => [:get, :post]
assert_routing(
{ :path => "/user/username", :method => :get },
- { :controller => "user", :action => "view", :display_name => "username" }
+ { :controller => "user", :action => "show", :display_name => "username" }
)
assert_routing(
# Check that the user account page will display and contains some relevant
# information for the user
- def test_view
+ def test_show
# Test a non-existent user
- get :view, :params => { :display_name => "unknown" }
+ get :show, :params => { :display_name => "unknown" }
assert_response :not_found
# Test a normal user
user = create(:user)
- get :view, :params => { :display_name => user.display_name }
+ get :show, :params => { :display_name => user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
# Test a user who has been blocked
blocked_user = create(:user)
create(:user_block, :user => blocked_user)
- get :view, :params => { :display_name => blocked_user.display_name }
+ get :show, :params => { :display_name => blocked_user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(blocked_user.display_name)}/history']", 1
# Test a moderator who has applied blocks
moderator_user = create(:moderator_user)
create(:user_block, :creator => moderator_user)
- get :view, :params => { :display_name => moderator_user.display_name }
+ get :show, :params => { :display_name => moderator_user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(moderator_user.display_name)}/history']", 1
session[:user] = user.id
# Test the normal user
- get :view, :params => { :display_name => user.display_name }
+ get :show, :params => { :display_name => user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
session[:user] = create(:moderator_user).id
# Test the normal user
- get :view, :params => { :display_name => user.display_name }
+ get :show, :params => { :display_name => user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "a[href^='/user/#{ERB::Util.u(user.display_name)}/history']", 1
seen_user = create(:user, :terms_seen => true)
not_seen_user = create(:user, :terms_seen => false)
- get :view, :params => { :display_name => agreed_user.display_name }
+ get :show, :params => { :display_name => agreed_user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "p", :count => 0, :text => /Contributor terms/
end
- get :view, :params => { :display_name => seen_user.display_name }
+ get :show, :params => { :display_name => seen_user.display_name }
assert_response :success
# put @response.body
assert_select "div#userinformation" do
assert_select "p", /Declined/
end
- get :view, :params => { :display_name => not_seen_user.display_name }
+ get :show, :params => { :display_name => not_seen_user.display_name }
assert_response :success
assert_select "div#userinformation" do
assert_select "p", :count => 1, :text => /Contributor terms/
# Now try as a normal user
get :set_status, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => user }
assert_response :redirect
- assert_redirected_to :action => :view, :display_name => user.display_name
+ assert_redirected_to :action => :show, :display_name => user.display_name
# Finally try as an administrator
get :set_status, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => create(:administrator_user) }
assert_response :redirect
- assert_redirected_to :action => :view, :display_name => user.display_name
+ assert_redirected_to :action => :show, :display_name => user.display_name
assert_equal "suspended", User.find(user.id).status
end
# Now try as a normal user
get :delete, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => user }
assert_response :redirect
- assert_redirected_to :action => :view, :display_name => user.display_name
+ assert_redirected_to :action => :show, :display_name => user.display_name
# Finally try as an administrator
get :delete, :params => { :display_name => user.display_name, :status => "suspended" }, :session => { :user => create(:administrator_user) }
assert_response :redirect
- assert_redirected_to :action => :view, :display_name => user.display_name
+ assert_redirected_to :action => :show, :display_name => user.display_name
# Check that the user was deleted properly
user.reload
assert_response :redirect
follow_redirect!
assert_response :success
- assert_template "user/view"
+ assert_template "user/show"
get "/user/#{ERB::Util.u(user.display_name)}/account"
assert_response :success
assert_template "user/account"
target_user = create(:user)
post "/user/#{ERB::Util.u(target_user.display_name)}/role/#{role}/#{action}"
- assert_redirected_to :controller => "user", :action => "view", :display_name => target_user.display_name
+ assert_redirected_to user_path(target_user)
reset!
end
target_user = create(:user)
post "/user/#{ERB::Util.u(target_user.display_name)}/role/#{role}/#{action}"
- assert_redirected_to :controller => "user", :action => "view", :display_name => target_user.display_name
+ assert_redirected_to user_path(target_user)
reset!
end
visit browse_note_path(note)
assert page.has_content?(note.comments.first.body)
- assert_not page.has_content?(I18n.t("user.view.report"))
+ assert_not page.has_content?(I18n.t("user.show.report"))
end
def test_can_report_user
sign_in_as(create(:user))
visit user_path(user.display_name)
- click_on I18n.t("user.view.report")
+ click_on I18n.t("user.show.report")
assert page.has_content? "Report"
assert page.has_content? I18n.t("reports.new.disclaimer.intro")
sign_in_as(create(:user))
visit user_path(user.display_name)
- click_on I18n.t("user.view.report")
+ click_on I18n.t("user.show.report")
assert page.has_content? "Report"
assert page.has_content? I18n.t("reports.new.disclaimer.intro")
visit user_path(user.display_name)
- click_on I18n.t("user.view.report")
+ click_on I18n.t("user.show.report")
assert page.has_content? "Report"
assert page.has_content? I18n.t("reports.new.disclaimer.intro")