]> git.openstreetmap.org Git - rails.git/commitdiff
Fix new rubocop warnings
authorTom Hughes <tom@compton.nu>
Tue, 22 Nov 2022 18:32:02 +0000 (18:32 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 22 Nov 2022 18:32:02 +0000 (18:32 +0000)
app/controllers/confirmations_controller.rb
app/controllers/diary_entries_controller.rb
app/controllers/friendships_controller.rb
app/controllers/geocoder_controller.rb
app/controllers/oauth_clients_controller.rb
app/controllers/passwords_controller.rb
app/controllers/sessions_controller.rb
app/controllers/traces_controller.rb
app/controllers/users_controller.rb

index 06e7c8e7d33f4d3519ff6921c3d88ea0c3a0a8af..a482bc96de0da11b52335a7790879fc0155f9ad9 100644 (file)
@@ -16,10 +16,10 @@ class ConfirmationsController < ApplicationController
     if request.post?
       token = UserToken.find_by(:token => params[:confirm_string])
       if token&.user&.active?
     if request.post?
       token = UserToken.find_by(:token => params[:confirm_string])
       if token&.user&.active?
-        flash[:error] = t("confirmations.confirm.already active")
+        flash[:error] = t(".already active")
         redirect_to login_path
       elsif !token || token.expired?
         redirect_to login_path
       elsif !token || token.expired?
-        flash[:error] = t("confirmations.confirm.unknown token")
+        flash[:error] = t(".unknown token")
         redirect_to :action => "confirm"
       elsif !token.user.visible?
         render_unknown_user token.user.display_name
         redirect_to :action => "confirm"
       elsif !token.user.visible?
         render_unknown_user token.user.display_name
@@ -40,7 +40,7 @@ class ConfirmationsController < ApplicationController
         end
 
         if token.nil? || token.user != user
         end
 
         if token.nil? || token.user != user
-          flash[:notice] = t("confirmations.confirm.success")
+          flash[:notice] = t(".success")
           redirect_to login_path(:referer => referer)
         else
           token.destroy
           redirect_to login_path(:referer => referer)
         else
           token.destroy
@@ -63,7 +63,7 @@ class ConfirmationsController < ApplicationController
     token = UserToken.find_by(:token => session[:token])
 
     if user.nil? || token.nil? || token.user != user
     token = UserToken.find_by(:token => session[:token])
 
     if user.nil? || token.nil? || token.user != user
-      flash[:error] = t "confirmations.confirm_resend.failure", :name => params[:display_name]
+      flash[:error] = t ".failure", :name => params[:display_name]
     else
       UserMailer.signup_confirm(user, user.tokens.create).deliver_later
       flash[:notice] = { :partial => "confirmations/resend_success_flash", :locals => { :email => user.email, :sender => Settings.email_from } }
     else
       UserMailer.signup_confirm(user, user.tokens.create).deliver_later
       flash[:notice] = { :partial => "confirmations/resend_success_flash", :locals => { :email => user.email, :sender => Settings.email_from } }
@@ -83,9 +83,9 @@ class ConfirmationsController < ApplicationController
         gravatar_enabled = gravatar_enable(current_user)
         if current_user.save
           flash[:notice] = if gravatar_enabled
         gravatar_enabled = gravatar_enable(current_user)
         if current_user.save
           flash[:notice] = if gravatar_enabled
-                             "#{t('confirmations.confirm_email.success')} #{gravatar_status_message(current_user)}"
+                             "#{t('.success')} #{gravatar_status_message(current_user)}"
                            else
                            else
-                             t("confirmations.confirm_email.success")
+                             t(".success")
                            end
         else
           flash[:errors] = current_user.errors
                            end
         else
           flash[:errors] = current_user.errors
@@ -94,9 +94,9 @@ class ConfirmationsController < ApplicationController
         session[:user] = current_user.id
         session[:fingerprint] = current_user.fingerprint
       elsif token
         session[:user] = current_user.id
         session[:fingerprint] = current_user.fingerprint
       elsif token
-        flash[:error] = t "confirmations.confirm_email.failure"
+        flash[:error] = t ".failure"
       else
       else
-        flash[:error] = t "confirmations.confirm_email.unknown_token"
+        flash[:error] = t ".unknown_token"
       end
 
       redirect_to edit_account_path
       end
 
       redirect_to edit_account_path
index 8e6215dbd2726a8a8356cd71eaa9c90be91011c1..4cdc1b55a817cb740b83d8920f7f0698327e9d05 100644 (file)
@@ -16,7 +16,7 @@ class DiaryEntriesController < ApplicationController
       @user = User.active.find_by(:display_name => params[:display_name])
 
       if @user
       @user = User.active.find_by(:display_name => params[:display_name])
 
       if @user
-        @title = t "diary_entries.index.user_title", :user => @user.display_name
+        @title = t ".user_title", :user => @user.display_name
         @entries = @user.diary_entries
       else
         render_unknown_user params[:display_name]
         @entries = @user.diary_entries
       else
         render_unknown_user params[:display_name]
@@ -24,7 +24,7 @@ class DiaryEntriesController < ApplicationController
       end
     elsif params[:friends]
       if current_user
       end
     elsif params[:friends]
       if current_user
-        @title = t "diary_entries.index.title_friends"
+        @title = t ".title_friends"
         @entries = DiaryEntry.where(:user_id => current_user.friends)
       else
         require_user
         @entries = DiaryEntry.where(:user_id => current_user.friends)
       else
         require_user
@@ -32,7 +32,7 @@ class DiaryEntriesController < ApplicationController
       end
     elsif params[:nearby]
       if current_user
       end
     elsif params[:nearby]
       if current_user
-        @title = t "diary_entries.index.title_nearby"
+        @title = t ".title_nearby"
         @entries = DiaryEntry.where(:user_id => current_user.nearby)
       else
         require_user
         @entries = DiaryEntry.where(:user_id => current_user.nearby)
       else
         require_user
@@ -42,10 +42,10 @@ class DiaryEntriesController < ApplicationController
       @entries = DiaryEntry.joins(:user).where(:users => { :status => %w[active confirmed] })
 
       if params[:language]
       @entries = DiaryEntry.joins(:user).where(:users => { :status => %w[active confirmed] })
 
       if params[:language]
-        @title = t "diary_entries.index.in_language_title", :language => Language.find(params[:language]).english_name
+        @title = t ".in_language_title", :language => Language.find(params[:language]).english_name
         @entries = @entries.where(:language_code => params[:language])
       else
         @entries = @entries.where(:language_code => params[:language])
       else
-        @title = t "diary_entries.index.title"
+        @title = t ".title"
       end
     end
 
       end
     end
 
@@ -64,7 +64,7 @@ class DiaryEntriesController < ApplicationController
   def show
     @entry = @user.diary_entries.visible.where(:id => params[:id]).first
     if @entry
   def show
     @entry = @user.diary_entries.visible.where(:id => params[:id]).first
     if @entry
-      @title = t "diary_entries.show.title", :user => params[:display_name], :title => @entry.title
+      @title = t ".title", :user => params[:display_name], :title => @entry.title
       @comments = can?(:unhidecomment, DiaryEntry) ? @entry.comments : @entry.visible_comments
     else
       @title = t "diary_entries.no_such_entry.title", :id => params[:id]
       @comments = can?(:unhidecomment, DiaryEntry) ? @entry.comments : @entry.visible_comments
     else
       @title = t "diary_entries.no_such_entry.title", :id => params[:id]
@@ -73,7 +73,7 @@ class DiaryEntriesController < ApplicationController
   end
 
   def new
   end
 
   def new
-    @title = t "diary_entries.new.title"
+    @title = t ".title"
 
     default_lang = current_user.preferences.where(:k => "diary.default_language").first
     lang_code = default_lang ? default_lang.v : current_user.preferred_language
 
     default_lang = current_user.preferences.where(:k => "diary.default_language").first
     lang_code = default_lang ? default_lang.v : current_user.preferred_language
@@ -83,7 +83,7 @@ class DiaryEntriesController < ApplicationController
   end
 
   def edit
   end
 
   def edit
-    @title = t "diary_entries.edit.title"
+    @title = t ".title"
     @diary_entry = DiaryEntry.find(params[:id])
 
     redirect_to diary_entry_path(@diary_entry.user, @diary_entry) if current_user != @diary_entry.user
     @diary_entry = DiaryEntry.find(params[:id])
 
     redirect_to diary_entry_path(@diary_entry.user, @diary_entry) if current_user != @diary_entry.user
index 5bfce7f0b27d617ae3c93848290e93c45cc0c5bb..4d1161147304943d50c4437797566e99aae6a917 100644 (file)
@@ -18,14 +18,14 @@ class FriendshipsController < ApplicationController
         friendship.befriender = current_user
         friendship.befriendee = @new_friend
         if current_user.friends_with?(@new_friend)
         friendship.befriender = current_user
         friendship.befriendee = @new_friend
         if current_user.friends_with?(@new_friend)
-          flash[:warning] = t "friendships.make_friend.already_a_friend", :name => @new_friend.display_name
+          flash[:warning] = t ".already_a_friend", :name => @new_friend.display_name
         elsif current_user.friendships.where("created_at >= ?", Time.now.utc - 1.hour).count >= current_user.max_friends_per_hour
         elsif current_user.friendships.where("created_at >= ?", Time.now.utc - 1.hour).count >= current_user.max_friends_per_hour
-          flash.now[:error] = t "friendships.make_friend.limit_exceeded"
+          flash.now[:error] = t ".limit_exceeded"
         elsif friendship.save
         elsif friendship.save
-          flash[:notice] = t "friendships.make_friend.success", :name => @new_friend.display_name
+          flash[:notice] = t ".success", :name => @new_friend.display_name
           UserMailer.friendship_notification(friendship).deliver_later
         else
           UserMailer.friendship_notification(friendship).deliver_later
         else
-          friendship.add_error(t("friendships.make_friend.failed", :name => @new_friend.display_name))
+          friendship.add_error(t(".failed", :name => @new_friend.display_name))
         end
 
         referer = safe_referer(params[:referer]) if params[:referer]
         end
 
         referer = safe_referer(params[:referer]) if params[:referer]
@@ -44,9 +44,9 @@ class FriendshipsController < ApplicationController
       if request.post?
         if current_user.friends_with?(@friend)
           Friendship.where(:befriender => current_user, :befriendee => @friend).delete_all
       if request.post?
         if current_user.friends_with?(@friend)
           Friendship.where(:befriender => current_user, :befriendee => @friend).delete_all
-          flash[:notice] = t "friendships.remove_friend.success", :name => @friend.display_name
+          flash[:notice] = t ".success", :name => @friend.display_name
         else
         else
-          flash[:error] = t "friendships.remove_friend.not_a_friend", :name => @friend.display_name
+          flash[:error] = t ".not_a_friend", :name => @friend.display_name
         end
 
         referer = safe_referer(params[:referer]) if params[:referer]
         end
 
         referer = safe_referer(params[:referer]) if params[:referer]
index 02f00ff7f3bf301bf10269ea685c0e99331d9dc5..4f9efa4dc553305d39e607b8f06dda3de6d1d5a1 100644 (file)
@@ -154,7 +154,7 @@ class GeocoderController < ApplicationController
           prefix_name = t "geocoder.search_osm_nominatim.prefix.place.#{extratag.attributes['value']}", :default => prefix_name if extratag.attributes["key"] == "linked_place" || extratag.attributes["key"] == "place"
         end
       end
           prefix_name = t "geocoder.search_osm_nominatim.prefix.place.#{extratag.attributes['value']}", :default => prefix_name if extratag.attributes["key"] == "linked_place" || extratag.attributes["key"] == "place"
         end
       end
-      prefix = t "geocoder.search_osm_nominatim.prefix_format", :name => prefix_name
+      prefix = t ".prefix_format", :name => prefix_name
       object_type = place.attributes["osm_type"]
       object_id = place.attributes["osm_id"]
 
       object_type = place.attributes["osm_type"]
       object_id = place.attributes["osm_id"]
 
index c17d3856d60492847f620a721bfccc8b3389ee39..44dacde6d72a4ce3a19eb7732eedea58d7c13f7d 100644 (file)
@@ -32,7 +32,7 @@ class OauthClientsController < ApplicationController
   def create
     @client_application = current_user.client_applications.build(application_params)
     if @client_application.save
   def create
     @client_application = current_user.client_applications.build(application_params)
     if @client_application.save
-      flash[:notice] = t "oauth_clients.create.flash"
+      flash[:notice] = t ".flash"
       redirect_to :action => "show", :id => @client_application.id
     else
       render :action => "new"
       redirect_to :action => "show", :id => @client_application.id
     else
       render :action => "new"
@@ -42,7 +42,7 @@ class OauthClientsController < ApplicationController
   def update
     @client_application = current_user.client_applications.find(params[:id])
     if @client_application.update(application_params)
   def update
     @client_application = current_user.client_applications.find(params[:id])
     if @client_application.update(application_params)
-      flash[:notice] = t "oauth_clients.update.flash"
+      flash[:notice] = t ".flash"
       redirect_to :action => "show", :id => @client_application.id
     else
       render :action => "edit"
       redirect_to :action => "show", :id => @client_application.id
     else
       render :action => "edit"
@@ -55,7 +55,7 @@ class OauthClientsController < ApplicationController
   def destroy
     @client_application = current_user.client_applications.find(params[:id])
     @client_application.destroy
   def destroy
     @client_application = current_user.client_applications.find(params[:id])
     @client_application.destroy
-    flash[:notice] = t "oauth_clients.destroy.flash"
+    flash[:notice] = t ".flash"
     redirect_to :action => "index"
   rescue ActiveRecord::RecordNotFound
     @type = "client application"
     redirect_to :action => "index"
   rescue ActiveRecord::RecordNotFound
     @type = "client application"
index 502b1357f29f9fb085833ecc78af61da0f964246..08df9f7a4bbeed964c17af62ccc7c4a5263c5cfb 100644 (file)
@@ -12,7 +12,7 @@ class PasswordsController < ApplicationController
   before_action :check_database_writable, :only => [:lost_password, :reset_password]
 
   def lost_password
   before_action :check_database_writable, :only => [:lost_password, :reset_password]
 
   def lost_password
-    @title = t "passwords.lost_password.title"
+    @title = t ".title"
 
     if request.post?
       user = User.visible.find_by(:email => params[:email])
 
     if request.post?
       user = User.visible.find_by(:email => params[:email])
@@ -26,16 +26,16 @@ class PasswordsController < ApplicationController
       if user
         token = user.tokens.create
         UserMailer.lost_password(user, token).deliver_later
       if user
         token = user.tokens.create
         UserMailer.lost_password(user, token).deliver_later
-        flash[:notice] = t "passwords.lost_password.notice email on way"
+        flash[:notice] = t ".notice email on way"
         redirect_to login_path
       else
         redirect_to login_path
       else
-        flash.now[:error] = t "passwords.lost_password.notice email cannot find"
+        flash.now[:error] = t ".notice email cannot find"
       end
     end
   end
 
   def reset_password
       end
     end
   end
 
   def reset_password
-    @title = t "passwords.reset_password.title"
+    @title = t ".title"
 
     if params[:token]
       token = UserToken.find_by(:token => params[:token])
 
     if params[:token]
       token = UserToken.find_by(:token => params[:token])
@@ -52,12 +52,12 @@ class PasswordsController < ApplicationController
           if current_user.save
             token.destroy
             session[:fingerprint] = current_user.fingerprint
           if current_user.save
             token.destroy
             session[:fingerprint] = current_user.fingerprint
-            flash[:notice] = t "passwords.reset_password.flash changed"
+            flash[:notice] = t ".flash changed"
             successful_login(current_user)
           end
         end
       else
             successful_login(current_user)
           end
         end
       else
-        flash[:error] = t "passwords.reset_password.flash token bad"
+        flash[:error] = t ".flash token bad"
         redirect_to :action => "lost_password"
       end
     else
         redirect_to :action => "lost_password"
       end
     else
index 2e223393993b1c5fc648ea9f1e0da95afe1b2fb7..ba2858ce4392f8fda4745ad90f5f27af7c90f4dd 100644 (file)
@@ -24,7 +24,7 @@ class SessionsController < ApplicationController
   end
 
   def destroy
   end
 
   def destroy
-    @title = t "sessions.destroy.title"
+    @title = t ".title"
 
     if request.post?
       if session[:token]
 
     if request.post?
       if session[:token]
index 86b09215ef94eba30405089e4918cc37020459fe..855bbb78af85bc8fc98a1dfe19731e304e8ed5ec 100644 (file)
@@ -119,7 +119,7 @@ class TracesController < ApplicationController
         TraceImporterJob.perform_later(@trace)
         redirect_to :action => :index, :display_name => current_user.display_name
       else
         TraceImporterJob.perform_later(@trace)
         redirect_to :action => :index, :display_name => current_user.display_name
       else
-        flash[:error] = t("traces.create.upload_failed") if @trace.valid?
+        flash[:error] = t(".upload_failed") if @trace.valid?
 
         render :action => "new"
       end
 
         render :action => "new"
       end
index 1e927aa01d71b2d80c0ff94ce2d9832d2d3239eb..6d98c17f6707e021d62f7c3be49aee81e8d08fbf 100644 (file)
@@ -53,7 +53,7 @@ class UsersController < ApplicationController
   end
 
   def new
   end
 
   def new
-    @title = t "users.new.title"
+    @title = t ".title"
     @referer = if params[:referer]
                  safe_referer(params[:referer])
                else
     @referer = if params[:referer]
                  safe_referer(params[:referer])
                else
@@ -127,7 +127,7 @@ class UsersController < ApplicationController
     if request.xhr?
       render :partial => "terms"
     else
     if request.xhr?
       render :partial => "terms"
     else
-      @title = t "users.terms.title"
+      @title = t ".title"
 
       if current_user&.terms_agreed?
         # Already agreed to terms, so just show settings
 
       if current_user&.terms_agreed?
         # Already agreed to terms, so just show settings
@@ -220,7 +220,7 @@ class UsersController < ApplicationController
   def go_public
     current_user.data_public = true
     current_user.save
   def go_public
     current_user.data_public = true
     current_user.save
-    flash[:notice] = t "users.go_public.flash success"
+    flash[:notice] = t ".flash success"
     redirect_to edit_account_path
   end
 
     redirect_to edit_account_path
   end
 
@@ -304,7 +304,7 @@ class UsersController < ApplicationController
   ##
   # omniauth failure callback
   def auth_failure
   ##
   # omniauth failure callback
   def auth_failure
-    flash[:error] = t(params[:message], :scope => "users.auth_failure", :default => t("users.auth_failure.unknown_error"))
+    flash[:error] = t(params[:message], :scope => "users.auth_failure", :default => t(".unknown_error"))
 
     origin = safe_referer(params[:origin]) if params[:origin]
 
 
     origin = safe_referer(params[:origin]) if params[:origin]