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
|
def create
|
||||||
if @draft_version.save
|
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
|
else
|
||||||
|
flash.now[:error] = t('admin.legislation.draft_versions.create.error')
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @draft_version.update(draft_version_params)
|
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
|
else
|
||||||
|
flash.now[:error] = t('admin.legislation.draft_versions.update.error')
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@draft_version.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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -9,23 +9,25 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
if @process.save
|
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
|
else
|
||||||
|
flash.now[:error] = t('admin.legislation.processes.create.error')
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @process.update(process_params)
|
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
|
else
|
||||||
|
flash.now[:error] = t('admin.legislation.processes.update.error')
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@process.destroy
|
@process.destroy
|
||||||
redirect_to admin_legislation_processes_path
|
redirect_to admin_legislation_processes_path, notice: t('admin.legislation.processes.destroy.notice')
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -13,23 +13,25 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll
|
|||||||
def create
|
def create
|
||||||
@question.author = current_user
|
@question.author = current_user
|
||||||
if @question.save
|
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
|
else
|
||||||
|
flash.now[:error] = t('admin.legislation.questions.create.error')
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @question.update(question_params)
|
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
|
else
|
||||||
|
flash.now[:error] = t('admin.legislation.questions.update.error')
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@question.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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -84,6 +84,14 @@ en:
|
|||||||
title: Hidden debates
|
title: Hidden debates
|
||||||
legislation:
|
legislation:
|
||||||
processes:
|
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:
|
edit:
|
||||||
back: Back
|
back: Back
|
||||||
submit_button: Save changes
|
submit_button: Save changes
|
||||||
@@ -123,6 +131,14 @@ en:
|
|||||||
draft_texts: Text
|
draft_texts: Text
|
||||||
questions: Debate
|
questions: Debate
|
||||||
draft_versions:
|
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:
|
edit:
|
||||||
back: Back
|
back: Back
|
||||||
submit_button: Save changes
|
submit_button: Save changes
|
||||||
@@ -157,6 +173,14 @@ en:
|
|||||||
final_version: Final version
|
final_version: Final version
|
||||||
status: Status
|
status: Status
|
||||||
questions:
|
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:
|
edit:
|
||||||
back: Back
|
back: Back
|
||||||
title: "Edit “%{question_title}”"
|
title: "Edit “%{question_title}”"
|
||||||
|
|||||||
@@ -82,6 +82,14 @@ es:
|
|||||||
title: Debates ocultos
|
title: Debates ocultos
|
||||||
legislation:
|
legislation:
|
||||||
processes:
|
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:
|
edit:
|
||||||
back: Volver
|
back: Volver
|
||||||
submit_button: Guardar cambios
|
submit_button: Guardar cambios
|
||||||
@@ -121,6 +129,14 @@ es:
|
|||||||
draft_texts: Texto
|
draft_texts: Texto
|
||||||
questions: Debate
|
questions: Debate
|
||||||
draft_versions:
|
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:
|
edit:
|
||||||
back: Volver
|
back: Volver
|
||||||
submit_button: Guardar cambios
|
submit_button: Guardar cambios
|
||||||
@@ -155,6 +171,14 @@ es:
|
|||||||
final_version: Versión final
|
final_version: Versión final
|
||||||
status: Estado
|
status: Estado
|
||||||
questions:
|
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:
|
edit:
|
||||||
back: Volver
|
back: Volver
|
||||||
title: "Editar “%{question_title}”"
|
title: "Editar “%{question_title}”"
|
||||||
|
|||||||
Reference in New Issue
Block a user