Add surveys to proposal todo list

This commit is contained in:
Andrew Kvalheim 2023-03-14 17:00:53 -07:00
parent f8d6283f44
commit 1260786a62
8 changed files with 25 additions and 2 deletions

View file

@ -38,6 +38,7 @@ linters:
- "app/views/admin/emails/index.html.haml"
- "app/views/admin/events/_proposal.html.haml"
- "app/views/admin/events/index.html.haml"
- "app/views/admin/events/show.html.haml"
- "app/views/admin/tracks/index.html.haml"
- "app/views/admin/tracks/show.html.haml"
- "app/views/admin/versions/_object_desc_and_link.html.haml"

View file

@ -228,8 +228,11 @@ class Event < ApplicationRecord
#
# Returns +Hash+
def progress_status
surveys = conference.surveys.during_proposal.select(&:active?)
{
registered: speakers.all? { |speaker| program.conference.user_registered? speaker },
surveys: (surveys.all? { |survey| survey.replied?(submitter) } if surveys.present?),
commercials: commercials.any?,
biographies: speakers.all? { |speaker| !speaker.biography.blank? },
subtitle: !subtitle.blank?,

View file

@ -36,4 +36,8 @@ class Survey < ActiveRecord::Base
def closed?
!active?
end
def replied?(user_id)
survey_submissions.where(user_id: user_id).any?
end
end

View file

@ -67,6 +67,11 @@
%td= link_to "#{'Speaker'.pluralize(@event.speakers.count)} must be registered to the conference", admin_conference_registrations_path(@event.program.conference.short_title)
%td{ 'class' => class_for_todo(progress_status['registered']) }
%span{ 'class' => [icon_for_todo(progress_status['registered']), 'fa-lg'] }
- unless progress_status['surveys'].nil?
%tr
%td= link_to 'Respond to surveys', admin_conference_surveys_path(@event.program.conference.short_title)
%td{ 'class' => class_for_todo(progress_status['surveys']) }
%span{ 'class' => [icon_for_todo(progress_status['surveys']), 'fa-lg'] }
%tr
%td
- speakers_count = @event.speakers.count

View file

@ -7,6 +7,10 @@
Speaker(s) registered to the conference
- else
= link_to 'Speaker(s) not registered to the conference', new_conference_conference_registration_path(event.program.conference.short_title)
- unless progress_status['surveys'].nil?
%li{'class'=>class_for_todo(progress_status['surveys'])}
%span{'class'=>icon_for_todo(progress_status['surveys'])}
= link_to 'Respond to surveys', '#surveys'
%li{'class'=>class_for_todo(progress_status['biographies'])}
%span{'class'=>icon_for_todo(progress_status['biographies'])}
- if progress_status['biographies']

View file

@ -121,6 +121,6 @@
- if @surveys.any?
.row
.col-md-12
%h2 Surveys
%h2#surveys Surveys
= render partial: 'surveys/list', locals: { surveys: @surveys, conference: @conference }

View file

@ -1,5 +1,5 @@
- surveys.each do |survey|
- if survey.survey_submissions.find_by(user: current_user)
- if survey.replied?(current_user)
%i.fa-solid.fa-square-check.text-success{ title: 'Thank you for filling out the survey' }
- else
%i.fa-solid.fa-square-minus.text-danger{ title: 'Please fill out the survey' }

View file

@ -67,6 +67,9 @@ feature Survey do
create :boolean_mandatory, survey: survey
visit conference_program_proposals_path(conference.short_title)
within('.progress') { expect(page).to have_text '4 left' }
click_on 'Complete your proposal'
within('.popover') { expect(find(:link, 'Respond to surveys')).to have_sibling('.fa-xmark') }
expect(find(:link, survey.title).sibling('.fa-solid')[:title]).to eq('Please fill out the survey')
click_link survey.title
@ -75,6 +78,9 @@ feature Survey do
expect(flash).to eq('Successfully responded to survey.')
visit conference_program_proposals_path(conference.short_title)
within('.progress') { expect(page).to have_text '3 left' }
click_on 'Complete your proposal'
within('.popover') { expect(find(:link, 'Respond to surveys')).to have_sibling('.fa-check') }
expect(find(:link, survey.title).sibling('.fa-solid')[:title]).to eq('Thank you for filling out the survey')
end
end