From cf815695b76c076f4270485b607e22be6c53ced0 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Sun, 12 Oct 2014 15:10:21 +0300 Subject: [PATCH] Implement a way for users to confirm submissions --- app/controllers/lectures_controller.rb | 7 ++++++- app/controllers/workshops_controller.rb | 7 ++++++- config/locales/views.bg.yml | 5 ++++- config/locales/views.en.yml | 5 ++++- config/routes.rb | 13 +++++++++++-- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/app/controllers/lectures_controller.rb b/app/controllers/lectures_controller.rb index 69a46b5..1128938 100644 --- a/app/controllers/lectures_controller.rb +++ b/app/controllers/lectures_controller.rb @@ -1,6 +1,6 @@ class LecturesController < ApplicationController before_filter :authenticate_user! - before_action :assign_lecture, only: [:show, :edit, :update] + before_action :assign_lecture, only: [:show, :edit, :update, :confirm] def index @lectures = Lecture.where user: current_user @@ -34,6 +34,11 @@ class LecturesController < ApplicationController def show end + def confirm + @lecture.touch :confirmed_at + redirect_to @lecture, notice: I18n.t(:lecture_was_successfully_confirmed) + end + private def assign_lecture diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb index 61b7350..678939c 100644 --- a/app/controllers/workshops_controller.rb +++ b/app/controllers/workshops_controller.rb @@ -1,6 +1,6 @@ class WorkshopsController < ApplicationController before_filter :authenticate_user! - before_action :assign_workshop, only: [:show, :edit, :update] + before_action :assign_workshop, only: [:show, :edit, :update, :confirm] def index @workshops = Workshop.where user: current_user @@ -34,6 +34,11 @@ class WorkshopsController < ApplicationController def show end + def confirm + @workshop.touch :confirmed_at + redirect_to @workshop, notice: I18n.t(:workshop_was_successfully_confirmed) + end + private def assign_workshop diff --git a/config/locales/views.bg.yml b/config/locales/views.bg.yml index 8484f44..d60d599 100644 --- a/config/locales/views.bg.yml +++ b/config/locales/views.bg.yml @@ -68,4 +68,7 @@ bg: of_motto: да споделим свободата meta_data: "Език: %{language}, поток: „%{track}“, продължителност: %{length} мин." - suggestion_and_speaker_count: "%{suggestions} предложения от %{speakers} лектори" \ No newline at end of file + suggestion_and_speaker_count: "%{suggestions} предложения от %{speakers} лектори" + + lecture_was_successfully_confirmed: "Лекцията беше потвърдена успешно" + workshop_was_successfully_confirmed: "Уъркшопът беше потвърден успешно" \ No newline at end of file diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index 2360cb9..231e987 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -66,4 +66,7 @@ en: of_motto: share the freedom meta_data: "Language: %{language}, track: \"%{track}\", length: %{length} min." - suggestion_and_speaker_count: "%{suggestions} suggestions by %{speakers} speakers" \ No newline at end of file + suggestion_and_speaker_count: "%{suggestions} suggestions by %{speakers} speakers" + + lecture_was_successfully_confirmed: "The lecture was successfully confirmed" + workshop_was_successfully_confirmed: "The workshop was successfully confirmed" \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 3ce2018..113916d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,15 @@ Rails.application.routes.draw do - resources :lectures, only: [:index, :new, :create, :edit, :update, :show] - resources :workshops, only: [:index, :new, :create, :edit, :update, :show] + resources :lectures, only: [:index, :new, :create, :edit, :update, :show] do + member do + get 'confirm' + end + end + + resources :workshops, only: [:index, :new, :create, :edit, :update, :show] do + member do + get 'confirm' + end + end devise_for :users, controllers: {registrations: 'registrations', sessions: 'sessions'}