Events: kickstart shared scoreboard
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
class ContestsController < ApplicationController
|
||||
include CompletionsConcern
|
||||
include ContestsConcern
|
||||
include ContestantsConcern
|
||||
|
||||
before_action :set_contest, only: %i[ destroy show ]
|
||||
@@ -168,10 +169,30 @@ class ContestsController < ApplicationController
|
||||
end
|
||||
|
||||
def scoreboard
|
||||
@contest = Contest.find_by(slug: params[:id])
|
||||
unless @contest && @contest.public
|
||||
skip_authorization
|
||||
not_found and return
|
||||
if active_page("/public/event")
|
||||
@event = Event.find_by(slug: params[:id])
|
||||
unless @event && @event.shared_scoreboard && !@event.contests.where(public: true).empty?
|
||||
skip_authorization
|
||||
not_found and return
|
||||
end
|
||||
if params.key?(:contest_id)
|
||||
begin
|
||||
@contest = Contest.find(params[:contest_id])
|
||||
if @contest.event != @event
|
||||
@contest = @event.contests.where(public: true).first
|
||||
end
|
||||
rescue
|
||||
@contest = @event.contests.where(public: true).first
|
||||
end
|
||||
else
|
||||
@contest = @event.contests.where(public: true).first
|
||||
end
|
||||
else
|
||||
@contest = Contest.find_by(slug: params[:id])
|
||||
unless @contest && @contest.public
|
||||
skip_authorization
|
||||
not_found and return
|
||||
end
|
||||
end
|
||||
authorize @contest
|
||||
|
||||
|
||||
Reference in New Issue
Block a user