1
0
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:
2019-02-02 17:53:02 +01:00
parent 0dd3092c4c
commit 3a2aa6ea1a
11 changed files with 87 additions and 11 deletions

View File

@@ -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