From 4ece3443bb4fe4925d82ef35288c8252fd3b40f2 Mon Sep 17 00:00:00 2001 From: "Chris Baudouin, Jr" Date: Sat, 4 Jul 2020 12:44:59 -0400 Subject: [PATCH 1/4] feat(questionnaires): Allows directors to block new questionnaires --- app/controllers/questionnaires_controller.rb | 1 + app/views/manage/configs/edit.html.haml | 2 +- app/views/questionnaires/new.html.haml | 29 +++++++++++++++---- config/app.yml | 1 + config/locales/en.yml | 4 ++- .../questionnaires_controller_test.rb | 9 ++++++ 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/app/controllers/questionnaires_controller.rb b/app/controllers/questionnaires_controller.rb index b1e592452..092289470 100644 --- a/app/controllers/questionnaires_controller.rb +++ b/app/controllers/questionnaires_controller.rb @@ -62,6 +62,7 @@ def create if current_user.reload.questionnaire.present? return redirect_to questionnaires_path, notice: 'Application already exists.' end + return if not HackathonConfig['accepting_questionnaires'] @questionnaire = Questionnaire.new(convert_school_name_to_id(questionnaire_params)) @questionnaire.user_id = current_user.id diff --git a/app/views/manage/configs/edit.html.haml b/app/views/manage/configs/edit.html.haml index 45919bdcf..3a2dda9e7 100644 --- a/app/views/manage/configs/edit.html.haml +++ b/app/views/manage/configs/edit.html.haml @@ -1,6 +1,6 @@ :ruby text_field_vars = %w() - markdown_field_vars = %w(bus_captain_notes thanks_for_rsvp_message thanks_for_applying_message disclaimer_message) + markdown_field_vars = %w(bus_captain_notes thanks_for_rsvp_message thanks_for_applying_message questionnaires_closed_message disclaimer_message) css_field_vars = %w(custom_css) form_field_vars = %w(disabled_fields) diff --git a/app/views/questionnaires/new.html.haml b/app/views/questionnaires/new.html.haml index 45cd8202d..6bae436c0 100644 --- a/app/views/questionnaires/new.html.haml +++ b/app/views/questionnaires/new.html.haml @@ -1,7 +1,24 @@ -- title "Apply" -.form-container - %h1.section-title - Apply for - %span.emphasized= HackathonConfig['name'] +- title "Application" +- if HackathonConfig['accepting_questionnaires'] + .form-container + %h1.section-title + Apply for + %span.emphasized= HackathonConfig['name'] + = render 'form' +- else + .form-container + #disclaimer + %h1.section-title + Applications Closed + %p + - if HackathonConfig['questionnaires_closed_message'].present? + = markdown(HackathonConfig['questionnaires_closed_message']) + - else + Sorry, we are no longer accepting new applications to + %strong + #{HackathonConfig['name']}. + %br + %p.session-link.right + Don't need account? #{link_to "Delete my account", user_registration_path, data: { confirm: "Are you sure? Your account and any related data will be permanently erased." }, method: :delete} + -= render 'form' diff --git a/config/app.yml b/config/app.yml index 69c47d4fe..23057decb 100644 --- a/config/app.yml +++ b/config/app.yml @@ -21,6 +21,7 @@ defaults: &defaults disclaimer_message: "" thanks_for_applying_message: "" thanks_for_rsvp_message: "" + questionnaires_closed_message: "" bus_captain_notes: "" custom_css: "" diff --git a/config/locales/en.yml b/config/locales/en.yml index 060806f62..f12837f46 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -55,7 +55,7 @@ en: school: is_home: The "home" school is separated from all other schools on dashboard metrics. hackathon_config: - accepting_questionnaires: Specify that questionnaires are being accepted. This does not block applying; it only changes messaging around it. + accepting_questionnaires: Specify and allow questionnaires to be accepted. last_day_to_apply: 'Last date to apply to your hackathon (format: YYYY-MM-DD)' event_start_date: 'Start date of your hackathon (format: YYYY-MM-DD)' auto_late_waitlist: Automatically set application status to "late waitlist" for new applications @@ -72,6 +72,7 @@ en: disclaimer_message: Optional message that appears before signing up & applying. Supports markdown. thanks_for_applying_message: Optional message that appears after completing an application. Supports markdown. thanks_for_rsvp_message: Optional message that appears after RSVP'ing as attending. Supports markdown. + questionnaires_closed_message: Message that replaces the new questionnaire form. Supports markdown. bus_captain_notes: Optional message that appears on the bus captain's bus list page. Supports markdown. custom_css: CSS to inject into the <head> of every public page placeholders: @@ -117,6 +118,7 @@ en: custom_css: Custom CSS homepage_url: Homepage URL thanks_for_rsvp_message: Thanks For RSVP Message + questionnaires_closed_message: Questionnaires Closed Message pages: manage: users: diff --git a/test/controllers/questionnaires_controller_test.rb b/test/controllers/questionnaires_controller_test.rb index 0ad2c8276..864cba0b0 100644 --- a/test/controllers/questionnaires_controller_test.rb +++ b/test/controllers/questionnaires_controller_test.rb @@ -76,6 +76,15 @@ class QuestionnairesControllerTest < ActionController::TestCase end end + context "with block questionnaires set" do + should "not allow creation" do + HackathonConfig['accepting_questionnaires'] = false + assert_difference('Questionnaire.count', 0) do + post :create, params: { questionnaire: { experience: @questionnaire.experience, interest: @questionnaire.interest, first_name: @questionnaire.first_name, last_name: @questionnaire.last_name, phone: @questionnaire.phone, level_of_study: @questionnaire.level_of_study, date_of_birth: @questionnaire.date_of_birth, shirt_size: @questionnaire.shirt_size, school_id: @school.id, agreement_accepted: "1", code_of_conduct_accepted: "1", data_sharing_accepted: "1", major: @questionnaire.major, gender: @questionnaire.gender, why_attend: @questionnaire.why_attend, graduation_year: @questionnaire.graduation_year, race_ethnicity: @questionnaire.race_ethnicity } } + end + end + end + context "#school_name" do context "on create" do should "save existing school name" do From e0f0d4b4f0af246589c44d187c2ccf8e6dfa6b59 Mon Sep 17 00:00:00 2001 From: "Chris Baudouin, Jr" Date: Sat, 4 Jul 2020 12:50:07 -0400 Subject: [PATCH 2/4] Fixes Hound issues --- app/controllers/questionnaires_controller.rb | 2 +- app/views/questionnaires/new.html.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/questionnaires_controller.rb b/app/controllers/questionnaires_controller.rb index 092289470..9d8511e8c 100644 --- a/app/controllers/questionnaires_controller.rb +++ b/app/controllers/questionnaires_controller.rb @@ -62,7 +62,7 @@ def create if current_user.reload.questionnaire.present? return redirect_to questionnaires_path, notice: 'Application already exists.' end - return if not HackathonConfig['accepting_questionnaires'] + return unless HackathonConfig['accepting_questionnaires'] @questionnaire = Questionnaire.new(convert_school_name_to_id(questionnaire_params)) @questionnaire.user_id = current_user.id diff --git a/app/views/questionnaires/new.html.haml b/app/views/questionnaires/new.html.haml index 6bae436c0..b41782197 100644 --- a/app/views/questionnaires/new.html.haml +++ b/app/views/questionnaires/new.html.haml @@ -14,8 +14,8 @@ - if HackathonConfig['questionnaires_closed_message'].present? = markdown(HackathonConfig['questionnaires_closed_message']) - else - Sorry, we are no longer accepting new applications to - %strong + Sorry, we are no longer accepting new applications to + %strong #{HackathonConfig['name']}. %br %p.session-link.right From 053ae06afd27fd30b714aebd8032922aa5627577 Mon Sep 17 00:00:00 2001 From: "Chris Baudouin, Jr" Date: Sun, 13 Sep 2020 23:38:33 -0400 Subject: [PATCH 3/4] Updates app/views/questionnaires/new.html.haml Co-authored-by: Peter Kos --- app/views/questionnaires/new.html.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/questionnaires/new.html.haml b/app/views/questionnaires/new.html.haml index b41782197..6d389312f 100644 --- a/app/views/questionnaires/new.html.haml +++ b/app/views/questionnaires/new.html.haml @@ -19,6 +19,5 @@ #{HackathonConfig['name']}. %br %p.session-link.right - Don't need account? #{link_to "Delete my account", user_registration_path, data: { confirm: "Are you sure? Your account and any related data will be permanently erased." }, method: :delete} - + Don't need your account? #{link_to "Delete my account", user_registration_path, data: { confirm: "Are you sure? Your account and any related data will be permanently erased." }, method: :delete} From 50cf10c4353abbdab332188f4426cdc1eaf3f4b2 Mon Sep 17 00:00:00 2001 From: "Chris Baudouin, Jr" Date: Mon, 14 Sep 2020 16:30:51 -0400 Subject: [PATCH 4/4] fix: Compatibility fix with hm-222 --- test/controllers/questionnaires_controller_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/controllers/questionnaires_controller_test.rb b/test/controllers/questionnaires_controller_test.rb index 4d2371a37..53260735c 100644 --- a/test/controllers/questionnaires_controller_test.rb +++ b/test/controllers/questionnaires_controller_test.rb @@ -80,7 +80,7 @@ class QuestionnairesControllerTest < ActionController::TestCase should "not allow creation" do HackathonConfig['accepting_questionnaires'] = false assert_difference('Questionnaire.count', 0) do - post :create, params: { questionnaire: { experience: @questionnaire.experience, interest: @questionnaire.interest, first_name: @questionnaire.first_name, last_name: @questionnaire.last_name, phone: @questionnaire.phone, level_of_study: @questionnaire.level_of_study, date_of_birth: @questionnaire.date_of_birth, shirt_size: @questionnaire.shirt_size, school_id: @school.id, agreement_accepted: "1", code_of_conduct_accepted: "1", data_sharing_accepted: "1", major: @questionnaire.major, gender: @questionnaire.gender, why_attend: @questionnaire.why_attend, graduation_year: @questionnaire.graduation_year, race_ethnicity: @questionnaire.race_ethnicity } } + post :create, params: { questionnaire: { experience: @questionnaire.experience, interest: @questionnaire.interest, phone: @questionnaire.phone, level_of_study: @questionnaire.level_of_study, date_of_birth: @questionnaire.date_of_birth, shirt_size: @questionnaire.shirt_size, school_id: @school.id, agreement_accepted: "1", code_of_conduct_accepted: "1", data_sharing_accepted: "1", major: @questionnaire.major, gender: @questionnaire.gender, why_attend: @questionnaire.why_attend, graduation_year: @questionnaire.graduation_year, race_ethnicity: @questionnaire.race_ethnicity } } end end end