Use one "no_such_user" view everywhere
authorTom Hughes <tom@compton.nu>
Wed, 21 Mar 2012 21:47:09 +0000 (21:47 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 21 Mar 2012 21:47:09 +0000 (21:47 +0000)
12 files changed:
app/controllers/application_controller.rb
app/controllers/changeset_controller.rb
app/controllers/diary_entry_controller.rb
app/controllers/message_controller.rb
app/controllers/trace_controller.rb
app/controllers/user_blocks_controller.rb
app/controllers/user_controller.rb
app/controllers/user_roles_controller.rb
app/views/diary_entry/no_such_user.html.erb [deleted file]
app/views/message/no_such_user.html.erb [deleted file]
app/views/trace/no_such_user.html.erb [deleted file]
config/locales/en.yml

index 0f9fad45e860ab40a6687b8eece4de1d59286cad..25f4054a3347dd61439f3b7e2e9f65a017f7d77b 100644 (file)
@@ -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
index cfe86de51fd462842e075353c8044f6027205dbb..2e6258ea8b2b25195fce22cae6956f82bddb2113 100644 (file)
@@ -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
index f87b02ef9b916b7b879a0a166db79d09e5f26577..6666d601734b71414f11ffa8508c59c83b80ba1c 100644 (file)
@@ -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
index ec183fc3e7800abe464774e44201e7ed2361cda7..5db4125248735d43cf4b90c4b0c973421bf2ff70 100644 (file)
@@ -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
 
index 7b2314be33c9db4b91906ececf8d5745768f128b..05f97bf0d507a667973fbf6405263af44d328c53 100644 (file)
@@ -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
index 26b698b607bc8b3808cd678cd186bc6d5dc44746..e681a194a842d2c4e6376e557ddb45ac7b6aabca 100644 (file)
@@ -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
 
index a086c9f697e86ed10cf5229213bd7150e1b50498..3b8206ed4ac9e945097f6124ef0f02a20b54c78b 100644 (file)
@@ -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
 
index 11a1dc41ee28f5c692f1055276f9482ad6785787..f38ba82ac80e59b1c1c354eb7c728e91552df88e 100644 (file)
@@ -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 (file)
index f1ba37d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-<h2><%= t 'diary_entry.no_such_user.heading', :user => @not_found_user %></h2>
-<p><%= t 'diary_entry.no_such_user.body', :user => @not_found_user %></p>
diff --git a/app/views/message/no_such_user.html.erb b/app/views/message/no_such_user.html.erb
deleted file mode 100644 (file)
index ace9953..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-<h1><%= t'message.no_such_user.heading' %></h1>
-<p><%= t'message.no_such_user.body' %></p>
diff --git a/app/views/trace/no_such_user.html.erb b/app/views/trace/no_such_user.html.erb
deleted file mode 100644 (file)
index 6b1b27f..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-<h2><%= t'trace.no_such_user.heading', :user => @not_found_user %></h2>
-<p><%= t'trace.no_such_user.body', :user => @not_found_user %></p>
index cfff3940e58f4637b2bba41d6f9f944a330cf389..e9ee39812bd8afc31b9c62c19d5dd0668c27a14c 100644 (file)
@@ -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:"