2017-10-22 22:38:48 +03:00
|
|
|
class Public::EventFeedbacksController < Public::ApplicationController
|
|
|
|
def new
|
2017-10-23 00:29:21 +03:00
|
|
|
if event.feedbacks.where(session_id: session.id).exists?
|
|
|
|
@feedback = event.feedbacks.where(session_id: session.id).order(updated_at: :asc).last
|
|
|
|
else
|
|
|
|
@feedback = event.feedbacks.build
|
2017-10-23 00:46:56 +03:00
|
|
|
@feedback.author_email = Feedback.where(session_id: session.id).order(updated_at: :asc).last.try(:author_email)
|
2017-10-23 00:29:21 +03:00
|
|
|
end
|
2017-10-22 22:38:48 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2017-10-23 00:29:21 +03:00
|
|
|
@feedback = event.feedbacks.build(feedback_params)
|
2017-10-22 23:40:12 +03:00
|
|
|
@feedback.ip_address = request.remote_ip
|
|
|
|
@feedback.session_id = session.id
|
2017-10-22 22:38:48 +03:00
|
|
|
|
|
|
|
if @feedback.save
|
2017-10-22 23:40:12 +03:00
|
|
|
flash[:notice] = I18n.t('public.event_feedbacks.new.success')
|
2017-10-23 00:29:21 +03:00
|
|
|
redirect_to conference_feedbacks_path
|
2017-10-22 22:38:48 +03:00
|
|
|
else
|
|
|
|
render :new, status: :unprocessable_entity
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def feedback_params
|
|
|
|
params.require(:feedback).permit(:author_email, :rating, :comment)
|
|
|
|
end
|
|
|
|
|
2017-10-23 00:29:21 +03:00
|
|
|
def event
|
|
|
|
approved_events.find(params[:event_id])
|
|
|
|
end
|
|
|
|
|
2017-10-22 22:38:48 +03:00
|
|
|
def approved_events
|
2018-11-24 11:21:22 +02:00
|
|
|
current_conference.events_of_all_editions.joins(:proposition).approved
|
2017-10-22 22:38:48 +03:00
|
|
|
end
|
|
|
|
end
|