Redirect to Speaker Profile after event creation

This commit is contained in:
Petko Bordjukov 2014-09-02 12:31:15 +03:00
parent 1d144019a4
commit f34de8f107
4 changed files with 23 additions and 4 deletions

View File

@ -14,7 +14,7 @@ class LecturesController < ApplicationController
@lecture = current_user.lectures.build lecture_params
if @lecture.save
redirect_to @lecture
after_save_redirection
else
render :new, status: :unprocessable_entity
end
@ -25,7 +25,7 @@ class LecturesController < ApplicationController
def update
if @lecture.update lecture_params
redirect_to @lecture
after_save_redirection
else
render :edit, status: :unprocessable_entity
end
@ -43,4 +43,13 @@ class LecturesController < ApplicationController
def lecture_params
params.require(:lecture).permit [:title, :subtitle, :length, :language, :abstract, :description, :notes, :track_id]
end
def after_save_redirection
if current_user.speaker_profile.present?
redirect_to @lecture
else
redirect_to edit_user_registration_path, alert: I18n.t(:please_fill_in_your_speaker_profile)
end
end
end

View File

@ -14,7 +14,7 @@ class WorkshopsController < ApplicationController
@workshop = current_user.workshops.build workshop_params
if @workshop.save
redirect_to @workshop
after_save_redirection
else
render :new, status: :unprocessable_entity
end
@ -25,7 +25,7 @@ class WorkshopsController < ApplicationController
def update
if @workshop.update workshop_params
redirect_to @workshop
after_save_redirection
else
render :edit, status: :unprocessable_entity
end
@ -43,4 +43,12 @@ class WorkshopsController < ApplicationController
def workshop_params
params.require(:workshop).permit [:title, :subtitle, :length, :language, :abstract, :description, :notes, :track_id]
end
def after_save_redirection
if current_user.speaker_profile.present?
redirect_to @workshop
else
redirect_to edit_user_registration_path, alert: I18n.t(:please_fill_in_your_speaker_profile)
end
end
end

View File

@ -19,6 +19,7 @@ bg:
login_with: "Влез с %{with}"
speaker_profile: Лекторски профил
please_fill_in_your_speaker_profile: Моля, попълнете данните в лекторския си профил
expected_validation: "Очаква се потвърждение на: %{email}"
pass_update_hint1: Не попълвайте, ако не желаете да промените паролата си
pass_update_hint2: Попълнете, ако искате да промените паролата или e-mail адреса си.

View File

@ -18,6 +18,7 @@ en:
login_with: "Login with %{with}"
speaker_profile: Speaker's profile
please_fill_in_your_speaker_profile: Please fill in your speaker profile
expected_validation: "Expected confirmation of: %{email}"
pass_update_hint1: Do not fill, if you do not want to change your password
pass_update_hint2: Fill this if you want to change your password or e-mail.