Implement a way for users to confirm submissions

This commit is contained in:
Petko Bordjukov 2014-10-12 15:10:21 +03:00
parent 97fcc32990
commit cf815695b7
5 changed files with 31 additions and 6 deletions

View File

@ -1,6 +1,6 @@
class LecturesController < ApplicationController class LecturesController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_action :assign_lecture, only: [:show, :edit, :update] before_action :assign_lecture, only: [:show, :edit, :update, :confirm]
def index def index
@lectures = Lecture.where user: current_user @lectures = Lecture.where user: current_user
@ -34,6 +34,11 @@ class LecturesController < ApplicationController
def show def show
end end
def confirm
@lecture.touch :confirmed_at
redirect_to @lecture, notice: I18n.t(:lecture_was_successfully_confirmed)
end
private private
def assign_lecture def assign_lecture

View File

@ -1,6 +1,6 @@
class WorkshopsController < ApplicationController class WorkshopsController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
before_action :assign_workshop, only: [:show, :edit, :update] before_action :assign_workshop, only: [:show, :edit, :update, :confirm]
def index def index
@workshops = Workshop.where user: current_user @workshops = Workshop.where user: current_user
@ -34,6 +34,11 @@ class WorkshopsController < ApplicationController
def show def show
end end
def confirm
@workshop.touch :confirmed_at
redirect_to @workshop, notice: I18n.t(:workshop_was_successfully_confirmed)
end
private private
def assign_workshop def assign_workshop

View File

@ -68,4 +68,7 @@ bg:
of_motto: да споделим свободата of_motto: да споделим свободата
meta_data: "Език: %{language}, поток: „%{track}“, продължителност: %{length} мин." meta_data: "Език: %{language}, поток: „%{track}“, продължителност: %{length} мин."
suggestion_and_speaker_count: "%{suggestions} предложения от %{speakers} лектори" suggestion_and_speaker_count: "%{suggestions} предложения от %{speakers} лектори"
lecture_was_successfully_confirmed: "Лекцията беше потвърдена успешно"
workshop_was_successfully_confirmed: "Уъркшопът беше потвърден успешно"

View File

@ -66,4 +66,7 @@ en:
of_motto: share the freedom of_motto: share the freedom
meta_data: "Language: %{language}, track: \"%{track}\", length: %{length} min." meta_data: "Language: %{language}, track: \"%{track}\", length: %{length} min."
suggestion_and_speaker_count: "%{suggestions} suggestions by %{speakers} speakers" 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"

View File

@ -1,6 +1,15 @@
Rails.application.routes.draw do Rails.application.routes.draw do
resources :lectures, only: [:index, :new, :create, :edit, :update, :show] resources :lectures, only: [:index, :new, :create, :edit, :update, :show] do
resources :workshops, only: [:index, :new, :create, :edit, :update, :show] 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'} devise_for :users, controllers: {registrations: 'registrations', sessions: 'sessions'}