diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-25 03:51:44 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-25 03:51:44 +0200 |
| commit | baace1fa5df46694ddd515dc3bbca59b22df8692 (patch) | |
| tree | 6a8b587ca5d6d38377fe132b02c857f1c4149231 /app/controllers | |
| parent | ed32bc6902ab634451539770bcd910662212e01a (diff) | |
Extract flashes to i18n and stop dispatching on submit labels
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/application_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/assets_controller.rb | 12 | ||||
| -rw-r--r-- | app/controllers/events_controller.rb | 6 | ||||
| -rw-r--r-- | app/controllers/nodes_controller.rb | 45 | ||||
| -rw-r--r-- | app/controllers/occurrences_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/otp_challenges_controller.rb | 6 | ||||
| -rw-r--r-- | app/controllers/otp_enrollments_controller.rb | 11 | ||||
| -rw-r--r-- | app/controllers/page_translations_controller.rb | 14 | ||||
| -rw-r--r-- | app/controllers/revisions_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/sessions_controller.rb | 8 | ||||
| -rw-r--r-- | app/controllers/users_controller.rb | 8 |
11 files changed, 60 insertions, 60 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6d46d522..0a7ba109 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb | |||
| @@ -40,7 +40,7 @@ class ApplicationController < ActionController::Base | |||
| 40 | return unless logged_in? | 40 | return unless logged_in? |
| 41 | return unless current_user.otp_required? && !current_user.otp_enrolled? | 41 | return unless current_user.otp_required? && !current_user.otp_enrolled? |
| 42 | return if %w[otp_enrollments otp_challenges sessions users].include?(controller_name) | 42 | return if %w[otp_enrollments otp_challenges sessions users].include?(controller_name) |
| 43 | flash[:error] = "Your account requires a second factor -- set it up to continue." | 43 | flash[:error] = t("flash.common.otp_required") |
| 44 | redirect_to edit_user_path(current_user) | 44 | redirect_to edit_user_path(current_user) |
| 45 | end | 45 | end |
| 46 | end | 46 | end |
diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index 7edd9c05..f1c259e3 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb | |||
| @@ -49,7 +49,7 @@ class AssetsController < ApplicationController | |||
| 49 | 49 | ||
| 50 | respond_to do |format| | 50 | respond_to do |format| |
| 51 | if @asset.save | 51 | if @asset.save |
| 52 | flash[:notice] = 'Asset was successfully created.' | 52 | flash[:notice] = t("flash.assets.created") |
| 53 | NodeAction.record!(:participants => [@asset], :user => current_user, | 53 | NodeAction.record!(:participants => [@asset], :user => current_user, |
| 54 | :action => "asset_create", | 54 | :action => "asset_create", |
| 55 | :asset_name => @asset.name, | 55 | :asset_name => @asset.name, |
| @@ -72,7 +72,7 @@ class AssetsController < ApplicationController | |||
| 72 | 72 | ||
| 73 | respond_to do |format| | 73 | respond_to do |format| |
| 74 | if @asset.update(asset_params) | 74 | if @asset.update(asset_params) |
| 75 | flash[:notice] = 'Asset was successfully updated.' | 75 | flash[:notice] = t("flash.assets.updated") |
| 76 | format.html { redirect_to(@asset) } | 76 | format.html { redirect_to(@asset) } |
| 77 | format.xml { head :ok } | 77 | format.xml { head :ok } |
| 78 | else | 78 | else |
| @@ -105,14 +105,14 @@ class AssetsController < ApplicationController | |||
| 105 | :headline => params[:headline].present?) | 105 | :headline => params[:headline].present?) |
| 106 | flash[:notice] = | 106 | flash[:notice] = |
| 107 | if result[:attached].zero? | 107 | if result[:attached].zero? |
| 108 | "Asset saved — it was already attached to “#{node.title}”." | 108 | t("flash.assets.already_attached", :title => node.title) |
| 109 | else | 109 | else |
| 110 | "Asset was successfully created and attached to “#{node.title}”." | 110 | t("flash.assets.attached", :title => node.title) |
| 111 | end | 111 | end |
| 112 | case result[:headline] | 112 | case result[:headline] |
| 113 | when :set then flash[:notice] += " It is now the page's headline." | 113 | when :set then flash[:notice] += " " + t("flash.common.now_headline") |
| 114 | when :kept_existing then flash[:headline_kept_path] = node_path(node) | 114 | when :kept_existing then flash[:headline_kept_path] = node_path(node) |
| 115 | when :not_eligible then flash[:error] = "This asset type cannot be a headline." | 115 | when :not_eligible then flash[:error] = t("flash.common.headline_ineligible") |
| 116 | end | 116 | end |
| 117 | rescue LockedByAnotherUser | 117 | rescue LockedByAnotherUser |
| 118 | flash[:locked_by] = node.lock_owner&.login | 118 | flash[:locked_by] = node.lock_owner&.login |
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index be3f5476..f2c710bd 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb | |||
| @@ -43,7 +43,7 @@ class EventsController < ApplicationController | |||
| 43 | ) | 43 | ) |
| 44 | 44 | ||
| 45 | if params[:tag_list].present? && params[:auto_tag_source].present? | 45 | if params[:tag_list].present? && params[:auto_tag_source].present? |
| 46 | flash.now[:notice] = "Tag '#{params[:tag_list]}' was pre-filled because this page is tagged '#{params[:auto_tag_source]}'. You can remove it below." | 46 | flash.now[:notice] = t("flash.events.tag_prefilled", :tag => params[:tag_list], :source => params[:auto_tag_source]) |
| 47 | end | 47 | end |
| 48 | 48 | ||
| 49 | respond_to do |format| | 49 | respond_to do |format| |
| @@ -65,7 +65,7 @@ class EventsController < ApplicationController | |||
| 65 | 65 | ||
| 66 | respond_to do |format| | 66 | respond_to do |format| |
| 67 | if @event.save | 67 | if @event.save |
| 68 | flash[:notice] = 'Event was successfully created.' | 68 | flash[:notice] = t("flash.events.created") |
| 69 | format.html { redirect_to(safe_return_to(params[:return_to] || (@event.node ? edit_node_path(@event.node) : edit_event_path(@event)))) } | 69 | format.html { redirect_to(safe_return_to(params[:return_to] || (@event.node ? edit_node_path(@event.node) : edit_event_path(@event)))) } |
| 70 | format.xml { render :xml => @event, :status => :created, :location => @event } | 70 | format.xml { render :xml => @event, :status => :created, :location => @event } |
| 71 | else | 71 | else |
| @@ -82,7 +82,7 @@ class EventsController < ApplicationController | |||
| 82 | 82 | ||
| 83 | respond_to do |format| | 83 | respond_to do |format| |
| 84 | if @event.update(event_params) | 84 | if @event.update(event_params) |
| 85 | flash[:notice] = 'Event was successfully updated.' | 85 | flash[:notice] = t("flash.events.updated") |
| 86 | format.html { redirect_to(safe_return_to(params[:return_to] || events_path)) } | 86 | format.html { redirect_to(safe_return_to(params[:return_to] || events_path)) } |
| 87 | format.xml { head :ok } | 87 | format.xml { head :ok } |
| 88 | else | 88 | else |
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index ce8f0538..50b30881 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb | |||
| @@ -55,9 +55,9 @@ class NodesController < ApplicationController | |||
| 55 | if params[:asset_id].present? && (asset = Asset.find(params[:asset_id])) | 55 | if params[:asset_id].present? && (asset = Asset.find(params[:asset_id])) |
| 56 | result = @node.attach_asset!(asset, :user => current_user, | 56 | result = @node.attach_asset!(asset, :user => current_user, |
| 57 | :headline => params[:asset_headline].present?) | 57 | :headline => params[:asset_headline].present?) |
| 58 | flash[:notice] = "Page created with “#{asset.name}” attached." | 58 | flash[:notice] = t("flash.nodes.created_with_attachment", :name => asset.name) |
| 59 | flash[:notice] += " It is the page's headline." if result[:headline] == :set | 59 | flash[:notice] += " " + t("flash.common.now_headline") if result[:headline] == :set |
| 60 | flash[:error] = "This asset type cannot be a headline." if result[:headline] == :not_eligible | 60 | flash[:error] = t("flash.common.headline_ineligible") if result[:headline] == :not_eligible |
| 61 | end | 61 | end |
| 62 | 62 | ||
| 63 | redirect_to(edit_node_path(@node)) | 63 | redirect_to(edit_node_path(@node)) |
| @@ -83,14 +83,12 @@ class NodesController < ApplicationController | |||
| 83 | @page = @node.autosave || @node.draft || @node.head | 83 | @page = @node.autosave || @node.draft || @node.head |
| 84 | 84 | ||
| 85 | if @node.autosave | 85 | if @node.autosave |
| 86 | flash.now[:notice] = | 86 | flash.now[:notice] = t("flash.nodes.autosave_banner") |
| 87 | "This page has unsaved changes from a previous session, shown below. " \ | ||
| 88 | "Save to keep them, or use \"Discard Autosave\" below to go back to the last saved version." | ||
| 89 | elsif freshly_locked | 87 | elsif freshly_locked |
| 90 | flash.now[:notice] ||= "Node locked and ready to edit" | 88 | flash.now[:notice] ||= t("flash.nodes.locked_ready") |
| 91 | end | 89 | end |
| 92 | rescue LockedByAnotherUser => e | 90 | rescue LockedByAnotherUser => e |
| 93 | flash[:error] = e.message | 91 | flash[:error] = t("flash.common.locked_by_other") |
| 94 | redirect_to(request.referer || node_path(@node)) | 92 | redirect_to(request.referer || node_path(@node)) |
| 95 | end | 93 | end |
| 96 | 94 | ||
| @@ -99,7 +97,7 @@ class NodesController < ApplicationController | |||
| 99 | @node.autosave!( page_params.merge(:tag_list => params[:tag_list]), current_user ) | 97 | @node.autosave!( page_params.merge(:tag_list => params[:tag_list]), current_user ) |
| 100 | @node.save_draft!(current_user) | 98 | @node.save_draft!(current_user) |
| 101 | 99 | ||
| 102 | flash[:notice] = "Draft saved. Publish your changes in the Status section once you're done." | 100 | flash[:notice] = t("flash.nodes.draft_saved") |
| 103 | flash[:status_path] = node_path(@node) | 101 | flash[:status_path] = node_path(@node) |
| 104 | 102 | ||
| 105 | if @node.draft.translated_locales.size > 1 | 103 | if @node.draft.translated_locales.size > 1 |
| @@ -112,7 +110,7 @@ class NodesController < ApplicationController | |||
| 112 | end | 110 | end |
| 113 | end | 111 | end |
| 114 | 112 | ||
| 115 | if params[:commit] == "Save + Unlock + Exit" | 113 | if params[:unlock_exit].present? |
| 116 | @node.unlock! | 114 | @node.unlock! |
| 117 | redirect_to node_path(@node) | 115 | redirect_to node_path(@node) |
| 118 | else | 116 | else |
| @@ -156,13 +154,16 @@ class NodesController < ApplicationController | |||
| 156 | 154 | ||
| 157 | def trash | 155 | def trash |
| 158 | if @node.trash!(current_user) | 156 | if @node.trash!(current_user) |
| 159 | flash[:notice] = "Page has been moved to the Trash" | 157 | flash[:notice] = t("flash.nodes.trashed") |
| 160 | redirect_to trashed_nodes_path | 158 | redirect_to trashed_nodes_path |
| 161 | else | 159 | else |
| 162 | flash[:notice] = "Page is already in the Trash" | 160 | flash[:notice] = t("flash.nodes.already_trashed") |
| 163 | redirect_to node_path(@node) | 161 | redirect_to node_path(@node) |
| 164 | end | 162 | end |
| 165 | rescue ActiveRecord::RecordInvalid, LockedByAnotherUser => e | 163 | rescue LockedByAnotherUser |
| 164 | flash[:error] = t("flash.common.locked_by_other") | ||
| 165 | redirect_to node_path(@node) | ||
| 166 | rescue ActiveRecord::RecordInvalid => e | ||
| 166 | flash[:error] = e.message | 167 | flash[:error] = e.message |
| 167 | redirect_to node_path(@node) | 168 | redirect_to node_path(@node) |
| 168 | end | 169 | end |
| @@ -170,10 +171,10 @@ class NodesController < ApplicationController | |||
| 170 | def restore_from_trash | 171 | def restore_from_trash |
| 171 | parent = Node.find(params[:parent_id]) | 172 | parent = Node.find(params[:parent_id]) |
| 172 | @node.restore_from_trash!(parent, current_user) | 173 | @node.restore_from_trash!(parent, current_user) |
| 173 | flash[:notice] = "Page has been restored from the Trash" | 174 | flash[:notice] = t("flash.nodes.restored") |
| 174 | redirect_to node_path(@node) | 175 | redirect_to node_path(@node) |
| 175 | rescue ActiveRecord::RecordNotFound | 176 | rescue ActiveRecord::RecordNotFound |
| 176 | flash[:error] = "Restore target not found" | 177 | flash[:error] = t("flash.nodes.restore_target_missing") |
| 177 | redirect_to node_path(@node) | 178 | redirect_to node_path(@node) |
| 178 | rescue ActiveRecord::RecordInvalid => e | 179 | rescue ActiveRecord::RecordInvalid => e |
| 179 | flash[:error] = e.message | 180 | flash[:error] = e.message |
| @@ -182,7 +183,7 @@ class NodesController < ApplicationController | |||
| 182 | 183 | ||
| 183 | def destroy | 184 | def destroy |
| 184 | @node.destroy_from_trash!(current_user) | 185 | @node.destroy_from_trash!(current_user) |
| 185 | flash[:notice] = "Page has been permanently deleted" | 186 | flash[:notice] = t("flash.nodes.deleted") |
| 186 | redirect_to trashed_nodes_path | 187 | redirect_to trashed_nodes_path |
| 187 | 188 | ||
| 188 | rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotDestroyed => e | 189 | rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotDestroyed => e |
| @@ -192,15 +193,15 @@ class NodesController < ApplicationController | |||
| 192 | 193 | ||
| 193 | def publish | 194 | def publish |
| 194 | @node.publish_draft!(current_user) | 195 | @node.publish_draft!(current_user) |
| 195 | flash[:notice] = "Draft has been published" | 196 | flash[:notice] = t("flash.nodes.published") |
| 196 | redirect_to node_path(@node) | 197 | redirect_to node_path(@node) |
| 197 | end | 198 | end |
| 198 | 199 | ||
| 199 | def unlock | 200 | def unlock |
| 200 | if @node.unlock! | 201 | if @node.unlock! |
| 201 | flash[:notice] = "Node unlocked" | 202 | flash[:notice] = t("flash.nodes.unlocked") |
| 202 | else | 203 | else |
| 203 | flash[:notice] = "Already unlocked" | 204 | flash[:notice] = t("flash.nodes.already_unlocked") |
| 204 | end | 205 | end |
| 205 | 206 | ||
| 206 | redirect_to node_path(@node) | 207 | redirect_to node_path(@node) |
| @@ -210,9 +211,9 @@ class NodesController < ApplicationController | |||
| 210 | @node = Node.find(params[:id]) | 211 | @node = Node.find(params[:id]) |
| 211 | if @node.draft | 212 | if @node.draft |
| 212 | @node.draft.ensure_preview_token! | 213 | @node.draft.ensure_preview_token! |
| 213 | flash[:notice] = "Shareable preview link created - see below." | 214 | flash[:notice] = t("flash.nodes.preview_created") |
| 214 | else | 215 | else |
| 215 | flash[:notice] = "Create or edit a draft first - shared preview links are only available for pages with an active draft." | 216 | flash[:notice] = t("flash.nodes.preview_needs_draft") |
| 216 | end | 217 | end |
| 217 | redirect_to node_path(@node) | 218 | redirect_to node_path(@node) |
| 218 | end | 219 | end |
| @@ -220,7 +221,7 @@ class NodesController < ApplicationController | |||
| 220 | def revoke_shared_preview | 221 | def revoke_shared_preview |
| 221 | @node = Node.find(params[:id]) | 222 | @node = Node.find(params[:id]) |
| 222 | @node.draft.revoke_preview_token! if @node.draft | 223 | @node.draft.revoke_preview_token! if @node.draft |
| 223 | flash[:notice] = "Shareable preview link revoked." | 224 | flash[:notice] = t("flash.nodes.preview_revoked") |
| 224 | redirect_to node_path(@node) | 225 | redirect_to node_path(@node) |
| 225 | end | 226 | end |
| 226 | 227 | ||
diff --git a/app/controllers/occurrences_controller.rb b/app/controllers/occurrences_controller.rb index 0f30ce38..2e3c2ec1 100644 --- a/app/controllers/occurrences_controller.rb +++ b/app/controllers/occurrences_controller.rb | |||
| @@ -49,7 +49,7 @@ class OccurrencesController < ApplicationController | |||
| 49 | 49 | ||
| 50 | respond_to do |format| | 50 | respond_to do |format| |
| 51 | if @occurrence.save | 51 | if @occurrence.save |
| 52 | flash[:notice] = 'Occurrence was successfully created.' | 52 | flash[:notice] = t("flash.occurrences.created") |
| 53 | format.html { redirect_to(@occurrence) } | 53 | format.html { redirect_to(@occurrence) } |
| 54 | format.xml { render :xml => @occurrence, :status => :created, :location => @occurrence } | 54 | format.xml { render :xml => @occurrence, :status => :created, :location => @occurrence } |
| 55 | else | 55 | else |
| @@ -66,7 +66,7 @@ class OccurrencesController < ApplicationController | |||
| 66 | 66 | ||
| 67 | respond_to do |format| | 67 | respond_to do |format| |
| 68 | if @occurrence.update(occurrence_params) | 68 | if @occurrence.update(occurrence_params) |
| 69 | flash[:notice] = 'Occurrence was successfully updated.' | 69 | flash[:notice] = t("flash.occurrences.updated") |
| 70 | format.html { redirect_to(@occurrence) } | 70 | format.html { redirect_to(@occurrence) } |
| 71 | format.xml { head :ok } | 71 | format.xml { head :ok } |
| 72 | else | 72 | else |
diff --git a/app/controllers/otp_challenges_controller.rb b/app/controllers/otp_challenges_controller.rb index e31c36ca..eeaeac20 100644 --- a/app/controllers/otp_challenges_controller.rb +++ b/app/controllers/otp_challenges_controller.rb | |||
| @@ -19,7 +19,7 @@ class OtpChallengesController < ApplicationController | |||
| 19 | session[:otp_attempts] = session[:otp_attempts].to_i + 1 | 19 | session[:otp_attempts] = session[:otp_attempts].to_i + 1 |
| 20 | if session[:otp_attempts] > MAX_ATTEMPTS | 20 | if session[:otp_attempts] > MAX_ATTEMPTS |
| 21 | clear_pending | 21 | clear_pending |
| 22 | flash[:error] = "Too many attempts -- log in again." | 22 | flash[:error] = t("flash.otp.too_many_attempts") |
| 23 | return redirect_to login_path | 23 | return redirect_to login_path |
| 24 | end | 24 | end |
| 25 | 25 | ||
| @@ -28,10 +28,10 @@ class OtpChallengesController < ApplicationController | |||
| 28 | reset_session | 28 | reset_session |
| 29 | self.current_user = user | 29 | self.current_user = user |
| 30 | session[:logged_in_at] = Time.now.to_i | 30 | session[:logged_in_at] = Time.now.to_i |
| 31 | flash[:notice] = "Logged in successfully" | 31 | flash[:notice] = t("flash.common.logged_in") |
| 32 | redirect_to safe_return_to(return_to, :default => admin_path) | 32 | redirect_to safe_return_to(return_to, :default => admin_path) |
| 33 | else | 33 | else |
| 34 | flash.now[:error] = "That code did not match." | 34 | flash.now[:error] = t("flash.otp.code_mismatch") |
| 35 | render :new | 35 | render :new |
| 36 | end | 36 | end |
| 37 | end | 37 | end |
diff --git a/app/controllers/otp_enrollments_controller.rb b/app/controllers/otp_enrollments_controller.rb index 7a31d1e1..54b82214 100644 --- a/app/controllers/otp_enrollments_controller.rb +++ b/app/controllers/otp_enrollments_controller.rb | |||
| @@ -15,7 +15,7 @@ class OtpEnrollmentsController < ApplicationController | |||
| 15 | # unattended logged-in session cannot be enrolled onto a stranger's phone. | 15 | # unattended logged-in session cannot be enrolled onto a stranger's phone. |
| 16 | def create | 16 | def create |
| 17 | unless User.authenticate(current_user.login, params[:current_password].to_s) | 17 | unless User.authenticate(current_user.login, params[:current_password].to_s) |
| 18 | flash[:error] = "Wrong password." | 18 | flash[:error] = t("flash.otp.wrong_password") |
| 19 | return redirect_to edit_user_path(current_user) | 19 | return redirect_to edit_user_path(current_user) |
| 20 | end | 20 | end |
| 21 | current_user.begin_otp_enrollment! | 21 | current_user.begin_otp_enrollment! |
| @@ -25,11 +25,10 @@ class OtpEnrollmentsController < ApplicationController | |||
| 25 | # Confirms with the first generated code. | 25 | # Confirms with the first generated code. |
| 26 | def update | 26 | def update |
| 27 | if current_user.confirm_otp_enrollment!(params[:code]) | 27 | if current_user.confirm_otp_enrollment!(params[:code]) |
| 28 | flash[:notice] = "Second factor enabled. The code you just entered is " \ | 28 | flash[:notice] = t("flash.otp.enabled") |
| 29 | "spent -- wait for the next one before logging in with it." | ||
| 30 | redirect_to edit_user_path(current_user) | 29 | redirect_to edit_user_path(current_user) |
| 31 | else | 30 | else |
| 32 | flash.now[:error] = "That code did not match. Rescan or wait for the next code." | 31 | flash.now[:error] = t("flash.otp.code_mismatch_rescan") |
| 33 | render :show | 32 | render :show |
| 34 | end | 33 | end |
| 35 | end | 34 | end |
| @@ -38,11 +37,11 @@ class OtpEnrollmentsController < ApplicationController | |||
| 38 | def destroy | 37 | def destroy |
| 39 | unless User.authenticate(current_user.login, params[:current_password].to_s) && | 38 | unless User.authenticate(current_user.login, params[:current_password].to_s) && |
| 40 | current_user.verify_otp!(params[:code]) | 39 | current_user.verify_otp!(params[:code]) |
| 41 | flash[:error] = "Password or code wrong -- second factor unchanged." | 40 | flash[:error] = t("flash.otp.wrong_credentials") |
| 42 | return redirect_to edit_user_path(current_user) | 41 | return redirect_to edit_user_path(current_user) |
| 43 | end | 42 | end |
| 44 | current_user.disable_otp!(:actor => current_user) | 43 | current_user.disable_otp!(:actor => current_user) |
| 45 | flash[:notice] = "Second factor disabled." | 44 | flash[:notice] = t("flash.otp.disabled") |
| 46 | redirect_to edit_user_path(current_user) | 45 | redirect_to edit_user_path(current_user) |
| 47 | end | 46 | end |
| 48 | end | 47 | end |
diff --git a/app/controllers/page_translations_controller.rb b/app/controllers/page_translations_controller.rb index 38a7c4f9..e5ca57e0 100644 --- a/app/controllers/page_translations_controller.rb +++ b/app/controllers/page_translations_controller.rb | |||
| @@ -16,14 +16,14 @@ class PageTranslationsController < ApplicationController | |||
| 16 | @page = @node.draft || @node.head | 16 | @page = @node.draft || @node.head |
| 17 | @translation = @page.translations.find_by(:locale => @locale) | 17 | @translation = @page.translations.find_by(:locale => @locale) |
| 18 | rescue LockedByAnotherUser => e | 18 | rescue LockedByAnotherUser => e |
| 19 | flash[:error] = e.message | 19 | flash[:error] = t("flash.common.locked_by_other") |
| 20 | redirect_to node_path(@node) | 20 | redirect_to node_path(@node) |
| 21 | end | 21 | end |
| 22 | 22 | ||
| 23 | def update | 23 | def update |
| 24 | Globalize.with_locale(@locale) { @node.autosave!(translation_params, current_user) } | 24 | Globalize.with_locale(@locale) { @node.autosave!(translation_params, current_user) } |
| 25 | @node.save_draft!(current_user) | 25 | @node.save_draft!(current_user) |
| 26 | flash[:notice] = "#{@locale.upcase} translation saved. Publish the draft to make it live." | 26 | flash[:notice] = t("flash.page_translations.saved", :lang => @locale.upcase) |
| 27 | 27 | ||
| 28 | if params[:commit] == "Save + Unlock + Exit" | 28 | if params[:commit] == "Save + Unlock + Exit" |
| 29 | @node.unlock! | 29 | @node.unlock! |
| @@ -32,7 +32,7 @@ class PageTranslationsController < ApplicationController | |||
| 32 | redirect_to edit_node_translation_path(@node, @locale) | 32 | redirect_to edit_node_translation_path(@node, @locale) |
| 33 | end | 33 | end |
| 34 | rescue LockedByAnotherUser => e | 34 | rescue LockedByAnotherUser => e |
| 35 | flash[:error] = e.message | 35 | flash[:error] = t("flash.common.locked_by_other") |
| 36 | redirect_to node_path(@node) | 36 | redirect_to node_path(@node) |
| 37 | end | 37 | end |
| 38 | 38 | ||
| @@ -40,7 +40,7 @@ class PageTranslationsController < ApplicationController | |||
| 40 | Globalize.with_locale(@locale) { @node.autosave!(translation_params, current_user) } | 40 | Globalize.with_locale(@locale) { @node.autosave!(translation_params, current_user) } |
| 41 | head :ok | 41 | head :ok |
| 42 | rescue LockedByAnotherUser => e | 42 | rescue LockedByAnotherUser => e |
| 43 | render plain: e.message, status: :locked | 43 | render plain: t("flash.common.locked_by_other"), status: :locked |
| 44 | rescue ActiveRecord::RecordInvalid => e | 44 | rescue ActiveRecord::RecordInvalid => e |
| 45 | render plain: e.message, status: :unprocessable_entity | 45 | render plain: e.message, status: :unprocessable_entity |
| 46 | rescue StandardError => e | 46 | rescue StandardError => e |
| @@ -50,12 +50,12 @@ class PageTranslationsController < ApplicationController | |||
| 50 | def destroy | 50 | def destroy |
| 51 | base = @node.draft || @node.head | 51 | base = @node.draft || @node.head |
| 52 | unless base && base.translated_locales.include?(@locale) | 52 | unless base && base.translated_locales.include?(@locale) |
| 53 | flash[:error] = "No #{@locale.to_s.upcase} translation exists to remove." | 53 | flash[:error] = t("flash.page_translations.none_to_remove", :lang => @locale.to_s.upcase) |
| 54 | return redirect_to node_path(@node) | 54 | return redirect_to node_path(@node) |
| 55 | end | 55 | end |
| 56 | 56 | ||
| 57 | if (base.translated_locales - [@locale]).empty? | 57 | if (base.translated_locales - [@locale]).empty? |
| 58 | flash[:error] = "Can't remove the only remaining translation." | 58 | flash[:error] = t("flash.page_translations.last_translation") |
| 59 | return redirect_to node_path(@node) | 59 | return redirect_to node_path(@node) |
| 60 | end | 60 | end |
| 61 | 61 | ||
| @@ -63,7 +63,7 @@ class PageTranslationsController < ApplicationController | |||
| 63 | draft.translations.where(:locale => @locale).delete_all | 63 | draft.translations.where(:locale => @locale).delete_all |
| 64 | draft.reload | 64 | draft.reload |
| 65 | 65 | ||
| 66 | flash[:notice] = "#{@locale.upcase} translation removed from the draft. Publish to make this permanent." | 66 | flash[:notice] = t("flash.page_translations.removed", :lang => @locale.upcase) |
| 67 | redirect_to node_path(@node) | 67 | redirect_to node_path(@node) |
| 68 | rescue LockedByAnotherUser => e | 68 | rescue LockedByAnotherUser => e |
| 69 | flash[:error] = e.message | 69 | flash[:error] = e.message |
diff --git a/app/controllers/revisions_controller.rb b/app/controllers/revisions_controller.rb index c1237a95..9f920b03 100644 --- a/app/controllers/revisions_controller.rb +++ b/app/controllers/revisions_controller.rb | |||
| @@ -26,7 +26,7 @@ class RevisionsController < ApplicationController | |||
| 26 | @end = @node.resolve_page_reference(params[:end_revision]) | 26 | @end = @node.resolve_page_reference(params[:end_revision]) |
| 27 | 27 | ||
| 28 | if @start.nil? || @end.nil? | 28 | if @start.nil? || @end.nil? |
| 29 | flash[:error] = "That comparison is no longer available." | 29 | flash[:error] = t("flash.revisions.unavailable") |
| 30 | redirect_to(node_path(@node)) and return | 30 | redirect_to(node_path(@node)) and return |
| 31 | end | 31 | end |
| 32 | 32 | ||
| @@ -50,7 +50,7 @@ class RevisionsController < ApplicationController | |||
| 50 | def restore | 50 | def restore |
| 51 | page = Page.find(params[:id]) | 51 | page = Page.find(params[:id]) |
| 52 | page.node.restore_revision! page.revision, current_user | 52 | page.node.restore_revision! page.revision, current_user |
| 53 | flash[:notice] = "Revision #{page.revision} restored" | 53 | flash[:notice] = t("flash.revisions.restored", :rev => page.revision) |
| 54 | redirect_to node_path(page.node) | 54 | redirect_to node_path(page.node) |
| 55 | end | 55 | end |
| 56 | 56 | ||
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 49d33810..bb63c51e 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb | |||
| @@ -32,10 +32,10 @@ class SessionsController < ApplicationController | |||
| 32 | session[:logged_in_at] = Time.now.to_i | 32 | session[:logged_in_at] = Time.now.to_i |
| 33 | 33 | ||
| 34 | if user.otp_required? | 34 | if user.otp_required? |
| 35 | flash[:error] = "Your account requires a second factor -- set it up now." | 35 | flash[:error] = t("flash.sessions.otp_setup_now") |
| 36 | redirect_to edit_user_path(user) | 36 | redirect_to edit_user_path(user) |
| 37 | else | 37 | else |
| 38 | flash[:notice] = "Logged in successfully" | 38 | flash[:notice] = t("flash.common.logged_in") |
| 39 | redirect_to safe_return_to(return_to, :default => admin_path) | 39 | redirect_to safe_return_to(return_to, :default => admin_path) |
| 40 | end | 40 | end |
| 41 | end | 41 | end |
| @@ -48,14 +48,14 @@ class SessionsController < ApplicationController | |||
| 48 | 48 | ||
| 49 | def destroy | 49 | def destroy |
| 50 | logout_killing_session! | 50 | logout_killing_session! |
| 51 | flash[:notice] = "You have been logged out." | 51 | flash[:notice] = t("flash.sessions.logged_out") |
| 52 | redirect_back_or_default('/login') | 52 | redirect_back_or_default('/login') |
| 53 | end | 53 | end |
| 54 | 54 | ||
| 55 | protected | 55 | protected |
| 56 | # Track failed login attempts | 56 | # Track failed login attempts |
| 57 | def note_failed_signin | 57 | def note_failed_signin |
| 58 | flash[:error] = "login not successful" | 58 | flash[:error] = t("flash.sessions.failed") |
| 59 | logger.warn "Failed login for '#{params[:login]}'" \ | 59 | logger.warn "Failed login for '#{params[:login]}'" \ |
| 60 | "from #{request.remote_ip} at #{Time.now.utc}" | 60 | "from #{request.remote_ip} at #{Time.now.utc}" |
| 61 | end | 61 | end |
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 08541b0c..12531d86 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb | |||
| @@ -22,7 +22,7 @@ class UsersController < ApplicationController | |||
| 22 | @user = User.new user_params | 22 | @user = User.new user_params |
| 23 | 23 | ||
| 24 | if @user.save | 24 | if @user.save |
| 25 | flash[:notice] = "User created #{@user.login}" | 25 | flash[:notice] = t("flash.users.created", :login => @user.login) |
| 26 | redirect_to user_path(@user) | 26 | redirect_to user_path(@user) |
| 27 | else | 27 | else |
| 28 | render :new | 28 | render :new |
| @@ -37,7 +37,7 @@ class UsersController < ApplicationController | |||
| 37 | permitted.delete(:admin) unless current_user.is_admin? | 37 | permitted.delete(:admin) unless current_user.is_admin? |
| 38 | 38 | ||
| 39 | if @user.update(permitted) | 39 | if @user.update(permitted) |
| 40 | flash[:notice] = "Updated user #{@user.login}" | 40 | flash[:notice] = t("flash.users.updated", :login => @user.login) |
| 41 | redirect_to user_path(@user) | 41 | redirect_to user_path(@user) |
| 42 | else | 42 | else |
| 43 | render :edit | 43 | render :edit |
| @@ -55,7 +55,7 @@ class UsersController < ApplicationController | |||
| 55 | def reset_otp | 55 | def reset_otp |
| 56 | return deny_user_access unless current_user.admin? | 56 | return deny_user_access unless current_user.admin? |
| 57 | @user.disable_otp!(:actor => current_user) | 57 | @user.disable_otp!(:actor => current_user) |
| 58 | flash[:notice] = "Second factor reset for #{@user.login}" | 58 | flash[:notice] = t("flash.users.otp_reset", :login => @user.login) |
| 59 | redirect_to edit_user_path(@user) | 59 | redirect_to edit_user_path(@user) |
| 60 | end | 60 | end |
| 61 | 61 | ||
| @@ -79,7 +79,7 @@ class UsersController < ApplicationController | |||
| 79 | end | 79 | end |
| 80 | 80 | ||
| 81 | def deny_user_access | 81 | def deny_user_access |
| 82 | flash[:notice] = "Sorry, you need to be an admin for this action" | 82 | flash[:notice] = t("flash.common.admin_required") |
| 83 | redirect_to users_path | 83 | redirect_to users_path |
| 84 | end | 84 | end |
| 85 | end | 85 | end |
