Introduce feedbacks for events
This commit is contained in:
parent
2ac4464d1b
commit
3384a73204
|
@ -0,0 +1,25 @@
|
||||||
|
class Public::EventFeedbacksController < Public::ApplicationController
|
||||||
|
def new
|
||||||
|
@feedback = approved_events.find(params[:event_id]).feedbacks.build
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@feedback = approved_events.find(params[:event_id]).feedbacks.build(feedback_params)
|
||||||
|
|
||||||
|
if @feedback.save
|
||||||
|
redirect_to root_path
|
||||||
|
else
|
||||||
|
render :new, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def feedback_params
|
||||||
|
params.require(:feedback).permit(:author_email, :rating, :comment)
|
||||||
|
end
|
||||||
|
|
||||||
|
def approved_events
|
||||||
|
current_conference.events.joins(:proposition).approved
|
||||||
|
end
|
||||||
|
end
|
|
@ -22,6 +22,7 @@ class Conference < ActiveRecord::Base
|
||||||
has_many :participants, -> { uniq }, class_name: 'User', through: :events
|
has_many :participants, -> { uniq }, class_name: 'User', through: :events
|
||||||
has_many :participant_profiles, class_name: 'PersonalProfile'
|
has_many :participant_profiles, class_name: 'PersonalProfile'
|
||||||
has_many :slots, through: :halls
|
has_many :slots, through: :halls
|
||||||
|
has_many :feedbacks, as: :feedback_receiving, dependent: :destroy
|
||||||
|
|
||||||
accepts_nested_attributes_for :tracks, :halls, :event_types, :volunteer_teams,
|
accepts_nested_attributes_for :tracks, :halls, :event_types, :volunteer_teams,
|
||||||
reject_if: :all_blank, allow_destroy: true
|
reject_if: :all_blank, allow_destroy: true
|
||||||
|
|
|
@ -11,6 +11,7 @@ class Event < ActiveRecord::Base
|
||||||
has_many :participants, through: :approved_participations
|
has_many :participants, through: :approved_participations
|
||||||
has_many :participants_with_personal_profiles, through: :approved_participations, source: :participant_with_personal_profile
|
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 :conflict_counts, -> { order(number_of_conflicts: :desc) }, foreign_key: :left_id
|
||||||
|
has_many :feedbacks, as: :feedback_receiving, dependent: :destroy
|
||||||
|
|
||||||
belongs_to :event_type
|
belongs_to :event_type
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class Feedback < ActiveRecord::Base
|
||||||
|
belongs_to :feedback_receiving, polymorphic: true
|
||||||
|
|
||||||
|
validates :rating, presence: true, inclusion: {in: [2, 3, 4, 5 ,6]}
|
||||||
|
end
|
|
@ -9,5 +9,6 @@
|
||||||
json.event_type_id event.event_type_id
|
json.event_type_id event.event_type_id
|
||||||
json.track_id event.track_id
|
json.track_id event.track_id
|
||||||
json.participant_user_ids event.participations.map(&:participant_id)
|
json.participant_user_ids event.participations.map(&:participant_id)
|
||||||
|
json.feedback_url new_event_feedback_url(event_id: event.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
bg:
|
bg:
|
||||||
|
public:
|
||||||
|
event_feedbacks:
|
||||||
|
new:
|
||||||
|
feedback_for: Оценяване на „%{title}“
|
||||||
|
submit: Изпрати
|
||||||
management:
|
management:
|
||||||
volunteers:
|
volunteers:
|
||||||
index:
|
index:
|
||||||
|
@ -103,6 +108,10 @@ bg:
|
||||||
title: "Преглед на %{model}"
|
title: "Преглед на %{model}"
|
||||||
activerecord:
|
activerecord:
|
||||||
attributes:
|
attributes:
|
||||||
|
feedback:
|
||||||
|
author_email: E-mail
|
||||||
|
rating: Оценка
|
||||||
|
comment: Коментар
|
||||||
participation:
|
participation:
|
||||||
participant: Участник
|
participant: Участник
|
||||||
approved: Потвърдено от участника
|
approved: Потвърдено от участника
|
||||||
|
@ -208,6 +217,9 @@ bg:
|
||||||
volunteer_teams:
|
volunteer_teams:
|
||||||
invalid_volunteer_team: "невалиден екип от доброволци"
|
invalid_volunteer_team: "невалиден екип от доброволци"
|
||||||
models:
|
models:
|
||||||
|
feedback:
|
||||||
|
one: Оценка
|
||||||
|
other: Оценки
|
||||||
participation:
|
participation:
|
||||||
one: Участие
|
one: Участие
|
||||||
other: Участия
|
other: Участия
|
||||||
|
@ -372,6 +384,10 @@ bg:
|
||||||
vegetarian: Вегетарианец
|
vegetarian: Вегетарианец
|
||||||
vegan: Веган
|
vegan: Веган
|
||||||
hints:
|
hints:
|
||||||
|
feedback:
|
||||||
|
author_email: Адресът на електронната ви поща, ако счетете за нужно
|
||||||
|
rating: Посочете оценката си
|
||||||
|
comment: Тук може да изразите по-подробно мнението си
|
||||||
conference:
|
conference:
|
||||||
description: "Описание на конференцията"
|
description: "Описание на конференцията"
|
||||||
email: Email на организаторския екип
|
email: Email на организаторския екип
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
en:
|
en:
|
||||||
|
public:
|
||||||
|
event_feedbacks:
|
||||||
|
new:
|
||||||
|
feedback_for: Rating '%{title}'
|
||||||
|
submit: Submit
|
||||||
abstract: Abstract
|
abstract: Abstract
|
||||||
helpers:
|
helpers:
|
||||||
submit:
|
submit:
|
||||||
|
@ -29,6 +34,10 @@ en:
|
||||||
title: Viewing %{model}
|
title: Viewing %{model}
|
||||||
activerecord:
|
activerecord:
|
||||||
attributes:
|
attributes:
|
||||||
|
feedback:
|
||||||
|
author_email: E-mail
|
||||||
|
rating: Rating
|
||||||
|
comment: Comment
|
||||||
conference:
|
conference:
|
||||||
description: Description
|
description: Description
|
||||||
email: E-mail
|
email: E-mail
|
||||||
|
@ -271,6 +280,10 @@ en:
|
||||||
vegetarian: Vegetarian
|
vegetarian: Vegetarian
|
||||||
vegan: Vegan
|
vegan: Vegan
|
||||||
hints:
|
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:
|
conference:
|
||||||
description: Conference description
|
description: Conference description
|
||||||
email: Orga team email
|
email: Orga team email
|
||||||
|
|
|
@ -5,6 +5,7 @@ Rails.application.routes.draw do
|
||||||
root to: 'home#index'
|
root to: 'home#index'
|
||||||
resource :personal_profile, path: 'profile'
|
resource :personal_profile, path: 'profile'
|
||||||
resources :events do
|
resources :events do
|
||||||
|
resources :feedbacks, controller: 'event_feedbacks', only: [:new, :create]
|
||||||
member do
|
member do
|
||||||
get :confirm
|
get :confirm
|
||||||
end
|
end
|
||||||
|
|
|
@ -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,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_feedbacks_path 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