From a9824dbc2e8763e6fff6f71db7a31cc4761cd245 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 21 Mar 2012 21:47:09 +0000 Subject: [PATCH] Use one "no_such_user" view everywhere --- app/controllers/application_controller.rb | 9 +++++++++ app/controllers/changeset_controller.rb | 4 +--- app/controllers/diary_entry_controller.rb | 13 +++---------- app/controllers/message_controller.rb | 3 +-- app/controllers/trace_controller.rb | 4 +--- app/controllers/user_blocks_controller.rb | 3 +-- app/controllers/user_controller.rb | 4 +--- app/controllers/user_roles_controller.rb | 3 +-- app/views/diary_entry/no_such_user.html.erb | 2 -- app/views/message/no_such_user.html.erb | 2 -- app/views/trace/no_such_user.html.erb | 2 -- config/locales/en.yml | 12 ------------ 12 files changed, 18 insertions(+), 43 deletions(-) delete mode 100644 app/views/diary_entry/no_such_user.html.erb delete mode 100644 app/views/message/no_such_user.html.erb delete mode 100644 app/views/trace/no_such_user.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0f9fad45e..25f4054a3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -362,6 +362,15 @@ class ApplicationController < ActionController::Base !@user.nil? end + ## + # render a "no such user" page + def render_unknown_user(name) + @title = t "user.no_such_user.title" + @not_found_user = name + + render :template => "user/no_such_user", :status => :not_found + end + private # extract authorisation credentials from headers, returns user = nil if none diff --git a/app/controllers/changeset_controller.rb b/app/controllers/changeset_controller.rb index cfe86de51..2e6258ea8 100644 --- a/app/controllers/changeset_controller.rb +++ b/app/controllers/changeset_controller.rb @@ -260,9 +260,7 @@ class ChangesetController < ApplicationController changesets = changesets.where("false") end elsif request.format == :html - @title = t 'user.no_such_user.title' - @not_found_user = params[:display_name] - render :template => 'user/no_such_user', :status => :not_found + render_unknown_user params[:display_name] return end end diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index f87b02ef9..6666d6017 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -84,10 +84,7 @@ class DiaryEntryController < ApplicationController :order => 'created_at DESC', :per_page => 20) else - @title = t'diary_entry.no_such_user.title' - @not_found_user = params[:display_name] - - render :action => 'no_such_user', :status => :not_found + render_unknown_user params[:display_name] end elsif params[:language] @title = t 'diary_entry.list.in_language_title', :language => Language.find(params[:language]).english_name @@ -178,9 +175,7 @@ class DiaryEntryController < ApplicationController render :action => 'no_such_entry', :status => :not_found end else - @not_found_user = params[:display_name] - - render :action => 'no_such_user', :status => :not_found + render_unknown_user params[:display_name] end end @@ -206,9 +201,7 @@ class DiaryEntryController < ApplicationController :per_page => 20) @page = (params[:page] || 1).to_i else - @title = t'diary_entry.no_such_user.title' - @not_found_user = params[:display_name] - render :action => 'no_such_user', :status => :not_found + render_unknown_user params[:display_name] end end private diff --git a/app/controllers/message_controller.rb b/app/controllers/message_controller.rb index ec183fc3e..5db412524 100644 --- a/app/controllers/message_controller.rb +++ b/app/controllers/message_controller.rb @@ -40,8 +40,7 @@ class MessageController < ApplicationController end end else - @title = t'message.no_such_user.title' - render :action => 'no_such_user', :status => :not_found + render_unknown_user params[:display_name] end end diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 7b2314be3..05f97bf0d 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -30,9 +30,7 @@ class TraceController < ApplicationController if !display_name.blank? target_user = User.active.where(:display_name => display_name).first if target_user.nil? - @title = t'trace.no_such_user.title' - @not_found_user = display_name - render :action => 'no_such_user', :status => :not_found + render_unknown_user display_name return end end diff --git a/app/controllers/user_blocks_controller.rb b/app/controllers/user_blocks_controller.rb index 26b698b60..e681a194a 100644 --- a/app/controllers/user_blocks_controller.rb +++ b/app/controllers/user_blocks_controller.rb @@ -124,8 +124,7 @@ class UserBlocksController < ApplicationController # ensure that there is a "this_user" instance variable def lookup_this_user unless @this_user = User.find_by_display_name(params[:display_name]) - @not_found_user = params[:display_name] - render :template => 'user/no_such_user', :status => :not_found + render_unknown_user params[:display_name] end end diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index a086c9f69..3b8206ed4 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -423,9 +423,7 @@ class UserController < ApplicationController (@this_user.visible? or (@user and @user.administrator?)) @title = @this_user.display_name else - @title = t 'user.no_such_user.title' - @not_found_user = params[:display_name] - render :action => 'no_such_user', :status => :not_found + render_unknown_user params[:display_name] end end diff --git a/app/controllers/user_roles_controller.rb b/app/controllers/user_roles_controller.rb index 11a1dc41e..f38ba82ac 100644 --- a/app/controllers/user_roles_controller.rb +++ b/app/controllers/user_roles_controller.rb @@ -36,8 +36,7 @@ class UserRolesController < ApplicationController # ensure that there is a "this_user" instance variable def lookup_this_user unless @this_user = User.find_by_display_name(params[:display_name]) - @not_found_user = params[:display_name] - render :template => 'user/no_such_user', :status => :not_found + render_unknown_user params[:display_name] end end diff --git a/app/views/diary_entry/no_such_user.html.erb b/app/views/diary_entry/no_such_user.html.erb deleted file mode 100644 index f1ba37d7b..000000000 --- a/app/views/diary_entry/no_such_user.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

<%= t 'diary_entry.no_such_user.heading', :user => @not_found_user %>

-

<%= t 'diary_entry.no_such_user.body', :user => @not_found_user %>

diff --git a/app/views/message/no_such_user.html.erb b/app/views/message/no_such_user.html.erb deleted file mode 100644 index ace99530e..000000000 --- a/app/views/message/no_such_user.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

<%= t'message.no_such_user.heading' %>

-

<%= t'message.no_such_user.body' %>

diff --git a/app/views/trace/no_such_user.html.erb b/app/views/trace/no_such_user.html.erb deleted file mode 100644 index 6b1b27f46..000000000 --- a/app/views/trace/no_such_user.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

<%= t'trace.no_such_user.heading', :user => @not_found_user %>

-

<%= t'trace.no_such_user.body', :user => @not_found_user %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index cfff3940e..e9ee39812 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -360,10 +360,6 @@ en: title: "No such diary entry" heading: "No entry with the id: %{id}" body: "Sorry, there is no diary entry or comment with the id %{id}. Please check your spelling, or maybe the link you clicked is wrong." - no_such_user: - title: "No such user" - 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." diary_entry: posted_by: "Posted by %{link_user} on %{created} in %{language_link}" comment_link: Comment on this entry @@ -1257,10 +1253,6 @@ en: back_to_inbox: "Back to inbox" message_sent: "Message sent" limit_exceeded: "You have sent a lot of messages recently. Please wait a while before trying to send any more." - no_such_user: - title: "No such user" - heading: "No such user" - body: "Sorry there is no user with that name." no_such_message: title: "No such message" heading: "No such message" @@ -1448,10 +1440,6 @@ en: visibility: "Visibility:" visibility_help: "what does this mean?" visibility_help_url: "http://wiki.openstreetmap.org/wiki/Visibility_of_GPS_traces" - no_such_user: - title: "No such user" - 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." trace_form: upload_gpx: "Upload GPX File:" description: "Description:" -- 2.39.5