Merge branch 'feedback'
This commit is contained in:
commit
82f44e69c3
2
Gemfile
2
Gemfile
|
@ -56,6 +56,8 @@ gem 'search_object'
|
|||
|
||||
gem 'faraday'
|
||||
|
||||
gem 'rqrcode'
|
||||
|
||||
group :development do
|
||||
gem 'spring'
|
||||
gem 'spring-commands-rspec'
|
||||
|
|
|
@ -89,6 +89,7 @@ GEM
|
|||
mime-types (>= 1.16)
|
||||
mimemagic (>= 0.3.0)
|
||||
choice (0.2.0)
|
||||
chunky_png (1.3.8)
|
||||
coderay (1.1.1)
|
||||
coffee-rails (4.2.1)
|
||||
coffee-script (>= 2.2.0)
|
||||
|
@ -284,6 +285,8 @@ GEM
|
|||
mime-types (>= 1.16, < 3.0)
|
||||
netrc (~> 0.7)
|
||||
rmagick (2.16.0)
|
||||
rqrcode (0.10.1)
|
||||
chunky_png (~> 1.0)
|
||||
rspec (3.5.0)
|
||||
rspec-core (~> 3.5.0)
|
||||
rspec-expectations (~> 3.5.0)
|
||||
|
@ -423,6 +426,7 @@ DEPENDENCIES
|
|||
refile
|
||||
refile-mini_magick
|
||||
rmagick
|
||||
rqrcode
|
||||
rspec-rails
|
||||
sass-rails
|
||||
search_object
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
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
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@feedback = current_conference.feedbacks.build(feedback_params)
|
||||
@feedback.ip_address = request.remote_ip
|
||||
@feedback.session_id = session.id
|
||||
|
||||
if @feedback.save
|
||||
flash[:notice] = I18n.t('public.conference_feedbacks.new.success')
|
||||
redirect_to conference_feedbacks_path
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def feedback_params
|
||||
params.require(:feedback).permit(:author_email, :rating, :comment)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
class Public::EventFeedbackQrcodesController < Public::ApplicationController
|
||||
def show
|
||||
event = current_conference.events.joins(:proposition).approved.find(params[:event_id])
|
||||
@qr = RQRCode::QRCode.new(new_event_feedback_url(event_id: event.id), level: :l)
|
||||
|
||||
respond_to do |format|
|
||||
format.svg do
|
||||
render(inline: @qr.as_svg(shape_rendering: 'crispEdges', module_size: 11, fill: 'ffffff', offset: 10),
|
||||
filename: "feedback_qr_code_#{event.id}.svg")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,36 @@
|
|||
class Public::EventFeedbacksController < Public::ApplicationController
|
||||
def new
|
||||
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
|
||||
|
||||
def create
|
||||
@feedback = event.feedbacks.build(feedback_params)
|
||||
@feedback.ip_address = request.remote_ip
|
||||
@feedback.session_id = session.id
|
||||
|
||||
if @feedback.save
|
||||
flash[:notice] = I18n.t('public.event_feedbacks.new.success')
|
||||
redirect_to conference_feedbacks_path
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def feedback_params
|
||||
params.require(:feedback).permit(:author_email, :rating, :comment)
|
||||
end
|
||||
|
||||
def event
|
||||
approved_events.find(params[:event_id])
|
||||
end
|
||||
|
||||
def approved_events
|
||||
current_conference.events.joins(:proposition).approved
|
||||
end
|
||||
end
|
|
@ -23,4 +23,15 @@ module EventsHelper
|
|||
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
|
||||
|
|
|
@ -22,6 +22,7 @@ class Conference < ActiveRecord::Base
|
|||
has_many :participants, -> { uniq }, class_name: 'User', through: :events
|
||||
has_many :participant_profiles, class_name: 'PersonalProfile'
|
||||
has_many :slots, through: :halls
|
||||
has_many :feedbacks, as: :feedback_receiving, dependent: :destroy
|
||||
|
||||
accepts_nested_attributes_for :tracks, :halls, :event_types, :volunteer_teams,
|
||||
reject_if: :all_blank, allow_destroy: true
|
||||
|
|
|
@ -11,6 +11,7 @@ class Event < ActiveRecord::Base
|
|||
has_many :participants, through: :approved_participations
|
||||
has_many :participants_with_personal_profiles, through: :approved_participations, source: :participant_with_personal_profile
|
||||
has_many :conflict_counts, -> { order(number_of_conflicts: :desc) }, foreign_key: :left_id
|
||||
has_many :feedbacks, as: :feedback_receiving, dependent: :destroy
|
||||
|
||||
belongs_to :event_type
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
class Feedback < ActiveRecord::Base
|
||||
belongs_to :feedback_receiving, polymorphic: true
|
||||
|
||||
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
|
|
@ -9,5 +9,7 @@
|
|||
json.event_type_id event.event_type_id
|
||||
json.track_id event.track_id
|
||||
json.participant_user_ids event.participations.map(&:participant_id)
|
||||
json.feedback_url new_event_feedback_url(event_id: event.id)
|
||||
json.feedback_qr_code_url event_feedback_qr_code_url(event_id: event.id, format: :svg)
|
||||
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" }
|
||||
|
||||
# Default value for keep_releases is 5
|
||||
# set :keep_releases, 5
|
||||
set :keep_releases, 10
|
||||
|
||||
set :rvm_ruby_version, '2.2.2'
|
||||
|
||||
|
|
|
@ -2,3 +2,5 @@
|
|||
|
||||
# Add new mime types for use in respond_to blocks:
|
||||
# Mime::Type.register "text/richtext", :rtf
|
||||
|
||||
Mime::Type.register "image/svg+xml", :svg
|
||||
|
|
|
@ -1,4 +1,20 @@
|
|||
bg:
|
||||
public:
|
||||
event_feedbacks:
|
||||
new: &new_feedbacks_bg
|
||||
feedback_for: Оценяване на „%{title}“
|
||||
submit: Изпрати
|
||||
success: Оценката беше изпратена успешно
|
||||
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:
|
||||
volunteers:
|
||||
index:
|
||||
|
@ -103,6 +119,10 @@ bg:
|
|||
title: "Преглед на %{model}"
|
||||
activerecord:
|
||||
attributes:
|
||||
feedback:
|
||||
author_email: E-mail
|
||||
rating: Оценка
|
||||
comment: Коментар
|
||||
participation:
|
||||
participant: Участник
|
||||
approved: Потвърдено от участника
|
||||
|
@ -208,6 +228,9 @@ bg:
|
|||
volunteer_teams:
|
||||
invalid_volunteer_team: "невалиден екип от доброволци"
|
||||
models:
|
||||
feedback:
|
||||
one: Оценка
|
||||
other: Оценки
|
||||
participation:
|
||||
one: Участие
|
||||
other: Участия
|
||||
|
@ -372,6 +395,10 @@ bg:
|
|||
vegetarian: Вегетарианец
|
||||
vegan: Веган
|
||||
hints:
|
||||
feedback:
|
||||
author_email: Адресът на електронната ви поща, ако счетете за нужно
|
||||
rating: Посочете оценката си
|
||||
comment: Тук може да изразите по-подробно мнението си
|
||||
conference:
|
||||
description: "Описание на конференцията"
|
||||
email: Email на организаторския екип
|
||||
|
|
|
@ -1,4 +1,20 @@
|
|||
en:
|
||||
public:
|
||||
event_feedbacks:
|
||||
new: &new_feedbacks_en
|
||||
feedback_for: Rating '%{title}'
|
||||
submit: Submit
|
||||
success: The feedback was submitted successfully
|
||||
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
|
||||
helpers:
|
||||
submit:
|
||||
|
@ -29,6 +45,10 @@ en:
|
|||
title: Viewing %{model}
|
||||
activerecord:
|
||||
attributes:
|
||||
feedback:
|
||||
author_email: E-mail
|
||||
rating: Rating
|
||||
comment: Comment
|
||||
conference:
|
||||
description: Description
|
||||
email: E-mail
|
||||
|
@ -271,6 +291,10 @@ en:
|
|||
vegetarian: Vegetarian
|
||||
vegan: Vegan
|
||||
hints:
|
||||
feedback:
|
||||
author_email: "Your E-mail address if you'd like to share it with us"
|
||||
rating: Select your rating for the event
|
||||
comment: Express your opinion in greater detail here
|
||||
conference:
|
||||
description: Conference description
|
||||
email: Orga team email
|
||||
|
|
|
@ -5,12 +5,15 @@ Rails.application.routes.draw do
|
|||
root to: 'home#index'
|
||||
resource :personal_profile, path: 'profile'
|
||||
resources :events do
|
||||
resources :feedback, controller: 'event_feedbacks', only: [:new, :create]
|
||||
resource :feedback_qr_code, controller: 'event_feedback_qrcodes', only: :show
|
||||
member do
|
||||
get :confirm
|
||||
end
|
||||
end
|
||||
resources :volunteers
|
||||
resources :volunteer_teams, only: [:index]
|
||||
resources :feedback, as: 'conference_feedbacks', controller: 'conference_feedbacks', only: [:new, :create, :index]
|
||||
end
|
||||
|
||||
namespace :api do
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
class CreateFeedbacks < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :feedbacks do |t|
|
||||
t.references :feedback_receiving, index: {name: :feedbacks_polymorphic_index}, polymorphic: true, null: false
|
||||
t.string :author_email
|
||||
t.integer :rating, null: false
|
||||
t.text :comment, null: false
|
||||
t.string :ip_address
|
||||
t.string :session_id, index: true
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -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(', '))
|
|
@ -0,0 +1,14 @@
|
|||
- content_for(: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, method: :post do |f|
|
||||
= f.error_notification
|
||||
|
||||
.form-inputs
|
||||
= f.input :author_email, autofocus: true
|
||||
= f.input :rating, collection: [2, 3, 4, 5, 6], as: :radio_buttons, include_blank: false, wrapper: :default
|
||||
= f.input :comment
|
||||
|
||||
.form-actions
|
||||
= f.button :submit, t('.submit')
|
|
@ -0,0 +1,14 @@
|
|||
- content_for(: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_feedback_index_path, method: :post do |f|
|
||||
= f.error_notification
|
||||
|
||||
.form-inputs
|
||||
= f.input :author_email, autofocus: true
|
||||
= f.input :rating, collection: [2, 3, 4, 5, 6], as: :radio_buttons, include_blank: false, wrapper: :default
|
||||
= f.input :comment
|
||||
|
||||
.form-actions
|
||||
= f.button :submit, t('.submit')
|
|
@ -0,0 +1 @@
|
|||
p Hello
|
Loading…
Reference in New Issue