From 9ce4ba6f6b6de575db681ba4c0779eea91481ff6 Mon Sep 17 00:00:00 2001 From: Shyukri Shyukriev Date: Thu, 30 Jun 2016 12:09:21 +0200 Subject: [PATCH] Added target for surveys. --- app/models/conference.rb | 2 +- app/models/survey.rb | 3 +-- app/views/admin/surveys/_form.html.haml | 1 + app/views/admin/surveys/index.html.haml | 3 +++ .../_registration_info.html.haml | 2 -- .../conference_registrations/show.html.haml | 16 ++++++---------- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/app/models/conference.rb b/app/models/conference.rb index 15352867..4d5b2085 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -36,7 +36,7 @@ class Conference < ActiveRecord::Base has_many :subscriptions, dependent: :destroy has_many :surveys, as: :surveyable, dependent: :destroy do def for_registration - where(target: targets[:registration]) + where(target: targets[:during_registration]) end end diff --git a/app/models/survey.rb b/app/models/survey.rb index d08df5dc..ac3e04a4 100644 --- a/app/models/survey.rb +++ b/app/models/survey.rb @@ -2,7 +2,6 @@ class Survey < ActiveRecord::Base belongs_to :surveyable, polymorphic: true has_many :survey_questions - enum target: [:conference, :registration] - + enum target: [:after_conference, :during_registration] validates :title, presence: true end diff --git a/app/views/admin/surveys/_form.html.haml b/app/views/admin/surveys/_form.html.haml index 11d1be9f..061ce52f 100644 --- a/app/views/admin/surveys/_form.html.haml +++ b/app/views/admin/surveys/_form.html.haml @@ -9,6 +9,7 @@ = f.hidden_field :surveyable_id = f.input :title = f.input :description, input_html: { rows: 3 } + = f.input :target, as: :select, collection: Survey.targets.keys, label: "When to ask" = f.input :start_date, as: :string, input_html: { class: 'datetimepicker' } = f.input :end_date, as: :string, input_html: { class: 'datetimepicker' } = f.submit 'Save', class: 'btn btn-primary' diff --git a/app/views/admin/surveys/index.html.haml b/app/views/admin/surveys/index.html.haml index 17320355..f1a777f5 100644 --- a/app/views/admin/surveys/index.html.haml +++ b/app/views/admin/surveys/index.html.haml @@ -14,6 +14,7 @@ %table.table.table-hover#surveys %thead %th Title + %th When %th Start Date %th End Date %th Actions @@ -22,6 +23,8 @@ %tr %td = link_to survey.title, admin_conference_survey_path(@conference.short_title, survey) + %td + = survey.target %td = survey.start_date %td diff --git a/app/views/conference_registrations/_registration_info.html.haml b/app/views/conference_registrations/_registration_info.html.haml index c1015d08..ae8bcbd0 100644 --- a/app/views/conference_registrations/_registration_info.html.haml +++ b/app/views/conference_registrations/_registration_info.html.haml @@ -1,5 +1,3 @@ -- if @conference.surveys.for_registration.any? - Something - if @conference.program.events.with_registration_open.any? || @registration.events.any? = f.inputs 'Pre-registration required for the following:' do diff --git a/app/views/conference_registrations/show.html.haml b/app/views/conference_registrations/show.html.haml index dd73e70b..add392ad 100644 --- a/app/views/conference_registrations/show.html.haml +++ b/app/views/conference_registrations/show.html.haml @@ -36,24 +36,20 @@ = @registration.departure.strftime('%A, %B %-d. %Y %H:%M') - else You haven't scheduled your departure - - if @conference.questions.any? + - if @conference.surveys.for_registration.any? .row .col-md-12 %h4 %span.fa-stack %i.fa.fa-square-o.fa-stack-2x %i.fa.fa-info.fa-stack-1x - Additional Info + Surveys + %ul - - @conference.questions.each do |q| + - @conference.surveys.for_registration.each do |survey| %li - %strong - = q.title - - if @registration.qanswers.any? - - @registration.qanswers.where(:question_id => q.id).each do |qa| - = qa.answer.title - - else - You haven't answered + = link_to survey.title, "#" + - if @registration.events.any? .row .col-md-12