Skip to content

Commit

Permalink
Added checkbox for requesting event restrictions based on specific co…
Browse files Browse the repository at this point in the history
…mbinations of events. Requested in WCAT wish list #3759 #3759 (comment)
  • Loading branch information
Jambrose777 authored and AlbertoPdRF committed Aug 17, 2019
1 parent 92cda7c commit c094db9
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions WcaOnRails/app/assets/javascripts/competitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ onPage('competitions#edit, competitions#update, competitions#admin_edit, competi
$('input[name="competition[qualification_results]"]').on('change', function() {
$('.competition_qualification_results_reason').toggle(this.checked);
}).trigger('change');

$('input[name="competition[event_restrictions]"]').on('change', function() {
$('.competition_event_restrictions_reason').toggle(this.checked);
}).trigger('change');
});

// Sets map container height.
Expand Down
2 changes: 2 additions & 0 deletions WcaOnRails/app/controllers/competitions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ def for_senior
:early_puzzle_submission_reason,
:qualification_results,
:qualification_results_reason,
:event_restrictions,
:event_restrictions_reason,
:guests_entry_fee_lowest_denomination,
competition_events_attributes: [:id, :event_id, :_destroy],
championships_attributes: [:id, :championship_type, :_destroy],
Expand Down
3 changes: 3 additions & 0 deletions WcaOnRails/app/models/competition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class Competition < ApplicationRecord
early_puzzle_submission_reason
qualification_results
qualification_results_reason
event_restrictions
event_restrictions_reason
).freeze
VALID_NAME_RE = /\A([-&.:' [:alnum:]]+) (\d{4})\z/.freeze
PATTERN_LINK_RE = /\[\{([^}]+)}\{((https?:|mailto:)[^}]+)}\]/.freeze
Expand Down Expand Up @@ -168,6 +170,7 @@ class Competition < ApplicationRecord
with_model_currency: :currency_code
validates :early_puzzle_submission_reason, presence: true, if: :early_puzzle_submission?
validates :qualification_results_reason, presence: true, if: :qualification_results?
validates :event_restrictions_reason, presence: true, if: :event_restrictions?

NEARBY_DISTANCE_KM_WARNING = 250
NEARBY_DISTANCE_KM_DANGER = 100
Expand Down
3 changes: 3 additions & 0 deletions WcaOnRails/app/views/competitions/_competition_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@
<%= f.input :qualification_results %>
<%= f.input :qualification_results_reason %>

<%= f.input :event_restrictions %>
<%= f.input :event_restrictions_reason %>

</fieldset>

<hr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
<% if @competition.qualification_results? %>
The <%= "Delegate".pluralize(@competition.delegates.count) %> requested the adoption of <b>qualification results</b> because "<%= @competition.qualification_results_reason %>".
<% end %>

<% if @competition.event_restrictions? %>
The <%= "Delegate".pluralize(@competition.delegates.count) %> requested the adoption of <b>event restrictions</b> because "<%= @competition.event_restrictions_reason %>".
<% end %>
</p>

<p>
Expand Down
4 changes: 4 additions & 0 deletions WcaOnRails/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ en:
early_puzzle_submission_reason: "Reason and details for submitting puzzles early"
qualification_results: "I would like to use qualification results to limit who can compete in certain events"
qualification_results_reason: "Reason and details for qualification results"
event_restrictions: "I would like to restrict competitors from registering for specific combinations of events"
event_restrictions_reason: "Reason and details for event restrictions"
#context: a registration to a competition
registration:
guests: "Guests"
Expand Down Expand Up @@ -499,6 +501,8 @@ en:
early_puzzle_submission_reason: "Please elaborate here why you would like to require competitors to submit puzzles early. Please fill this out in English!"
qualification_results: ""
qualification_results_reason: "Please elaborate here why you would like to use qualification times. Please fill this out in English!"
event_restrictions: ""
event_restrictions_reason: "Please elaborate here why you would like to restrict certain event combinations. Please fill this out in English!"
website_contact:
inquiry: ""
competition_id: ""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

class AddEventRestrictionColumnsToCompetitions < ActiveRecord::Migration[5.2]
def change
add_column :Competitions, :event_restrictions, :boolean, null: true, default: nil
add_column :Competitions, :event_restrictions_reason, :text, null: true, default: nil
end
end
5 changes: 4 additions & 1 deletion WcaOnRails/db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ CREATE TABLE `Competitions` (
`name_reason` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`external_registration_page` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`confirmed_at` datetime DEFAULT NULL,
`event_restrictions` tinyint(1) DEFAULT NULL,
`event_restrictions_reason` text COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
KEY `year_month_day` (`year`,`month`,`day`),
KEY `index_Competitions_on_countryId` (`countryId`),
Expand Down Expand Up @@ -1573,4 +1575,5 @@ INSERT INTO `schema_migrations` (version) VALUES
('20190716065618'),
('20190728084145'),
('20190814232833'),
('20190816001639');
('20190816001639'),
('20190816004605');
2 changes: 2 additions & 0 deletions WcaOnRails/lib/database_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def self.actions_to_column_sanitizers(columns_by_action)
early_puzzle_submission_reason
qualification_results
qualification_results_reason
event_restrictions
event_restrictions_reason
),
db_default: %w(
connected_stripe_account_id
Expand Down

0 comments on commit c094db9

Please sign in to comment.