Skip to content

Commit

Permalink
fix referees list in event
Browse files Browse the repository at this point in the history
  • Loading branch information
ctizen committed Oct 7, 2024
1 parent 223ac8f commit 4e16d30
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 30 deletions.
3 changes: 1 addition & 2 deletions Mimir/src/controllers/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -1371,8 +1371,7 @@ public function cancelPenalty($penaltyId, $reason)
throw new InvalidParametersException('Penalty id#' . $penaltyId . ' not found in DB');
}

if (
!$this->_meta->isEventAdminById($penalty[0]->getEventId()) ||
if (!$this->_meta->isEventAdminById($penalty[0]->getEventId()) ||
!$this->_meta->isEventRefereeById($penalty[0]->getEventId())
) {
throw new BadActionException("You don't have enough privileges to cancel penalties for this event");
Expand Down
5 changes: 4 additions & 1 deletion Mimir/src/controllers/Seating.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ public function makeIntervalSeating($eventId, $step)

$currentRatingTable = (new EventRatingTableModel($this->_ds, $this->_config, $this->_meta))
->getRatingTable(
$eventList, [], 'rating', 'desc',
$eventList,
[],
'rating',
'desc',
$this->_meta->isEventAdminById($eventId) || $this->_meta->isEventRefereeById($eventId)
);

Expand Down
3 changes: 1 addition & 2 deletions Mimir/src/models/InteractiveSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,7 @@ public function dropLastRound(string $gameHash, array $intermediateResults)
throw new InvalidParametersException("Couldn't find session in DB");
}

if (
!$this->_meta->isEventAdminById($session[0]->getEventId()) &&
if (!$this->_meta->isEventAdminById($session[0]->getEventId()) &&
!$this->_meta->isEventRefereeById($session[0]->getEventId())
) {
throw new AuthFailedException('Only administrators are allowed to drop last round');
Expand Down
5 changes: 5 additions & 0 deletions Mimir/tests/util/FreyClientMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,4 +425,9 @@ public function getMajsoulNicknames($ids)
}
return [];
}

public function getEventReferees(int $eventId): array
{
return [];
}
}
52 changes: 27 additions & 25 deletions Sigrun/app/pages/EventInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,31 +108,33 @@ export const EventInfo: React.FC<{ params: { eventId: string } }> = ({ params: {
</Group>
))}
</Group>
<Group style={{ fontSize: 'small' }}>
<Text c='dimmed'>{i18n._t('Event referees: ')}</Text>
{referees?.map((referee, idx) => (
<Group key={`ref_${idx}`}>
<PlayerAvatar
size='xs'
p={{
title: referee.personName,
id: referee.personId,
hasAvatar: referee.hasAvatar,
lastUpdate: referee.lastUpdate,
}}
/>
<Anchor
href={`/event/${eventId}/player/${referee.personId}`}
onClick={(e) => {
navigate(`/event/${eventId}/player/${referee.personId}`);
e.preventDefault();
}}
>
{referee.personName}
</Anchor>
</Group>
))}
</Group>
{(referees?.length ?? 0) > 0 && (
<Group style={{ fontSize: 'small' }}>
<Text c='dimmed'>{i18n._t('Event referees: ')}</Text>
{referees?.map((referee, idx) => (
<Group key={`ref_${idx}`}>
<PlayerAvatar
size='xs'
p={{
title: referee.personName,
id: referee.personId,
hasAvatar: referee.hasAvatar,
lastUpdate: referee.lastUpdate,
}}
/>
<Anchor
href={`/event/${eventId}/player/${referee.personId}`}
onClick={(e) => {
navigate(`/event/${eventId}/player/${referee.personId}`);
e.preventDefault();
}}
>
{referee.personName}
</Anchor>
</Group>
))}
</Group>
)}
</>
)}
</Container>
Expand Down

0 comments on commit 4e16d30

Please sign in to comment.