Skip to content

Commit 457781d

Browse files
authored
feat: Add ability to close registration completely (#176)
* feat: Support SMTP as an alternative email provider to Sparkpost (#172) test: Fix _asset config test maint: Code reformat * fix: when registration is over it should redirect to the root path * use alert instead of failure or error because looking at the docs they only have alert and notice to be used * Update app/controllers/users/registrations_controller.rb Co-Authored-By: Stuart Olivera <[email protected]> * check only during the create or new registration * Update app/controllers/manage/questionnaires_controller.rb Co-Authored-By: Stuart Olivera <[email protected]> * end to close def block * Update app/controllers/manage/questionnaires_controller.rb Co-Authored-By: Stuart Olivera <[email protected]> * test: add new tests for registration and questionnaire * test: remove response method * test: resolve for registration controller * test: remove trailing white space * test: update test * test: get the :new * fix: move the test for questionnaires to be moved to config since that is where it should be housed. Remove the check for response due to root redirecting to sign in page. * fix: remove failing test, it touches both config and questionnaire * fix: remove failing test
1 parent ccc6514 commit 457781d

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

app/controllers/manage/questionnaires_controller.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
class Manage::QuestionnairesController < Manage::ApplicationController
22
include QuestionnairesControllable
33

4+
before_action :ensure_registration_is_open, only: [:new, :create]
45
before_action :set_questionnaire, only: [:show, :edit, :update, :destroy, :check_in, :convert_to_admin, :update_acc_status, :message_events]
56

67
respond_to :html, :json
@@ -169,4 +170,11 @@ def convert_boarded_bus_param(values, questionnaire = nil)
169170
def set_questionnaire
170171
@questionnaire = ::Questionnaire.find(params[:id])
171172
end
173+
174+
def ensure_registration_is_open
175+
if HackathonConfig['disable_account_registration']
176+
flash[:alert] = "Registration has closed"
177+
redirect_to root_path
178+
end
179+
end
172180
end

app/controllers/users/registrations_controller.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ class Users::RegistrationsController < Devise::RegistrationsController
33
# before_action :configure_account_update_params, only: [:update]
44

55
# GET /resource/sign_up
6-
# def new
7-
# super
8-
# end
6+
def new
7+
if HackathonConfig['disable_account_registration']
8+
flash[:alert] = "Registration has closed"
9+
redirect_to root_path
10+
else
11+
super
12+
end
13+
end
914

1015
# POST /resource
1116
# def create

config/app.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ defaults: &defaults
77
last_day_to_apply: "<%= Date.new(2000, 1, 1).to_s %>"
88
event_start_date: "<%= Date.new(2000, 1, 1).to_s %>"
99
auto_late_waitlist: false
10+
disable_account_registration: false
1011

1112
# Content config
1213
name: HackFoo

config/locales/en.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
# available at http://guides.rubyonrails.org/i18n.html.
3131

3232
en:
33-
devise:
3433
devise:
3534
failure:
3635
unauthenticated: "Please sign in or sign up to continue."
@@ -61,6 +60,7 @@ en:
6160
last_day_to_apply: 'Last date to apply to your hackathon (format: YYYY-MM-DD)'
6261
event_start_date: 'Start date of your hackathon (format: YYYY-MM-DD)'
6362
auto_late_waitlist: Automatically set application status to "late waitlist" for new applications
63+
disable_account_registration: Prevent applicants from applying
6464

6565
name: Your hackathon's name
6666
logo_asset: Optional logo asset (should be a full https:// URL to a .jpg, .png, or .svg file)

0 commit comments

Comments
 (0)