mirror of
https://github.com/projekteuler/projekteuler.git
synced 2026-01-27 10:38:50 +01:00
Add ability to accept or decline translations
This commit is contained in:
@@ -1,18 +1,28 @@
|
||||
class Admin::TranslationsController < AdminController
|
||||
before_action :set_translation, only: :show
|
||||
before_action :set_translation, only: [:show, :accept, :decline]
|
||||
|
||||
# GET /translations
|
||||
# GET /translations.json
|
||||
def index
|
||||
@translations = Translation.paginate(page: params[:page])
|
||||
@translations = Translation.pending.order(created_at: :desc).paginate(page: params[:page])
|
||||
end
|
||||
|
||||
# GET /translations/1
|
||||
# GET /translations/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
def accept
|
||||
raise t('.must_be_pending') unless @translation.pending?
|
||||
@translation.problem.set_translation(@translation)
|
||||
redirect_to @translation.problem, notice: t('.success_message')
|
||||
end
|
||||
|
||||
def decline
|
||||
raise t('.must_be_pending') unless @translation.pending?
|
||||
@translation.declined!
|
||||
redirect_to admin_translations_path, notice: t('.success_message')
|
||||
end
|
||||
|
||||
def set_translation
|
||||
@translation = Translation.find(params[:id])
|
||||
@translation = Translation.find(params[:translation_id])
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user