diff --git a/app/controllers/management/feedback_controller.rb b/app/controllers/management/feedback_controller.rb new file mode 100644 index 0000000..a28921d --- /dev/null +++ b/app/controllers/management/feedback_controller.rb @@ -0,0 +1,13 @@ +module Management + class FeedbackController < ManagementController + def index + @conference = find_conference + end + + private + + def find_conference + Conference.eager_load(:feedbacks, :feedbacks_with_comment, :event_feedbacks, :event_feedbacks_with_comment).find(params[:conference_id]) + end + end +end diff --git a/app/models/conference.rb b/app/models/conference.rb index 49abb8e..7ed78ae 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -22,10 +22,15 @@ class Conference < ActiveRecord::Base has_many :participants, -> { distinct }, class_name: "User", through: :events has_many :participant_profiles, class_name: "PersonalProfile" has_many :slots, through: :halls - has_many :feedbacks, as: :feedback_receiving has_many :editions, primary_key: :host_name, foreign_key: :host_name, class_name: "Conference" has_many :events_of_all_editions, through: :editions, source: :events + include FeedbackReceiving + has_many :feedbacks, as: :feedback_receiving + has_many :feedbacks_with_comment, -> { where.not(comment: [nil, ""]) }, as: :feedback_receiving, class_name: 'Feedback' + has_many :event_feedbacks, through: :events, source: :feedbacks + has_many :event_feedbacks_with_comment, through: :events, source: :feedbacks_with_comment + accepts_nested_attributes_for :tracks, :halls, :event_types, :volunteer_teams, reject_if: :all_blank, allow_destroy: true diff --git a/app/views/layouts/management/_navigation.html.slim b/app/views/layouts/management/_navigation.html.slim index e128d57..5a141c2 100644 --- a/app/views/layouts/management/_navigation.html.slim +++ b/app/views/layouts/management/_navigation.html.slim @@ -32,7 +32,9 @@ nav.navbar.navbar-static-top.navbar-inverse role="navigation" / li class="#{'active' if controller_name == 'propositions'}" / = link_to [:management, current_conference, :propositions] do / => icon 'question', Proposition.model_name.human(count: 2).mb_chars.capitalize, class: 'fa-fw' - + li class="#{'active' if controller_name == 'feedback'}" + = link_to management_conference_feedback_index_path(current_conference) do + => icon 'star-half-o', t('activerecord.models.feedback', count: 2).mb_chars.capitalize, class: 'fa-fw' ul.nav.navbar-nav.navbar-right li.dropdown = link_to '#', class: 'dropdown-toggle', data: {toggle: 'dropdown'} do diff --git a/app/views/management/feedback/index.csv.erb b/app/views/management/feedback/index.csv.erb new file mode 100644 index 0000000..60d334c --- /dev/null +++ b/app/views/management/feedback/index.csv.erb @@ -0,0 +1,8 @@ +<%- csv_headers = %w{id feedback_receiving_type feedback_receiving_id name/title author_email rating comment ip session_id created_at} -%> +<%= CSV.generate_line(csv_headers).html_safe -%> +<%- @conference.feedbacks.each do |feedback| -%> +<%= CSV.generate_line([feedback.id, feedback.feedback_receiving_type, feedback.feedback_receiving_id, feedback.feedback_receiving&.title || feefback.feedback_receiving&.name, feedback.author_email, feedback.rating, feedback.comment, feedback.ip_address, feedback.session_id, feedback.created_at]).html_safe -%> +<%- end -%> +<%- @conference.event_feedbacks.each do |feedback| -%> +<%= CSV.generate_line([feedback.id, feedback.feedback_receiving_type, feedback.feedback_receiving_id, feedback.feedback_receiving&.title || feefback.feedback_receiving&.name, feedback.author_email, feedback.rating, feedback.comment, feedback.ip_address, feedback.session_id, feedback.created_at]).html_safe -%> +<%- end -%> diff --git a/app/views/management/feedback/index.html.slim b/app/views/management/feedback/index.html.slim new file mode 100644 index 0000000..bbb9990 --- /dev/null +++ b/app/views/management/feedback/index.html.slim @@ -0,0 +1,62 @@ +- content_for :title + = t '.feedback' + +.row + .col-lg-12 + h1.page-header + = t '.feedback' + = link_to management_conference_feedback_index_path(@conference, format: 'csv'), class: 'btn btn-info pull-right' + = icon :download, t('.export') + +- if @conference.start_date.past? || @conference.rated? + .row + .col-xs-12 + h3 + =< t '.overall_organisation' + - if @conference.rated? + .row + .col-md-10 + .panel.panel-default + .panel-heading = t('.comments') + - if @conference.feedbacks_with_comment.order(created_at: :asc).size > 0 + table.table.table-striped + tbody + = render partial: '/management/shared/feedback', collection: @conference.feedbacks_with_comment.order(created_at: :asc), locals: {hide_title: true} + - else + .panel-body + = t ('.no_comments_received') + .col-md-2 + .panel.panel-info + .panel-heading + = t '.average_grade' + .panel-body.text-right + .huge + = number_with_precision(@conference.average_rating, precision: 2, strip_insignificant_zeros: true) || '–' + = t('.total_feedback_grades', total_grades: @conference.feedbacks.count, count: @conference.feedbacks.count) + - else + p = t '.no_feedback_received' + +- if @conference.start_date.past? || @conference.event_feedbacks_with_comment.order(created_at: :asc).size > 0 + .row + .col-xs-12 + h3 + =< t '.events' + + - if @conference.event_feedbacks.size > 0 + .row + .col-md-10 + .panel.panel-default + .panel-heading = t('.comments') + table.table.table-striped + tbody + = render partial: '/management/shared/feedback', collection: @conference.event_feedbacks_with_comment.order(created_at: :asc) + .col-md-2 + .panel.panel-info + .panel-heading + = t '.average_grade' + .panel-body.text-right + .huge + = number_with_precision(@conference.event_feedbacks.average(:rating), precision: 2, strip_insignificant_zeros: true) || '–' + = t('.total_feedback_grades', total_grades: @conference.event_feedbacks.count, count: @conference.event_feedbacks.count) + - else + p = t '.no_comments_received' diff --git a/app/views/management/shared/_feedback.html.slim b/app/views/management/shared/_feedback.html.slim index 3ee7ed6..b7b9714 100644 --- a/app/views/management/shared/_feedback.html.slim +++ b/app/views/management/shared/_feedback.html.slim @@ -11,6 +11,6 @@ tr = feedback.author_email - else = t(".anonymous") - - if !local_assigns[:show_title] + - if !local_assigns[:hide_title] span<> = t '.about' - = link_to feedback.feedback_receiving.title, [:management, feedback.feedback_receiving.conference, feedback.feedback_receiving] + = link_to feedback.feedback_receiving.title, [:management, current_conference, feedback.feedback_receiving] diff --git a/config/locales/management.bg.yml b/config/locales/management.bg.yml index 62506e9..584b7a7 100644 --- a/config/locales/management.bg.yml +++ b/config/locales/management.bg.yml @@ -11,6 +11,18 @@ bg: events: metadata: "%{type} на %{language} с продължителност %{length} минути" management: + feedback: + index: + feedback: Обратна връзка + overall_organisation: За конференцията + comments: Коментари + average_grade: Средна оценка + total_feedback_grades: + one: от %{total_grades} оценка + other: от %{total_grades} оценки + no_feedback_received: Все още няма обратна връзка + no_comments_received: Все още няма коментари + events: За събитията shared: feedback: anonymous: Анонимен diff --git a/config/routes.rb b/config/routes.rb index a414264..95b0f16 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -51,6 +51,8 @@ Rails.application.routes.draw do resources :sponsorship_offers resource :call_for_participation, only: [:create, :destroy] + resources :feedback, controller: :feedback, only: :index + resources :personal_profiles do member do put :toggle_admin