mirror of
https://github.com/projekteuler/projekteuler.git
synced 2025-12-10 08:46:41 +01:00
Add status to translations
This commit is contained in:
parent
1533431c4a
commit
8da1323fd8
@ -11,18 +11,12 @@ class TranslationsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
# POST /translations
|
# POST /translations
|
||||||
# POST /translations.json
|
|
||||||
def create
|
def create
|
||||||
@translation = @problem.translations.new(translation_params)
|
@translation = @problem.translations.new(translation_params)
|
||||||
|
if @translation.save
|
||||||
respond_to do |format|
|
redirect_to @problem, notice: t('translations.notice.successfully_created')
|
||||||
if @translation.save
|
else
|
||||||
format.html { redirect_to @problem, notice: t('translations.notice.successfully_created') }
|
render :new
|
||||||
format.json { render :show, status: :created, location: @translation }
|
|
||||||
else
|
|
||||||
format.html { render :new }
|
|
||||||
format.json { render json: @translation.errors, status: :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,14 @@ class Problem < ApplicationRecord
|
|||||||
!!self.translation
|
!!self.translation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_translation(translation)
|
||||||
|
if self.is_translated?
|
||||||
|
self.translation.outdated!
|
||||||
|
end
|
||||||
|
self.translation = translation
|
||||||
|
self.translation.in_use!
|
||||||
|
end
|
||||||
|
|
||||||
def original_url
|
def original_url
|
||||||
"https://projecteuler.net/problem=#{self.id}"
|
"https://projecteuler.net/problem=#{self.id}"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
class Translation < ApplicationRecord
|
class Translation < ApplicationRecord
|
||||||
belongs_to :problem, inverse_of: :translations
|
belongs_to :problem, inverse_of: :translations
|
||||||
|
enum status: [:pending, :in_use, :outdated, :declined]
|
||||||
|
|
||||||
validates :title, :content, :problem_id, presence: true
|
validates :title, :content, :problem_id, presence: true
|
||||||
validate :title_is_unique_among_other_problems
|
validate :title_is_unique_among_other_problems
|
||||||
|
|||||||
@ -8,4 +8,8 @@ de:
|
|||||||
info: "Info"
|
info: "Info"
|
||||||
legal: "Impressum"
|
legal: "Impressum"
|
||||||
copyright: "Copyright-Informationen"
|
copyright: "Copyright-Informationen"
|
||||||
bootstrap_html: 'Entworfen mit <a href="http://getbootstrap.com/">Bootstrap</a>'
|
bootstrap_html: 'Entworfen mit <a href="http://getbootstrap.com/">Bootstrap</a>'
|
||||||
|
helpers:
|
||||||
|
submit:
|
||||||
|
translation:
|
||||||
|
create: "%{model} vorschlagen"
|
||||||
|
|||||||
@ -9,4 +9,4 @@ de:
|
|||||||
new:
|
new:
|
||||||
new_translation: Neue Übersetzung für Problem %{id}
|
new_translation: Neue Übersetzung für Problem %{id}
|
||||||
notice:
|
notice:
|
||||||
successfully_created: Übersetzung wurde erfolgreich erstellt.
|
successfully_created: Der Übersetzungsvorschlag wurde eingereicht. Ein Organisator wird sich Ihren Vorschlag so bald wie möglich anschauen.
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150131103802) do
|
ActiveRecord::Schema.define(version: 2019_02_02_113250) do
|
||||||
|
|
||||||
create_table "admins", force: :cascade do |t|
|
create_table "admins", force: :cascade do |t|
|
||||||
t.string "email", default: "", null: false
|
t.string "email", default: "", null: false
|
||||||
@ -42,6 +42,7 @@ ActiveRecord::Schema.define(version: 20150131103802) do
|
|||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.integer "problem_id"
|
t.integer "problem_id"
|
||||||
|
t.integer "status", default: 0
|
||||||
t.index ["problem_id"], name: "index_translations_on_problem_id"
|
t.index ["problem_id"], name: "index_translations_on_problem_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ for i in 1..10 do
|
|||||||
)
|
)
|
||||||
|
|
||||||
problem = Problem.find(i)
|
problem = Problem.find(i)
|
||||||
problem.translation = translation
|
problem.set_translation(translation)
|
||||||
problem.save!
|
problem.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user