Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(questionnaires): Allows directors to block new questionnaires #279

Merged
merged 9 commits into from
Sep 19, 2020
1 change: 1 addition & 0 deletions app/controllers/questionnaires_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/views/manage/configs/edit.html.haml
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
28 changes: 22 additions & 6 deletions app/views/questionnaires/new.html.haml
Original file line number Diff line number Diff line change
@@ -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'
1 change: 1 addition & 0 deletions config/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ defaults: &defaults
disclaimer_message: ""
thanks_for_applying_message: ""
thanks_for_rsvp_message: ""
questionnaires_closed_message: ""
bus_captain_notes: ""
custom_css: ""

Expand Down
4 changes: 3 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>not</strong> 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
Expand All @@ -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 &lt;head&gt; of every public page
placeholders:
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions test/controllers/questionnaires_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down