diff --git a/.haml-lint_todo.yml b/.haml-lint_todo.yml index 8d6474cd..decbeb3c 100644 --- a/.haml-lint_todo.yml +++ b/.haml-lint_todo.yml @@ -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" diff --git a/app/models/event.rb b/app/models/event.rb index dc7202c2..cf2914b4 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -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?, diff --git a/app/models/survey.rb b/app/models/survey.rb index ccc5f423..66c10667 100644 --- a/app/models/survey.rb +++ b/app/models/survey.rb @@ -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 diff --git a/app/views/admin/events/show.html.haml b/app/views/admin/events/show.html.haml index 4b764838..0831f49f 100644 --- a/app/views/admin/events/show.html.haml +++ b/app/views/admin/events/show.html.haml @@ -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 diff --git a/app/views/proposals/_tooltip.html.haml b/app/views/proposals/_tooltip.html.haml index b10b5a7a..d91cf923 100644 --- a/app/views/proposals/_tooltip.html.haml +++ b/app/views/proposals/_tooltip.html.haml @@ -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'] diff --git a/app/views/proposals/index.html.haml b/app/views/proposals/index.html.haml index 961c5368..ace97ad0 100644 --- a/app/views/proposals/index.html.haml +++ b/app/views/proposals/index.html.haml @@ -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 } diff --git a/app/views/surveys/_list.html.haml b/app/views/surveys/_list.html.haml index 200fe7e9..aa785037 100644 --- a/app/views/surveys/_list.html.haml +++ b/app/views/surveys/_list.html.haml @@ -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' } diff --git a/spec/features/surveys_spec.rb b/spec/features/surveys_spec.rb index 98fcc493..eefb1758 100644 --- a/spec/features/surveys_spec.rb +++ b/spec/features/surveys_spec.rb @@ -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