Skip to content

Commit

Permalink
Add surveys to proposal todo list
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKvalheim committed Mar 15, 2023
1 parent f8d6283 commit 1260786
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions .haml-lint_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,11 @@ def speaker_emails
#
# 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?,
Expand Down
4 changes: 4 additions & 0 deletions app/models/survey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ def active?
def closed?
!active?
end

def replied?(user_id)
survey_submissions.where(user_id: user_id).any?
end
end
5 changes: 5 additions & 0 deletions app/views/admin/events/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/views/proposals/_tooltip.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion app/views/proposals/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
2 changes: 1 addition & 1 deletion app/views/surveys/_list.html.haml
Original file line number Diff line number Diff line change
@@ -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' }
Expand Down
6 changes: 6 additions & 0 deletions spec/features/surveys_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
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
Expand All @@ -75,6 +78,9 @@
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
Expand Down

0 comments on commit 1260786

Please sign in to comment.