diff --git a/CHANGELOG.md b/CHANGELOG.md
index 87c9420ce..f9e7a4339 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,20 @@
+# [1.19.0](https://github.com/codeRIT/hackathon-manager/compare/v1.18.0...v1.19.0) (2019-10-05)
+
+
+### Features
+
+* Add ability to close registration completely ([#176](https://github.com/codeRIT/hackathon-manager/issues/176)) ([457781d](https://github.com/codeRIT/hackathon-manager/commit/457781d)), closes [#172](https://github.com/codeRIT/hackathon-manager/issues/172)
+
+
+### Maintenance
+
+* Code reformat ([123eafc](https://github.com/codeRIT/hackathon-manager/commit/123eafc))
+
+
+### Tests
+
+* Fix _asset config test ([63f49ec](https://github.com/codeRIT/hackathon-manager/commit/63f49ec))
+
# [1.18.0](https://github.com/codeRIT/hackathon-manager/compare/v1.17.2...v1.18.0) (2019-08-18)
diff --git a/Gemfile b/Gemfile
index 30f818c2a..61ef50cfb 100644
--- a/Gemfile
+++ b/Gemfile
@@ -38,7 +38,7 @@ gem 'redis', '~> 4.0'
gem 'bootsnap', '>= 1.1.0', require: false
# Authentication
-gem 'devise', '~> 4.2'
+gem 'devise', '~> 4.7'
gem 'omniauth-mlh', '~> 0.1'
gem 'doorkeeper', '~> 5.0'
gem 'devise-doorkeeper'
diff --git a/Gemfile.lock b/Gemfile.lock
index 8191e3b30..50c984a24 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -116,10 +116,10 @@ GEM
css_parser (1.7.0)
addressable
debug_inspector (0.0.3)
- devise (4.6.2)
+ devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
- railties (>= 4.1.0, < 6.0)
+ railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise-doorkeeper (1.1.2)
@@ -465,7 +465,7 @@ DEPENDENCIES
chartkick (~> 3.0)
chromedriver-helper
codeclimate-test-reporter (~> 0.6.0)
- devise (~> 4.2)
+ devise (~> 4.7)
devise-doorkeeper
doorkeeper (~> 5.0)
dotenv-rails
diff --git a/app/assets/javascripts/manage/lib/setupDataTables.js b/app/assets/javascripts/manage/lib/setupDataTables.js
index ec5c53297..586c63577 100644
--- a/app/assets/javascripts/manage/lib/setupDataTables.js
+++ b/app/assets/javascripts/manage/lib/setupDataTables.js
@@ -4,7 +4,7 @@
* See app/views/manage/application/_questionnaire_datatable.html.haml for an example.
*/
-var setupDataTables = function() {
+var setupDataTables = function () {
$('.datatable.checkins').DataTable({
order: [1, 'asc'],
columns: [
@@ -25,6 +25,11 @@ var setupDataTables = function() {
{ orderable: true, data: 'active' },
{ orderable: true, data: 'receive_weekly_report' },
{ orderable: true, data: 'created_at' },
+ { orderable: true, data: 'current_sign_in_at' },
+ { orderable: true, data: 'last_sign_in_at', visible: false },
+ { orderable: true, data: 'current_sign_in_ip', visible: false },
+ { orderable: true, data: 'last_sign_in_ip', visible: false },
+ { orderable: true, data: 'sign_in_count', visible: false },
],
});
diff --git a/app/controllers/manage/configs_controller.rb b/app/controllers/manage/configs_controller.rb
index a48e5011d..e5d8eedc9 100644
--- a/app/controllers/manage/configs_controller.rb
+++ b/app/controllers/manage/configs_controller.rb
@@ -17,7 +17,10 @@ def update
value = params[:hackathon_config][key]
value = true if value == "true"
value = false if value == "false"
- if @config.value != value
+ if @config.var.end_with?("_asset") && !value.start_with?('http://', 'https://')
+ flash[:alert] = "Config \"#{key}\" must start with http:// or https://"
+ render :edit
+ elsif @config.value != value
@config.value = value
@config.save
redirect_to manage_configs_path, notice: "Config \"#{key}\" has been updated."
diff --git a/app/controllers/manage/questionnaires_controller.rb b/app/controllers/manage/questionnaires_controller.rb
index 70873a9b8..f10c75129 100644
--- a/app/controllers/manage/questionnaires_controller.rb
+++ b/app/controllers/manage/questionnaires_controller.rb
@@ -1,6 +1,7 @@
class Manage::QuestionnairesController < Manage::ApplicationController
include QuestionnairesControllable
+ before_action :ensure_registration_is_open, only: [:new, :create]
before_action :set_questionnaire, only: [:show, :edit, :update, :destroy, :check_in, :convert_to_admin, :update_acc_status, :message_events]
respond_to :html, :json
@@ -169,4 +170,11 @@ def convert_boarded_bus_param(values, questionnaire = nil)
def set_questionnaire
@questionnaire = ::Questionnaire.find(params[:id])
end
+
+ def ensure_registration_is_open
+ if HackathonConfig['disable_account_registration']
+ flash[:alert] = "Registration has closed"
+ redirect_to root_path
+ end
+ end
end
diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb
index 3fd090aa9..aa1766d7b 100644
--- a/app/controllers/users/registrations_controller.rb
+++ b/app/controllers/users/registrations_controller.rb
@@ -3,9 +3,14 @@ class Users::RegistrationsController < Devise::RegistrationsController
# before_action :configure_account_update_params, only: [:update]
# GET /resource/sign_up
- # def new
- # super
- # end
+ def new
+ if HackathonConfig['disable_account_registration']
+ flash[:alert] = "Registration has closed"
+ redirect_to root_path
+ else
+ super
+ end
+ end
# POST /resource
# def create
diff --git a/app/datatables/admin_datatable.rb b/app/datatables/admin_datatable.rb
index 5d3039011..62bdea5f5 100644
--- a/app/datatables/admin_datatable.rb
+++ b/app/datatables/admin_datatable.rb
@@ -9,6 +9,11 @@ def view_columns
active: { source: "User.is_active", searchable: false },
receive_weekly_report: { source: "User.receive_weekly_report", searchable: false },
created_at: { source: "User.created_at", searchable: false },
+ current_sign_in_at: { source: "User.current_sign_in_at", searchable: false },
+ last_sign_in_at: { source: "User.last_sign_in_at", searchable: false },
+ current_sign_in_ip: { source: "User.current_sign_in_ip" },
+ last_sign_in_ip: { source: "User.last_sign_in_ip" },
+ sign_in_count: { source: "User.sign_in_count", searchable: false },
}
end
@@ -23,6 +28,11 @@ def data
active: record.is_active ? 'Active'.html_safe : 'Inactive'.html_safe,
receive_weekly_report: yes_no_display(record.receive_weekly_report),
created_at: display_datetime(record.created_at),
+ current_sign_in_at: display_datetime(record.current_sign_in_at),
+ last_sign_in_at: display_datetime(record.last_sign_in_at),
+ current_sign_in_ip: record.current_sign_in_ip == "::1" ? "127.0.0.1" : record.current_sign_in_ip,
+ last_sign_in_ip: record.last_sign_in_ip == "::1" ? "127.0.0.1" : record.last_sign_in_ip,
+ sign_in_count: record.sign_in_count,
}
end
end
diff --git a/app/helpers/hackathon_manager_helper.rb b/app/helpers/hackathon_manager_helper.rb
index d8abdece4..cbc129dba 100644
--- a/app/helpers/hackathon_manager_helper.rb
+++ b/app/helpers/hackathon_manager_helper.rb
@@ -92,6 +92,9 @@ def acc_status_class(acc_status)
end
def display_datetime(datetime, opts = {})
+ if datetime.blank?
+ return ""
+ end
opts[:relative] = true if opts[:relative].nil?
formatted = ""
diff --git a/app/views/manage/admins/index.html.haml b/app/views/manage/admins/index.html.haml
index 25487b23c..ed72eef9e 100644
--- a/app/views/manage/admins/index.html.haml
+++ b/app/views/manage/admins/index.html.haml
@@ -11,4 +11,9 @@
%th Login access
%th Weekly report
%th Registered on
+ %th Signed-in on
+ %th Previous signed-in on
+ %th Signed-in IP
+ %th Previous signed-in IP
+ %th Sign-in count
%tbody
diff --git a/app/views/manage/admins/show.html.haml b/app/views/manage/admins/show.html.haml
index 7565d0f50..73f498e0f 100644
--- a/app/views/manage/admins/show.html.haml
+++ b/app/views/manage/admins/show.html.haml
@@ -36,6 +36,26 @@
%b Registered:
= display_datetime(@user.created_at)
+ %p
+ %b Signed-in on:
+ = display_datetime(@user.current_sign_in_at)
+
+ %p
+ %b Previous signed-in on:
+ = display_datetime(@user.last_sign_in_at)
+
+ %p
+ %b Signed-in IP:
+ = @user.current_sign_in_ip == "::1" ? "127.0.0.1" : @user.current_sign_in_ip
+
+ %p
+ %b Previous signed-in IP:
+ = @user.last_sign_in_ip == "::1" ? "127.0.0.1" : @user.last_sign_in_ip
+
+ %p
+ %b Sign-in count:
+ = @user.sign_in_count
+
.col-lg-6
%h4.border-bottom.pb-2.mb-3 Change History
= render "model_history", model: @user
diff --git a/config/app.yml b/config/app.yml
index ad910e4bf..62b077943 100644
--- a/config/app.yml
+++ b/config/app.yml
@@ -7,6 +7,7 @@ defaults: &defaults
last_day_to_apply: "<%= Date.new(2000, 1, 1).to_s %>"
event_start_date: "<%= Date.new(2000, 1, 1).to_s %>"
auto_late_waitlist: false
+ disable_account_registration: false
# Content config
name: HackFoo
diff --git a/config/locales/en.yml b/config/locales/en.yml
index bb090bf98..cc2654fde 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -30,7 +30,6 @@
# available at http://guides.rubyonrails.org/i18n.html.
en:
- devise:
devise:
failure:
unauthenticated: "Please sign in or sign up to continue."
@@ -61,6 +60,7 @@ en:
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
+ disable_account_registration: Prevent applicants from applying
name: Your hackathon's name
logo_asset: Optional logo asset (should be a full https:// URL to a .jpg, .png, or .svg file)
diff --git a/test/controllers/manage/configs_controller_test.rb b/test/controllers/manage/configs_controller_test.rb
index f3168b402..038423fa4 100644
--- a/test/controllers/manage/configs_controller_test.rb
+++ b/test/controllers/manage/configs_controller_test.rb
@@ -115,6 +115,20 @@ class Manage::ConfigsControllerTest < ActionController::TestCase
assert_redirected_to manage_configs_path
end
+ should "update logo_asset with a url" do
+ HackathonConfig["logo_asset"] = ""
+ patch :update, params: { id: "logo_asset", hackathon_config: { logo_asset: "https://picsum.photos/200" } }
+ assert_equal "https://picsum.photos/200", HackathonConfig["logo_asset"]
+ assert_redirected_to manage_configs_path
+ end
+
+ should "not update logo_asset with an asset that is not URL based" do
+ HackathonConfig["logo_asset"] = ""
+ patch :update, params: { id: "logo_asset", hackathon_config: { logo_asset: "test" } }
+ assert_equal "", HackathonConfig["logo_asset"]
+ assert_template :edit
+ end
+
should "update config CSS variables when custom_css is blank" do
HackathonConfig["custom_css"] = ""
patch :update, params: { id: "custom_css", hackathon_config: { custom_css: ":root {\n --foo: #fff;\n}" } }