Add flash messages. Redirect to edit action after update
This commit is contained in:
@@ -8,23 +8,25 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont
|
||||
|
||||
def create
|
||||
if @draft_version.save
|
||||
redirect_to admin_legislation_process_draft_versions_path
|
||||
redirect_to admin_legislation_process_draft_versions_path, notice: t('admin.legislation.draft_versions.create.notice')
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.draft_versions.create.error')
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @draft_version.update(draft_version_params)
|
||||
redirect_to admin_legislation_process_draft_versions_path
|
||||
redirect_to edit_admin_legislation_process_draft_version_path(@process, @draft_version), notice: t('admin.legislation.draft_versions.update.notice')
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.draft_versions.update.error')
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@draft_version.destroy
|
||||
redirect_to admin_legislation_process_draft_versions_path
|
||||
redirect_to admin_legislation_process_draft_versions_path, notice: t('admin.legislation.draft_versions.destroy.notice')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -9,23 +9,25 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
|
||||
def create
|
||||
if @process.save
|
||||
redirect_to admin_legislation_processes_path
|
||||
redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.create.notice')
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.processes.create.error')
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @process.update(process_params)
|
||||
redirect_to admin_legislation_processes_path
|
||||
redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.update.notice')
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.processes.update.error')
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@process.destroy
|
||||
redirect_to admin_legislation_processes_path
|
||||
redirect_to admin_legislation_processes_path, notice: t('admin.legislation.processes.destroy.notice')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -13,23 +13,25 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll
|
||||
def create
|
||||
@question.author = current_user
|
||||
if @question.save
|
||||
redirect_to admin_legislation_process_questions_path
|
||||
redirect_to admin_legislation_process_questions_path, notice: t('admin.legislation.questions.create.notice')
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.questions.create.error')
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @question.update(question_params)
|
||||
redirect_to admin_legislation_process_questions_path
|
||||
redirect_to edit_admin_legislation_process_question_path(@process, @question), notice: t('admin.legislation.questions.update.notice')
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.questions.update.error')
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@question.destroy
|
||||
redirect_to admin_legislation_process_questions_path
|
||||
redirect_to admin_legislation_process_questions_path, notice: t('admin.legislation.questions.destroy.notice')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -84,6 +84,14 @@ en:
|
||||
title: Hidden debates
|
||||
legislation:
|
||||
processes:
|
||||
create:
|
||||
notice: Process created successfully
|
||||
error: Process couldn't be created
|
||||
update:
|
||||
notice: Process updated successfully
|
||||
error: Process couldn't be updated
|
||||
destroy:
|
||||
notice: Process deleted successfully
|
||||
edit:
|
||||
back: Back
|
||||
submit_button: Save changes
|
||||
@@ -123,6 +131,14 @@ en:
|
||||
draft_texts: Text
|
||||
questions: Debate
|
||||
draft_versions:
|
||||
create:
|
||||
notice: Draft created successfully
|
||||
error: Draft couldn't be created
|
||||
update:
|
||||
notice: Draft updated successfully
|
||||
error: Draft couldn't be updated
|
||||
destroy:
|
||||
notice: Draft deleted successfully
|
||||
edit:
|
||||
back: Back
|
||||
submit_button: Save changes
|
||||
@@ -157,6 +173,14 @@ en:
|
||||
final_version: Final version
|
||||
status: Status
|
||||
questions:
|
||||
create:
|
||||
notice: Question created successfully
|
||||
error: Question couldn't be created
|
||||
update:
|
||||
notice: Question updated successfully
|
||||
error: Question couldn't be updated
|
||||
destroy:
|
||||
notice: Question deleted successfully
|
||||
edit:
|
||||
back: Back
|
||||
title: "Edit “%{question_title}”"
|
||||
|
||||
@@ -82,6 +82,14 @@ es:
|
||||
title: Debates ocultos
|
||||
legislation:
|
||||
processes:
|
||||
create:
|
||||
notice: Proceso creado correctamente
|
||||
error: No se ha podido crear el proceso
|
||||
update:
|
||||
notice: Proceso actualizado correctamente
|
||||
error: No se ha podido actualizar el proceso
|
||||
destroy:
|
||||
notice: Proceso eliminado correctamente
|
||||
edit:
|
||||
back: Volver
|
||||
submit_button: Guardar cambios
|
||||
@@ -121,6 +129,14 @@ es:
|
||||
draft_texts: Texto
|
||||
questions: Debate
|
||||
draft_versions:
|
||||
create:
|
||||
notice: Borrador creado correctamente
|
||||
error: No se ha podido crear el borrador
|
||||
update:
|
||||
notice: Borrador actualizado correctamente
|
||||
error: No se ha podido actualizar el borrador
|
||||
destroy:
|
||||
notice: Borrador eliminado correctamente
|
||||
edit:
|
||||
back: Volver
|
||||
submit_button: Guardar cambios
|
||||
@@ -155,6 +171,14 @@ es:
|
||||
final_version: Versión final
|
||||
status: Estado
|
||||
questions:
|
||||
create:
|
||||
notice: Pregunta creada correctamente
|
||||
error: No se ha podido crear la pregunta
|
||||
update:
|
||||
notice: Pregunta actualizada correctamente
|
||||
error: No se ha podido actualizar la pregunta
|
||||
destroy:
|
||||
notice: Pregunta eliminada correctamente
|
||||
edit:
|
||||
back: Volver
|
||||
title: "Editar “%{question_title}”"
|
||||
|
||||
Reference in New Issue
Block a user