Redirect to root if conference over

Fixes #791
This commit is contained in:
Chashmeet Singh 2016-03-01 17:59:25 +05:30
parent eda5c2bc07
commit e0b1fec14d

View file

@ -5,6 +5,14 @@ class ConferenceRegistrationsController < ApplicationController
before_action :set_registration, only: [:edit, :update, :destroy, :show]
def new
# Check if conference is over
# Display error if yes
if @conference.end_date < Date.today
flash[:alert] = "Sorry, the conference is already over."
redirect_to root_path
return
end
# Redirect to registration edit when user is already registered
if @conference.user_registered?(current_user)
redirect_to edit_conference_conference_registrations_path(@conference.short_title)