Skip to content

Commit 5e03082

Browse files
feat(questionnaires): Allows directors to block new questionnaires (#279)
* feat(questionnaires): Allows directors to block new questionnaires * Fixes Hound issues * Updates app/views/questionnaires/new.html.haml Co-authored-by: Peter Kos <pkos91@icloud.com> * fix: Compatibility fix with hm-222 Co-authored-by: Peter Kos <pkos91@icloud.com>
1 parent 54d2cea commit 5e03082

File tree

6 files changed

+37
-8
lines changed

6 files changed

+37
-8
lines changed

app/controllers/questionnaires_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def create
5858
if current_user.reload.questionnaire.present?
5959
return redirect_to questionnaires_path, notice: 'Application already exists.'
6060
end
61+
return unless HackathonConfig['accepting_questionnaires']
6162
@questionnaire = Questionnaire.new(convert_school_name_to_id(questionnaire_params))
6263
@questionnaire.user_id = current_user.id
6364

app/views/manage/configs/edit.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
:ruby
22
text_field_vars = %w()
3-
markdown_field_vars = %w(bus_captain_notes thanks_for_rsvp_message thanks_for_applying_message disclaimer_message)
3+
markdown_field_vars = %w(bus_captain_notes thanks_for_rsvp_message thanks_for_applying_message questionnaires_closed_message disclaimer_message)
44
css_field_vars = %w(custom_css)
55
form_field_vars = %w(disabled_fields)
66

app/views/questionnaires/new.html.haml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1-
- title "Apply"
2-
.form-container
3-
%h1.section-title
4-
Apply for
5-
%span.emphasized= HackathonConfig['name']
1+
- title "Application"
2+
- if HackathonConfig['accepting_questionnaires']
3+
.form-container
4+
%h1.section-title
5+
Apply for
6+
%span.emphasized= HackathonConfig['name']
7+
= render 'form'
8+
- else
9+
.form-container
10+
#disclaimer
11+
%h1.section-title
12+
Applications Closed
13+
%p
14+
- if HackathonConfig['questionnaires_closed_message'].present?
15+
= markdown(HackathonConfig['questionnaires_closed_message'])
16+
- else
17+
Sorry, we are no longer accepting new applications to
18+
%strong
19+
#{HackathonConfig['name']}.
20+
%br
21+
%p.session-link.right
22+
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}
623

7-
= render 'form'

config/app.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ defaults: &defaults
2121
disclaimer_message: ""
2222
thanks_for_applying_message: ""
2323
thanks_for_rsvp_message: ""
24+
questionnaires_closed_message: ""
2425
bus_captain_notes: ""
2526
custom_css: ""
2627

config/locales/en.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ en:
5555
school:
5656
is_home: The "home" school is separated from all other schools on dashboard metrics.
5757
hackathon_config:
58-
accepting_questionnaires: Specify that questionnaires are being accepted. This does <strong>not</strong> block applying; it only changes messaging around it.
58+
accepting_questionnaires: Specify and allow questionnaires to be accepted.
5959
last_day_to_apply: 'Last date to apply to your hackathon (format: YYYY-MM-DD)'
6060
event_start_date: 'Start date of your hackathon (format: YYYY-MM-DD)'
6161
auto_late_waitlist: Automatically set application status to "late waitlist" for new applications
@@ -72,6 +72,7 @@ en:
7272
disclaimer_message: Optional message that appears before signing up & applying. Supports markdown.
7373
thanks_for_applying_message: Optional message that appears after completing an application. Supports markdown.
7474
thanks_for_rsvp_message: Optional message that appears after RSVP'ing as attending. Supports markdown.
75+
questionnaires_closed_message: Message that replaces the new questionnaire form. Supports markdown.
7576
bus_captain_notes: Optional message that appears on the bus captain's bus list page. Supports markdown.
7677
custom_css: CSS to inject into the &lt;head&gt; of every public page
7778
placeholders:
@@ -117,6 +118,7 @@ en:
117118
custom_css: Custom CSS
118119
homepage_url: Homepage URL
119120
thanks_for_rsvp_message: Thanks For RSVP Message
121+
questionnaires_closed_message: Questionnaires Closed Message
120122
pages:
121123
manage:
122124
dashboard:

test/controllers/questionnaires_controller_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ class QuestionnairesControllerTest < ActionController::TestCase
7676
end
7777
end
7878

79+
context "with block questionnaires set" do
80+
should "not allow creation" do
81+
HackathonConfig['accepting_questionnaires'] = false
82+
assert_difference('Questionnaire.count', 0) do
83+
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 } }
84+
end
85+
end
86+
end
87+
7988
context "#school_name" do
8089
context "on create" do
8190
should "save existing school name" do

0 commit comments

Comments
 (0)