2014-05-19 21:21:06 +05:30
|
|
|
class ConferenceController < ApplicationController
|
2014-08-12 11:51:59 +03:00
|
|
|
load_and_authorize_resource find_by: :short_title
|
|
|
|
|
|
2014-08-12 22:27:02 +03:00
|
|
|
def show; end
|
2014-06-30 19:24:26 +05:30
|
|
|
|
2014-07-25 13:13:35 +05:30
|
|
|
def subscribe
|
|
|
|
|
conference = Conference.find_by_short_title(params[:id])
|
|
|
|
|
if current_user.subscriptions.where(conference: conference).blank?
|
|
|
|
|
subscription = Subscription.new(user_id: current_user.id, conference_id: conference.id)
|
|
|
|
|
begin
|
|
|
|
|
subscription.save!
|
|
|
|
|
flash[:success] = "You have been subscribed to receive Email Notifications from this Conference."
|
|
|
|
|
redirect_to root_path
|
|
|
|
|
rescue ActiveRecord::RecordInvalid
|
|
|
|
|
flash[:error] = subscription.errors.full_messages.to_sentence
|
|
|
|
|
redirect_to root_path
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
flash[:notice] = "Already Subscribed"
|
|
|
|
|
redirect_to root_path
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def unsubscribe
|
|
|
|
|
conference = Conference.find_by_short_title(params[:id])
|
|
|
|
|
subscription = current_user.subscriptions.where(conference_id: conference.id).first
|
|
|
|
|
if subscription.blank?
|
|
|
|
|
flash[:notice] = "Already Unsubscribed"
|
|
|
|
|
redirect_to root_path
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
subscription.destroy!
|
|
|
|
|
flash[:notice] = "You have been unsubscribed and now you won't be receiving any Email Notifications."
|
|
|
|
|
redirect_to root_path
|
|
|
|
|
rescue ActiveRecord::RecordInvalid
|
|
|
|
|
flash[:error] = subscription.errors.full_messages.to_sentence
|
|
|
|
|
redirect_to root_path
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-07-02 00:25:09 +05:30
|
|
|
def gallery_photos
|
2014-08-12 11:51:59 +03:00
|
|
|
@photos = @conference.photos
|
2014-06-30 20:32:34 +05:30
|
|
|
render "photos", formats: [:js]
|
2014-06-30 19:24:26 +05:30
|
|
|
end
|
2014-05-19 21:21:06 +05:30
|
|
|
end
|