From f34de8f10729a939c6e6f91159e1da15d2f18f44 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Tue, 2 Sep 2014 12:31:15 +0300 Subject: [PATCH] Redirect to Speaker Profile after event creation --- app/controllers/lectures_controller.rb | 13 +++++++++++-- app/controllers/workshops_controller.rb | 12 ++++++++++-- config/locales/views.bg.yml | 1 + config/locales/views.en.yml | 1 + 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/controllers/lectures_controller.rb b/app/controllers/lectures_controller.rb index 4a03ea4..64bcfe9 100644 --- a/app/controllers/lectures_controller.rb +++ b/app/controllers/lectures_controller.rb @@ -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 diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb index 06ffe48..f133091 100644 --- a/app/controllers/workshops_controller.rb +++ b/app/controllers/workshops_controller.rb @@ -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 diff --git a/config/locales/views.bg.yml b/config/locales/views.bg.yml index ffe2f64..ac5620f 100644 --- a/config/locales/views.bg.yml +++ b/config/locales/views.bg.yml @@ -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 адреса си. diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index 5185465..59d7c50 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -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.