Restrict offline participation to single-puzzle
contests
This commit is contained in:
@@ -48,7 +48,7 @@ class ContestPolicy < ApplicationPolicy
|
||||
end
|
||||
|
||||
def offline?
|
||||
record.offline_form
|
||||
record.offline_form && record.puzzles.length < 2
|
||||
end
|
||||
|
||||
def offline_new?
|
||||
|
||||
@@ -17,9 +17,18 @@ h4.mt-5 = t("contests.form.general")
|
||||
= form.label :public
|
||||
.row.mb-3
|
||||
.col
|
||||
.form-check.form-switch
|
||||
= form.check_box :offline_form, class: "form-check-input"
|
||||
= form.label :offline_form
|
||||
- if @contest.puzzles.length <= 1
|
||||
.form-check.form-switch
|
||||
= form.check_box :offline_form, class: "form-check-input"
|
||||
= form.label :offline_form
|
||||
.form-text = t("activerecord.attributes.contest.offline_form_warning")
|
||||
.form-text = t("activerecord.attributes.contest.offline_form_description")
|
||||
- else
|
||||
.form-check.form-switch
|
||||
= form.check_box :offline_form_fake, class: "form-check-input", disabled: true
|
||||
= form.label :offline_form
|
||||
.form-text = t("activerecord.attributes.contest.offline_form_warning")
|
||||
.form-text = t("activerecord.attributes.contest.offline_form_description")
|
||||
.row.mb-3
|
||||
.col
|
||||
.form-check.form-switch
|
||||
|
||||
@@ -29,7 +29,7 @@ javascript:
|
||||
categorySelectEl.addEventListener('change', (e) => {
|
||||
updateParams();
|
||||
})
|
||||
- if @contest.offline_form
|
||||
- if @contest.offline_form && @contest.puzzles.length < 2
|
||||
.row
|
||||
.col
|
||||
input type="checkbox" id="offline" style="padding: 5px;"
|
||||
|
||||
@@ -68,7 +68,7 @@ css:
|
||||
- @contest.puzzles.each do |puzzle|
|
||||
= image_tag(puzzle.image, class: "img-fluid ms-3 me-3", style: "max-height: 220px") if puzzle.image.attached?
|
||||
|
||||
= render "category_selector"
|
||||
= render "selectors"
|
||||
|
||||
.d-flex.flex-column style="overflow-y: auto"
|
||||
table.table.table-striped.table-hover
|
||||
|
||||
@@ -20,7 +20,7 @@ javascript:
|
||||
- else
|
||||
a.btn.btn-success.disabled
|
||||
= t("contests.show.public_scoreboard_disabled")
|
||||
- if @contest.offline_form
|
||||
- if @contest.offline_form && @contest.puzzles.length < 2
|
||||
a.ms-3.btn.btn-success href="/public/#{@contest.slug}/offline"
|
||||
= t("contests.show.open_offline_form")
|
||||
- else
|
||||
|
||||
Reference in New Issue
Block a user