diff --git a/app/controllers/questionnaires_controller.rb b/app/controllers/questionnaires_controller.rb index 633547842..190acbac9 100644 --- a/app/controllers/questionnaires_controller.rb +++ b/app/controllers/questionnaires_controller.rb @@ -58,6 +58,7 @@ def create if current_user.reload.questionnaire.present? return redirect_to questionnaires_path, notice: 'Application already exists.' end + 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/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..6d389312f 100644 --- a/app/views/questionnaires/new.html.haml +++ b/app/views/questionnaires/new.html.haml @@ -1,7 +1,23 @@ -- 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 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} -= 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 5e62ea3fa..8e6b7835f 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: dashboard: diff --git a/test/controllers/questionnaires_controller_test.rb b/test/controllers/questionnaires_controller_test.rb index faf0279a0..53260735c 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, 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