Skip to content

Commit

Permalink
Add Regulations Z1) and Z3) to the Create Competition form.
Browse files Browse the repository at this point in the history
This is another step towards thewca#2472.
  • Loading branch information
AlbertoPdRF committed Sep 1, 2018
1 parent 07eb637 commit 702000b
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 1 deletion.
8 changes: 8 additions & 0 deletions WcaOnRails/app/assets/javascripts/competitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ onPage('competitions#edit, competitions#update, competitions#admin_edit, competi
$('div.competition_external_website').toggle(!generateWebsite);
$('input#competition_external_website').prop('disabled', generateWebsite);
}).trigger('change');

$('input[name="competition[regulation_z1]"]').on('change', function() {
$('.wca-regulation-z1-reason').toggle(this.checked);
}).trigger('change');

$('input[name="competition[regulation_z3]"]').on('change', function() {
$('.wca-regulation-z3-reason').toggle(this.checked);
}).trigger('change');
});

// Sets map container height.
Expand Down
4 changes: 4 additions & 0 deletions WcaOnRails/app/controllers/competitions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ def my_competitions
:being_cloned_from_id,
:clone_tabs,
:refund_policy_limit_date,
:regulation_z1,
:regulation_z1_reason,
:regulation_z3,
:regulation_z3_reason,
]

if @competition.nil? || @competition.can_edit_registration_fees?
Expand Down
6 changes: 6 additions & 0 deletions WcaOnRails/app/models/competition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ class Competition < ApplicationRecord
updated_at
connected_stripe_account_id
refund_policy_limit_date
regulation_z1
regulation_z1_reason
regulation_z3
regulation_z3_reason
).freeze
VALID_NAME_RE = /\A([-&.:' [:alnum:]]+) (\d{4})\z/
PATTERN_LINK_RE = /\[\{([^}]+)}\{((https?:|mailto:)[^}]+)}\]/
Expand Down Expand Up @@ -152,6 +156,8 @@ class Competition < ApplicationRecord
as: "guests_base_fee",
allow_nil: true,
with_model_currency: :currency_code
validates :regulation_z1_reason, presence: true, if: :regulation_z1?
validates :regulation_z3_reason, presence: true, if: :regulation_z3?

NEARBY_DISTANCE_KM_WARNING = 250
NEARBY_DISTANCE_KM_DANGER = 100
Expand Down
11 changes: 11 additions & 0 deletions WcaOnRails/app/views/competitions/_competition_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,17 @@
</div>

<%= f.input :extra_registration_requirements, input_html: { class: "markdown-editor" } %>

<hr>
<%= f.input :regulation_z1 %>
<div class="wca-regulation-z1-reason">
<%= f.input :regulation_z1_reason %>
</div>

<%= f.input :regulation_z3 %>
<div class="wca-regulation-z3-reason">
<%= f.input :regulation_z3_reason %>
</div>
<% end %>

<hr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
</p>
<% end %>

<% if @competition.regulation_z1? %>
<p>
The Delegate(s) requested the adoption of <b>Regulation Z1)</b> because "<%= @competition.regulation_z1_reason %>"
</p>
<% end %>

<% if @competition.regulation_z3? %>
<p>
The Delegate(s) requested the adoption of <b>Regulation Z3)</b> because "<%= @competition.regulation_z3_reason %>"
</p>
<% end %>

<p>
@Board: You can delete this competition or make it publicly visible <%= link_to "here", admin_edit_competition_url(@competition) %>.
For a complete list of confirmed but unannounced competitions see your <%= link_to "notifications", notifications_url %>.
Expand Down
8 changes: 8 additions & 0 deletions WcaOnRails/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ en:
refund_policy_percent: "Percent to be refunded"
refund_policy_limit_date: "Limit date for refunds"
guests_entry_fee_lowest_denomination: "Entry fee for guests"
regulation_z1: "I would like to require competitors to submit puzzles during registration as per Regulation Z1)"
regulation_z1_reason: "Reason for Z1)"
regulation_z3: "I would like to select competitors who directly qualify for certain rounds of certain events based on the results of specific previous competitions as per Regulation Z3)"
regulation_z3_reason: "Reason for Z3)"
#context: a registration to a competition
registration:
guests: "Guests"
Expand Down Expand Up @@ -433,6 +437,10 @@ en:
refund_policy_percent: "For now this number is informational only, refunds will have to be issued manually. If this is set to 0, a sentence will be displayed saying that registration fees won't be refunded under any circumstance."
refund_policy_limit_date: "Date after which no more refunds will be issued."
guests_entry_fee_lowest_denomination: "For now this number is informational only, guest fees cannot be managed through this website. If this is set to 0, a sentence will be displayed saying that spectators can attend for free."
regulation_z1: ""
regulation_z1_reason: "Please elaborate here why you would like to adopt Regulation Z1). Please fill this out in English!"
regulation_z3: ""
regulation_z3_reason: "Please elaborate here why you would like to adopt Regulation Z3). 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,11 @@
# frozen_string_literal: true

class AddZ1AndZ3ColumnsToCompetitions < ActiveRecord::Migration[5.2]
def change
add_column :Competitions, :regulation_z1, :boolean, null: true, default: nil
add_column :Competitions, :regulation_z1_reason, :string, null: true, default: nil

add_column :Competitions, :regulation_z3, :boolean, null: true, default: nil
add_column :Competitions, :regulation_z3_reason, :string, null: true, default: nil
end
end
7 changes: 6 additions & 1 deletion WcaOnRails/db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ CREATE TABLE `Competitions` (
`guests_entry_fee_lowest_denomination` int(11) DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`regulation_z1` tinyint(1) DEFAULT NULL,
`regulation_z1_reason` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`regulation_z3` tinyint(1) DEFAULT NULL,
`regulation_z3_reason` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `year_month_day` (`year`,`month`,`day`),
KEY `index_Competitions_on_countryId` (`countryId`),
Expand Down Expand Up @@ -1408,4 +1412,5 @@ INSERT INTO `schema_migrations` (version) VALUES
('20180731204733'),
('20180822165331'),
('20180825115701'),
('20180831075355');
('20180831075355'),
('20180831164420');
4 changes: 4 additions & 0 deletions WcaOnRails/lib/database_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def self.actions_to_column_sanitizers(columns_by_action)
refund_policy_percent
refund_policy_limit_date
guests_entry_fee_lowest_denomination
regulation_z1
regulation_z1_reason
regulation_z3
regulation_z3_reason
),
db_default: %w(
connected_stripe_account_id
Expand Down

0 comments on commit 702000b

Please sign in to comment.