Implement listing of things that feedback can be submitted for
This commit is contained in:
parent
39217a24c1
commit
a12baf2b94
|
@ -1,7 +1,25 @@
|
||||||
class Public::ConferenceFeedbacksController < Public::ApplicationController
|
class Public::ConferenceFeedbacksController < Public::ApplicationController
|
||||||
|
def index
|
||||||
|
@conference = current_conference
|
||||||
|
@unrated_events = @conference.events
|
||||||
|
.joins(:proposition).approved
|
||||||
|
.joins('LEFT JOIN feedbacks ON feedbacks.feedback_receiving_id = events.id AND feedbacks.feedback_receiving_type = "Event"')
|
||||||
|
.where('feedbacks.session_id != ? OR feedbacks.id IS NULL', session.id)
|
||||||
|
|
||||||
|
@rated_events = @conference.events
|
||||||
|
.joins(:proposition).approved
|
||||||
|
.joins(:feedbacks)
|
||||||
|
.where(feedbacks: {session_id: session.id}).distinct
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
if current_conference.feedbacks.where(session_id: session.id).exists?
|
||||||
|
@feedback = current_conference.feedbacks.where(session_id: session.id).order(updated_at: :asc).last
|
||||||
|
else
|
||||||
@feedback = current_conference.feedbacks.build
|
@feedback = current_conference.feedbacks.build
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@feedback = current_conference.feedbacks.build(feedback_params)
|
@feedback = current_conference.feedbacks.build(feedback_params)
|
||||||
|
@ -10,7 +28,7 @@ class Public::ConferenceFeedbacksController < Public::ApplicationController
|
||||||
|
|
||||||
if @feedback.save
|
if @feedback.save
|
||||||
flash[:notice] = I18n.t('public.conference_feedbacks.new.success')
|
flash[:notice] = I18n.t('public.conference_feedbacks.new.success')
|
||||||
redirect_to root_path
|
redirect_to conference_feedbacks_path
|
||||||
else
|
else
|
||||||
render :new, status: :unprocessable_entity
|
render :new, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
class Public::EventFeedbacksController < Public::ApplicationController
|
class Public::EventFeedbacksController < Public::ApplicationController
|
||||||
def new
|
def new
|
||||||
@feedback = approved_events.find(params[:event_id]).feedbacks.build
|
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
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@feedback = approved_events.find(params[:event_id]).feedbacks.build(feedback_params)
|
@feedback = event.feedbacks.build(feedback_params)
|
||||||
@feedback.ip_address = request.remote_ip
|
@feedback.ip_address = request.remote_ip
|
||||||
@feedback.session_id = session.id
|
@feedback.session_id = session.id
|
||||||
|
|
||||||
if @feedback.save
|
if @feedback.save
|
||||||
flash[:notice] = I18n.t('public.event_feedbacks.new.success')
|
flash[:notice] = I18n.t('public.event_feedbacks.new.success')
|
||||||
redirect_to root_path
|
redirect_to conference_feedbacks_path
|
||||||
else
|
else
|
||||||
render :new, status: :unprocessable_entity
|
render :new, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
@ -22,6 +26,10 @@ class Public::EventFeedbacksController < Public::ApplicationController
|
||||||
params.require(:feedback).permit(:author_email, :rating, :comment)
|
params.require(:feedback).permit(:author_email, :rating, :comment)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def event
|
||||||
|
approved_events.find(params[:event_id])
|
||||||
|
end
|
||||||
|
|
||||||
def approved_events
|
def approved_events
|
||||||
current_conference.events.joins(:proposition).approved
|
current_conference.events.joins(:proposition).approved
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,4 +23,15 @@ module EventsHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def participant_names(event)
|
||||||
|
event.participants.map do |participant|
|
||||||
|
if participant.personal_profile(event.conference).present?
|
||||||
|
profile = participant.personal_profile(event.conference)
|
||||||
|
"#{profile.name}"
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end.compact
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,4 +2,12 @@ class Feedback < ActiveRecord::Base
|
||||||
belongs_to :feedback_receiving, polymorphic: true
|
belongs_to :feedback_receiving, polymorphic: true
|
||||||
|
|
||||||
validates :rating, presence: true, inclusion: {in: [2, 3, 4, 5 ,6]}
|
validates :rating, presence: true, inclusion: {in: [2, 3, 4, 5 ,6]}
|
||||||
|
|
||||||
|
before_create :destroy_older_feedbacks_by_the_session
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def destroy_older_feedbacks_by_the_session
|
||||||
|
feedback_receiving.feedbacks.where(session_id: session_id).destroy_all
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,7 +32,7 @@ set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/uploads', 'tmp/pids',
|
||||||
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
||||||
|
|
||||||
# Default value for keep_releases is 5
|
# Default value for keep_releases is 5
|
||||||
# set :keep_releases, 5
|
set :keep_releases, 10
|
||||||
|
|
||||||
set :rvm_ruby_version, '2.2.2'
|
set :rvm_ruby_version, '2.2.2'
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
bg:
|
bg:
|
||||||
public:
|
public:
|
||||||
event_feedbacks: &feedbacks_bg
|
event_feedbacks:
|
||||||
new:
|
new: &new_feedbacks_bg
|
||||||
feedback_for: Оценяване на „%{title}“
|
feedback_for: Оценяване на „%{title}“
|
||||||
submit: Изпрати
|
submit: Изпрати
|
||||||
success: Оценката беше изпратена успешно
|
success: Оценката беше изпратена успешно
|
||||||
conference_feedbacks: *feedbacks_bg
|
conference_feedbacks:
|
||||||
|
new: *new_feedbacks_bg
|
||||||
|
index:
|
||||||
|
feedback_for_the_conference: Оценяване на конференцията
|
||||||
|
general_feedback_for: Оценете цялостно %{title}
|
||||||
|
change_general_feedback_for: Преоценете цялостно %{title}
|
||||||
|
feedback_for: Оценете „%{title}“
|
||||||
|
change_feedback_for: Преоценете „%{title}“
|
||||||
|
by: от %{authors}
|
||||||
|
feedback_incentive: Бихме били благодарни, ако споделите с нас мнението си за конференцията и събитията в нея.
|
||||||
management:
|
management:
|
||||||
volunteers:
|
volunteers:
|
||||||
index:
|
index:
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
en:
|
en:
|
||||||
public:
|
public:
|
||||||
event_feedbacks: &feedbacks_en
|
event_feedbacks:
|
||||||
new:
|
new: &new_feedbacks_en
|
||||||
feedback_for: Rating '%{title}'
|
feedback_for: Rating '%{title}'
|
||||||
submit: Submit
|
submit: Submit
|
||||||
success: The feedback was submitted successfully
|
success: The feedback was submitted successfully
|
||||||
conference_feedbacks: *feedbacks_en
|
conference_feedbacks:
|
||||||
|
new: *new_feedbacks_en
|
||||||
|
index:
|
||||||
|
feedback_for_the_conference: Feedback for the conference
|
||||||
|
general_feedback_for: Submit general feedback for "%{title}"
|
||||||
|
change_general_feedback_for: Resubmit general feedback for "%{title}"
|
||||||
|
feedback_for: Submit feedback for "%{title}"
|
||||||
|
change_feedback_for: Resubmit feedback for "%{title}"
|
||||||
|
by: by %{authors}
|
||||||
|
feedback_incentive: We would be happy to receive your feedback about the conference and its events.
|
||||||
abstract: Abstract
|
abstract: Abstract
|
||||||
helpers:
|
helpers:
|
||||||
submit:
|
submit:
|
||||||
|
|
|
@ -13,7 +13,7 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
resources :volunteers
|
resources :volunteers
|
||||||
resources :volunteer_teams, only: [:index]
|
resources :volunteer_teams, only: [:index]
|
||||||
resources :feedback, as: 'conference_feedbacks', controller: 'conference_feedbacks', only: [:new, :create]
|
resources :feedback, as: 'conference_feedbacks', controller: 'conference_feedbacks', only: [:new, :create, :index]
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :api do
|
namespace :api do
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
- content_for(:title) { t('.feedback_for_the_conference') }
|
||||||
|
|
||||||
|
h1.entry-title = t('.feedback_for_the_conference')
|
||||||
|
|
||||||
|
p = t('.feedback_incentive')
|
||||||
|
|
||||||
|
ul
|
||||||
|
- if @conference.feedbacks.where(session_id: session.id).exists?
|
||||||
|
li = link_to t('.change_general_feedback_for', title: @conference.title), new_conference_feedback_path
|
||||||
|
- else
|
||||||
|
li = link_to t('.general_feedback_for', title: @conference.title), new_conference_feedback_path
|
||||||
|
|
||||||
|
ul
|
||||||
|
- @unrated_events.each do |event|
|
||||||
|
li
|
||||||
|
= link_to t('.feedback_for', title: event.title), new_event_feedback_path(event_id: event.id)
|
||||||
|
- if participant_names(event).any?
|
||||||
|
=< t('.by', authors: participant_names(event).join(', '))
|
||||||
|
|
||||||
|
ul
|
||||||
|
- @rated_events.each do |event|
|
||||||
|
li
|
||||||
|
= link_to t('.change_feedback_for', title: event.title), new_event_feedback_path(event_id: event.id)
|
||||||
|
- if participant_names(event).any?
|
||||||
|
=< t('.by', authors: participant_names(event).join(', '))
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
h1.entry-title = t('.feedback_for', title: @feedback.feedback_receiving.title)
|
h1.entry-title = t('.feedback_for', title: @feedback.feedback_receiving.title)
|
||||||
|
|
||||||
= simple_form_for @feedback, wrapper: :default, url: conference_feedbacks_path do |f|
|
= simple_form_for @feedback, wrapper: :default, url: conference_feedbacks_path, method: :post do |f|
|
||||||
= f.error_notification
|
= f.error_notification
|
||||||
|
|
||||||
.form-inputs
|
.form-inputs
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
h1.entry-title = t('.feedback_for', title: @feedback.feedback_receiving.title)
|
h1.entry-title = t('.feedback_for', title: @feedback.feedback_receiving.title)
|
||||||
|
|
||||||
= simple_form_for @feedback, wrapper: :default, url: event_feedbacks_path do |f|
|
= simple_form_for @feedback, wrapper: :default, url: event_feedback_index_path, method: :post do |f|
|
||||||
= f.error_notification
|
= f.error_notification
|
||||||
|
|
||||||
.form-inputs
|
.form-inputs
|
||||||
|
|
Loading…
Reference in New Issue