mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 12:29:54 +01:00
Add controller-scoped locales for AnnouncementController
This commit is contained in:
parent
8d73008ebf
commit
ac83995dfc
2 changed files with 31 additions and 6 deletions
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AnnouncementController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
|
@ -13,10 +15,11 @@ class AnnouncementController < ApplicationController
|
|||
@announcement = Announcement.new(announcement_params)
|
||||
@announcement.user = current_user
|
||||
if @announcement.save
|
||||
flash[:success] = "Announcement created successfully."
|
||||
flash[:success] = t(".success")
|
||||
redirect_to action: :index
|
||||
else
|
||||
render 'announcement/new'
|
||||
flash[:error] = t(".error")
|
||||
render "announcement/new"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -28,18 +31,19 @@ class AnnouncementController < ApplicationController
|
|||
@announcement = Announcement.find(params[:id])
|
||||
@announcement.update(announcement_params)
|
||||
if @announcement.save
|
||||
flash[:success] = "Announcement updated successfully."
|
||||
flash[:success] = T(".success")
|
||||
redirect_to announcement_index_path
|
||||
else
|
||||
render 'announcement/edit'
|
||||
flash[:error] = T(".error")
|
||||
render "announcement/edit"
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if Announcement.destroy(params[:id])
|
||||
flash[:success] = "Announcement deleted successfully."
|
||||
flash[:success] = t(".success")
|
||||
else
|
||||
flash[:error] = "Failed to delete announcement."
|
||||
flash[:error] = t(".error")
|
||||
end
|
||||
redirect_to announcement_index_path
|
||||
end
|
||||
|
|
|
@ -457,6 +457,27 @@ en:
|
|||
invalid_code: "The code you entered was invalid."
|
||||
setup:
|
||||
success: "Two factor authentication has been enabled for your account."
|
||||
announcement:
|
||||
index:
|
||||
title: :activerecord.models.announcement.other
|
||||
confirm: "Are you sure you want to delete this announcement?"
|
||||
new: "Add Announcement"
|
||||
new:
|
||||
title: "Create Announcement"
|
||||
create:
|
||||
success: "Announcement created successfully."
|
||||
error: "Unable to create announcement."
|
||||
edit:
|
||||
title: "Edit Announcement"
|
||||
update:
|
||||
success: "Announcement updated successfully."
|
||||
error: "Unable to save announcement."
|
||||
destroy:
|
||||
success: "Announcement has been deleted successfully."
|
||||
error: "Unable to delete announcement."
|
||||
voc:
|
||||
delete: "Delete"
|
||||
edit: "Edit"
|
||||
errors:
|
||||
base: "An error occurred"
|
||||
|
||||
|
|
Loading…
Reference in a new issue