Added target for surveys.

This commit is contained in:
Shyukri Shyukriev 2016-06-30 12:09:21 +02:00
parent 157a16d8f2
commit 9ce4ba6f6b
6 changed files with 12 additions and 15 deletions

View file

@ -36,7 +36,7 @@ class Conference < ActiveRecord::Base
has_many :subscriptions, dependent: :destroy has_many :subscriptions, dependent: :destroy
has_many :surveys, as: :surveyable, dependent: :destroy do has_many :surveys, as: :surveyable, dependent: :destroy do
def for_registration def for_registration
where(target: targets[:registration]) where(target: targets[:during_registration])
end end
end end

View file

@ -2,7 +2,6 @@ class Survey < ActiveRecord::Base
belongs_to :surveyable, polymorphic: true belongs_to :surveyable, polymorphic: true
has_many :survey_questions has_many :survey_questions
enum target: [:conference, :registration] enum target: [:after_conference, :during_registration]
validates :title, presence: true validates :title, presence: true
end end

View file

@ -9,6 +9,7 @@
= f.hidden_field :surveyable_id = f.hidden_field :surveyable_id
= f.input :title = f.input :title
= f.input :description, input_html: { rows: 3 } = 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 :start_date, as: :string, input_html: { class: 'datetimepicker' }
= f.input :end_date, as: :string, input_html: { class: 'datetimepicker' } = f.input :end_date, as: :string, input_html: { class: 'datetimepicker' }
= f.submit 'Save', class: 'btn btn-primary' = f.submit 'Save', class: 'btn btn-primary'

View file

@ -14,6 +14,7 @@
%table.table.table-hover#surveys %table.table.table-hover#surveys
%thead %thead
%th Title %th Title
%th When
%th Start Date %th Start Date
%th End Date %th End Date
%th Actions %th Actions
@ -22,6 +23,8 @@
%tr %tr
%td %td
= link_to survey.title, admin_conference_survey_path(@conference.short_title, survey) = link_to survey.title, admin_conference_survey_path(@conference.short_title, survey)
%td
= survey.target
%td %td
= survey.start_date = survey.start_date
%td %td

View file

@ -1,5 +1,3 @@
- if @conference.surveys.for_registration.any?
Something
- if @conference.program.events.with_registration_open.any? || @registration.events.any? - if @conference.program.events.with_registration_open.any? || @registration.events.any?
= f.inputs 'Pre-registration required for the following:' do = f.inputs 'Pre-registration required for the following:' do

View file

@ -36,24 +36,20 @@
= @registration.departure.strftime('%A, %B %-d. %Y %H:%M') = @registration.departure.strftime('%A, %B %-d. %Y %H:%M')
- else - else
You haven't scheduled your departure You haven't scheduled your departure
- if @conference.questions.any? - if @conference.surveys.for_registration.any?
.row .row
.col-md-12 .col-md-12
%h4 %h4
%span.fa-stack %span.fa-stack
%i.fa.fa-square-o.fa-stack-2x %i.fa.fa-square-o.fa-stack-2x
%i.fa.fa-info.fa-stack-1x %i.fa.fa-info.fa-stack-1x
Additional Info Surveys
%ul %ul
- @conference.questions.each do |q| - @conference.surveys.for_registration.each do |survey|
%li %li
%strong = link_to survey.title, "#"
= q.title
- if @registration.qanswers.any?
- @registration.qanswers.where(:question_id => q.id).each do |qa|
= qa.answer.title
- else
You haven't answered
- if @registration.events.any? - if @registration.events.any?
.row .row
.col-md-12 .col-md-12