Introduce conference feedback

This commit is contained in:
Petko Bordjukov 2017-10-22 23:40:12 +03:00
parent 47d2ec99b1
commit 39217a24c1
6 changed files with 49 additions and 3 deletions

View File

@ -0,0 +1,24 @@
class Public::ConferenceFeedbacksController < Public::ApplicationController
def new
@feedback = current_conference.feedbacks.build
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 root_path
else
render :new, status: :unprocessable_entity
end
end
private
def feedback_params
params.require(:feedback).permit(:author_email, :rating, :comment)
end
end

View File

@ -5,8 +5,11 @@ class Public::EventFeedbacksController < Public::ApplicationController
def create def create
@feedback = approved_events.find(params[:event_id]).feedbacks.build(feedback_params) @feedback = approved_events.find(params[:event_id]).feedbacks.build(feedback_params)
@feedback.ip_address = request.remote_ip
@feedback.session_id = session.id
if @feedback.save if @feedback.save
flash[:notice] = I18n.t('public.event_feedbacks.new.success')
redirect_to root_path redirect_to root_path
else else
render :new, status: :unprocessable_entity render :new, status: :unprocessable_entity

View File

@ -1,9 +1,11 @@
bg: bg:
public: public:
event_feedbacks: event_feedbacks: &feedbacks_bg
new: new:
feedback_for: Оценяване на „%{title}“ feedback_for: Оценяване на „%{title}“
submit: Изпрати submit: Изпрати
success: Оценката беше изпратена успешно
conference_feedbacks: *feedbacks_bg
management: management:
volunteers: volunteers:
index: index:

View File

@ -1,9 +1,11 @@
en: en:
public: public:
event_feedbacks: event_feedbacks: &feedbacks_en
new: new:
feedback_for: Rating '%{title}' feedback_for: Rating '%{title}'
submit: Submit submit: Submit
success: The feedback was submitted successfully
conference_feedbacks: *feedbacks_en
abstract: Abstract abstract: Abstract
helpers: helpers:
submit: submit:

View File

@ -5,7 +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] resources :feedback, controller: 'event_feedbacks', only: [:new, :create]
resource :feedback_qr_code, controller: 'event_feedback_qrcodes', only: :show resource :feedback_qr_code, controller: 'event_feedback_qrcodes', only: :show
member do member do
get :confirm get :confirm
@ -13,6 +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]
end end
namespace :api do namespace :api do

View File

@ -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 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')