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 :surveys, as: :surveyable, dependent: :destroy do
def for_registration
where(target: targets[:registration])
where(target: targets[:during_registration])
end
end

View file

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

View file

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

View file

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

View file

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

View file

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