Add controller-scoped locales for `AnnouncementController`
This commit is contained in:
parent
8d73008ebf
commit
ac83995dfc
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class AnnouncementController < ApplicationController
|
class AnnouncementController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
|
||||||
|
@ -13,10 +15,11 @@ class AnnouncementController < ApplicationController
|
||||||
@announcement = Announcement.new(announcement_params)
|
@announcement = Announcement.new(announcement_params)
|
||||||
@announcement.user = current_user
|
@announcement.user = current_user
|
||||||
if @announcement.save
|
if @announcement.save
|
||||||
flash[:success] = "Announcement created successfully."
|
flash[:success] = t(".success")
|
||||||
redirect_to action: :index
|
redirect_to action: :index
|
||||||
else
|
else
|
||||||
render 'announcement/new'
|
flash[:error] = t(".error")
|
||||||
|
render "announcement/new"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,18 +31,19 @@ class AnnouncementController < ApplicationController
|
||||||
@announcement = Announcement.find(params[:id])
|
@announcement = Announcement.find(params[:id])
|
||||||
@announcement.update(announcement_params)
|
@announcement.update(announcement_params)
|
||||||
if @announcement.save
|
if @announcement.save
|
||||||
flash[:success] = "Announcement updated successfully."
|
flash[:success] = T(".success")
|
||||||
redirect_to announcement_index_path
|
redirect_to announcement_index_path
|
||||||
else
|
else
|
||||||
render 'announcement/edit'
|
flash[:error] = T(".error")
|
||||||
|
render "announcement/edit"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if Announcement.destroy(params[:id])
|
if Announcement.destroy(params[:id])
|
||||||
flash[:success] = "Announcement deleted successfully."
|
flash[:success] = t(".success")
|
||||||
else
|
else
|
||||||
flash[:error] = "Failed to delete announcement."
|
flash[:error] = t(".error")
|
||||||
end
|
end
|
||||||
redirect_to announcement_index_path
|
redirect_to announcement_index_path
|
||||||
end
|
end
|
||||||
|
|
|
@ -457,6 +457,27 @@ en:
|
||||||
invalid_code: "The code you entered was invalid."
|
invalid_code: "The code you entered was invalid."
|
||||||
setup:
|
setup:
|
||||||
success: "Two factor authentication has been enabled for your account."
|
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:
|
errors:
|
||||||
base: "An error occurred"
|
base: "An error occurred"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue