Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/Http/Controllers/ContestEntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ class ContestEntriesController extends Controller
{
public function judgeResults($contestId, $id)
{
$contest = Contest::findOrFail($contestId)
$contest = Contest::findOrFail($contestId);

abort_if(!$contest->isJudged() || !priv_check('ContestResultsShow', $contest)->can(), 404);

$contest
->loadCount('judges')
->loadSum('scoringCategories', 'max_value');

abort_if(!$contest->isJudged() || !$contest->show_votes, 404);

$entry = ContestEntry
::with([
'judgeVotes.scores',
Expand Down
5 changes: 5 additions & 0 deletions app/Models/Contest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ public function isBestOf(): bool
return isset($this->getExtraOptions()['best_of']);
}

public function isHostUserId(?int $userId): bool
{
return in_array($userId, $this->getExtraOptions()['host_user_ids'] ?? [], true);
}

public function isJudge(User $user): bool
{
$judges = $this->judges();
Expand Down
15 changes: 15 additions & 0 deletions app/Singletons/OsuAuthorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,21 @@ public function checkContestJudgeShow(?User $user, Contest $contest): string
return $this->checkContestJudge($user, $contest);
}

public function checkContestResultsShow(?User $user, Contest $contest): string
{
if ($contest->show_votes) {
return 'ok';
}

$this->ensureLoggedIn($user);

if ($contest->isHostUserId($user->getKey())) {
return 'ok';
}

return 'unauthorized';
}

/**
* @param User|null $user
* @param Contest $contest
Expand Down
4 changes: 4 additions & 0 deletions resources/css/bem/contest-judge-results-header.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
flex-wrap: wrap;
gap: 20px;
}

&__warning {
color: hsl(var(--hsl-red-2));
}
}
7 changes: 7 additions & 0 deletions resources/js/contest-judge-results/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ export default class Header extends React.PureComponent<Props> {
selected={this.selected}
/>

{!this.props.contest.show_votes && (
<div className='contest-judge-results-header__warning'>
<div>{trans('contest.judge_results.provisional')}</div>
<div>{trans('contest.judge_results.hosts_only')}</div>
</div>
)}

<div className='contest-judge-results-header__values'>
{totalScoreStd != null && (
<ValueDisplay
Expand Down
1 change: 1 addition & 0 deletions resources/js/interfaces/contest-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface ContestJsonAvailableIncludes {
interface ContestJsonDefaultAttributes {
id: number;
name: string;
show_votes: boolean;
}

type ContestJson = ContestJsonDefaultAttributes & Partial<ContestJsonAvailableIncludes>;
Expand Down
3 changes: 3 additions & 0 deletions resources/lang/en/contest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@
'judge_results' => [
'_' => 'Judging results',
'creator' => 'creator',
'hosts_only' => 'Only contest hosts and admins can currently see the results.',
'provisional' => 'Judging has not been finalized yet, and scores may not be accurate!',
Comment thread
notbakaneko marked this conversation as resolved.
Outdated
'score' => 'Score',
'score_std' => 'Standardised Score',
'total_score' => 'total score',
'total_score_std' => 'total standardised score',
],

'voting' => [
'host_link' => 'You are a host of this contest. View the premilinary results here!',
'judge_link' => 'You are a judge of this contest. Judge the entries here!',
'judged_notice' => 'This contest is using the judging system, the judges are currently processing the entries.',
'login_required' => 'Please sign in to vote.',
Expand Down
8 changes: 8 additions & 0 deletions resources/views/contests/voting.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
{{ $noVoteReason }}
</div>

@if ($contestMeta->isHostUserId(\Auth::id()))
<div class='contest__voting-notice'>
<a href="{{ route('contests.entries.judge-results', ['contest' => $contestMeta, 'contest_entry' => $contestMeta->entries()->first()]) }}">
{{osu_trans('contest.voting.host_link')}}
</a>
</div>
@endif

@if ($contestMeta->isJudged() && priv_check('ContestJudge', $contestMeta)->can())
<div class='contest__voting-notice'>
<a href="{{ route('contests.judge', $contestMeta) }}" target="_blank">{{osu_trans('contest.voting.judge_link')}}</a>
Expand Down