From 4e16d30e855a2940d6c373915984ecf5b1206dc4 Mon Sep 17 00:00:00 2001 From: Oleg Klimenko Date: Sat, 5 Oct 2024 00:20:18 +0300 Subject: [PATCH] fix referees list in event --- Mimir/src/controllers/Events.php | 3 +- Mimir/src/controllers/Seating.php | 5 ++- Mimir/src/models/InteractiveSession.php | 3 +- Mimir/tests/util/FreyClientMock.php | 5 +++ Sigrun/app/pages/EventInfo.tsx | 52 +++++++++++++------------ 5 files changed, 38 insertions(+), 30 deletions(-) diff --git a/Mimir/src/controllers/Events.php b/Mimir/src/controllers/Events.php index 7ff11fa18..de0d2b4c0 100644 --- a/Mimir/src/controllers/Events.php +++ b/Mimir/src/controllers/Events.php @@ -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"); diff --git a/Mimir/src/controllers/Seating.php b/Mimir/src/controllers/Seating.php index b6f50ff43..5ec0b23b4 100644 --- a/Mimir/src/controllers/Seating.php +++ b/Mimir/src/controllers/Seating.php @@ -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) ); diff --git a/Mimir/src/models/InteractiveSession.php b/Mimir/src/models/InteractiveSession.php index 5f1b96d9d..0d83191d9 100644 --- a/Mimir/src/models/InteractiveSession.php +++ b/Mimir/src/models/InteractiveSession.php @@ -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'); diff --git a/Mimir/tests/util/FreyClientMock.php b/Mimir/tests/util/FreyClientMock.php index e0506c82a..9dfc903ee 100644 --- a/Mimir/tests/util/FreyClientMock.php +++ b/Mimir/tests/util/FreyClientMock.php @@ -425,4 +425,9 @@ public function getMajsoulNicknames($ids) } return []; } + + public function getEventReferees(int $eventId): array + { + return []; + } } diff --git a/Sigrun/app/pages/EventInfo.tsx b/Sigrun/app/pages/EventInfo.tsx index 44f3cc329..454d1881f 100644 --- a/Sigrun/app/pages/EventInfo.tsx +++ b/Sigrun/app/pages/EventInfo.tsx @@ -108,31 +108,33 @@ export const EventInfo: React.FC<{ params: { eventId: string } }> = ({ params: { ))} - - {i18n._t('Event referees: ')} - {referees?.map((referee, idx) => ( - - - { - navigate(`/event/${eventId}/player/${referee.personId}`); - e.preventDefault(); - }} - > - {referee.personName} - - - ))} - + {(referees?.length ?? 0) > 0 && ( + + {i18n._t('Event referees: ')} + {referees?.map((referee, idx) => ( + + + { + navigate(`/event/${eventId}/player/${referee.personId}`); + e.preventDefault(); + }} + > + {referee.personName} + + + ))} + + )} )}