diff --git a/ChangeLog b/ChangeLog index 6e3e5f344f0..2d16454641a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,7 @@ Version 8.3.0DEV - Fix medal awards when skipping categories. - Add direct button to public page for registering when enabled. - Scale batch size of judge tasks dynamically. + - Rename room to location for teams. Version 8.2.0 - 6 March 2023 ---------------------------- diff --git a/doc/manual/import.rst b/doc/manual/import.rst index 6cfaa1f0f19..11878e11dba 100644 --- a/doc/manual/import.rst +++ b/doc/manual/import.rst @@ -166,7 +166,7 @@ fields: - ``display_name`` (optional): the team display name. If provided, will display this instead of the team name in certain places, like the scoreboard - ``organization_id``: the ID of the team affiliation this team belongs to -- ``room`` (optional): the room of the team +- ``location`` (optional): the location of the team If the ``data_source`` setting of DOMjudge is set to external, the ``id`` field will be the ID used for the team and the ``group_ids`` and ``organization_id`` fields are the values as @@ -183,7 +183,7 @@ Example ``teams.json``:: "group_ids": ["24"], "name": "¡i¡i¡", "organization_id": "INST-42", - "room": "AUD 10" + "location": "AUD 10" }, { "id": "2", "icpc_id": "447837", diff --git a/webapp/migrations/Version20240112100916.php b/webapp/migrations/Version20240112100916.php new file mode 100644 index 00000000000..0ff4776a5c6 --- /dev/null +++ b/webapp/migrations/Version20240112100916.php @@ -0,0 +1,36 @@ +addSql('ALTER TABLE team CHANGE room location VARCHAR(255) DEFAULT NULL COMMENT \'Physical location of team\''); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE team CHANGE location room VARCHAR(255) DEFAULT NULL COMMENT \'Physical location of team\''); + } + + public function isTransactional(): bool + { + return false; + } +} diff --git a/webapp/public/js/domjudge.js b/webapp/public/js/domjudge.js index bd1b254320d..891faf7abca 100644 --- a/webapp/public/js/domjudge.js +++ b/webapp/public/js/domjudge.js @@ -658,7 +658,7 @@ function updateMenuBalloons(data) $("#num-alerts-balloons").html(num); $("#num-alerts-balloons").show(); for (var i=0; iem->createQueryBuilder() - ->from(Team::class, 'a', 'a.room') + ->from(Team::class, 'a', 'a.location') ->select('a') - ->where('a.room IN (:rooms)') - ->setParameter('rooms', $filters['location-str']) + ->where('a.location IN (:locations)') + ->setParameter('locations', $filters['location-str']) ->getQuery() ->getResult(); } diff --git a/webapp/src/Controller/Jury/JuryMiscController.php b/webapp/src/Controller/Jury/JuryMiscController.php index 3222ce0b090..17389ec6071 100644 --- a/webapp/src/Controller/Jury/JuryMiscController.php +++ b/webapp/src/Controller/Jury/JuryMiscController.php @@ -83,15 +83,15 @@ public function ajaxDataAction(Request $request, string $datatype): JsonResponse }, $affiliations); } elseif ($datatype === 'locations') { $locations = $qb->from(Team::class, 'a') - ->select('DISTINCT a.room') - ->where($qb->expr()->like('a.room', '?1')) - ->orderBy('a.room', 'ASC') + ->select('DISTINCT a.location') + ->where($qb->expr()->like('a.location', '?1')) + ->orderBy('a.location', 'ASC') ->getQuery()->setParameter(1, '%' . $q . '%') ->getResult(); $results = array_map(fn(array $location) => [ - 'id' => $location['room'], - 'text' => $location['room'] + 'id' => $location['location'], + 'text' => $location['location'] ], $locations); } elseif (!$this->isGranted('ROLE_JURY')) { throw new AccessDeniedHttpException('Permission denied'); diff --git a/webapp/src/Controller/Jury/TeamController.php b/webapp/src/Controller/Jury/TeamController.php index 89af02df104..fe72da5f7d6 100644 --- a/webapp/src/Controller/Jury/TeamController.php +++ b/webapp/src/Controller/Jury/TeamController.php @@ -93,7 +93,7 @@ public function indexAction(): Response 'affiliation' => ['title' => 'affiliation', 'sort' => true,], 'num_contests' => ['title' => '# contests', 'sort' => true,], 'ip_address' => ['title' => 'last IP', 'sort' => true,], - 'room' => ['title' => 'room', 'sort' => true,], + 'location' => ['title' => 'location', 'sort' => true,], 'status' => ['title' => '', 'sort' => false,], 'stats' => ['title' => 'stats', 'sort' => true,], ]; diff --git a/webapp/src/Controller/Team/MiscController.php b/webapp/src/Controller/Team/MiscController.php index bacd344d5e4..014667b9582 100644 --- a/webapp/src/Controller/Team/MiscController.php +++ b/webapp/src/Controller/Team/MiscController.php @@ -184,7 +184,7 @@ public function printAction(Request $request): Response $teamId = (string)$team->getTeamid(); } $ret = $this->dj->printFile($realfile, $originalfilename, $langid, - $username, $team->getEffectiveName(), $teamId, $team->getRoom()); + $username, $team->getEffectiveName(), $teamId, $team->getLocation()); return $this->render('team/print_result.html.twig', [ 'success' => $ret[0], diff --git a/webapp/src/DataFixtures/Test/AddLocationToTeamFixture.php b/webapp/src/DataFixtures/Test/AddLocationToTeamFixture.php new file mode 100644 index 00000000000..806bbb206aa --- /dev/null +++ b/webapp/src/DataFixtures/Test/AddLocationToTeamFixture.php @@ -0,0 +1,16 @@ +getRepository(Team::class)->findOneBy(['name' => 'Example teamname']); + $team->setLocation('Utrecht'); + $manager->flush(); + } +} diff --git a/webapp/src/Entity/Team.php b/webapp/src/Entity/Team.php index c2f66196013..73c749f47ee 100644 --- a/webapp/src/Entity/Team.php +++ b/webapp/src/Entity/Team.php @@ -87,8 +87,9 @@ class Team extends BaseApiEntity implements ExternalRelationshipEntityInterface, private ?string $publicDescription = null; #[ORM\Column(nullable: true, options: ['comment' => 'Physical location of team'])] - #[Serializer\Exclude] - private ?string $room = null; + #[OA\Property(nullable: true)] + #[Serializer\Groups([ARC::GROUP_NONSTRICT])] + private ?string $location = null; #[ORM\Column( name: 'internalcomments', @@ -285,15 +286,15 @@ public function getPublicDescription(): ?string return $this->publicDescription; } - public function setRoom(?string $room): Team + public function setLocation(?string $location): Team { - $this->room = $room; + $this->location = $location; return $this; } - public function getRoom(): ?string + public function getLocation(): ?string { - return $this->room; + return $this->location; } public function setInternalComments(?string $comments): Team diff --git a/webapp/src/Form/Type/TeamType.php b/webapp/src/Form/Type/TeamType.php index 17b98cb5282..5a5cdde162e 100644 --- a/webapp/src/Form/Type/TeamType.php +++ b/webapp/src/Form/Type/TeamType.php @@ -82,7 +82,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $builder->add('penalty', IntegerType::class, [ 'label' => 'Penalty time', ]); - $builder->add('room', TextType::class, [ + $builder->add('location', TextType::class, [ 'label' => 'Location', 'required' => false, ]); diff --git a/webapp/src/Service/BalloonService.php b/webapp/src/Service/BalloonService.php index 3a824eb0565..c269d85cfe2 100644 --- a/webapp/src/Service/BalloonService.php +++ b/webapp/src/Service/BalloonService.php @@ -92,7 +92,7 @@ public function collectBalloonTable(Contest $contest, bool $todo = false): array $query = $em->createQueryBuilder() ->select('b', 's.submittime', 'p.probid', - 't.teamid', 's', 't', 't.room', + 't.teamid', 's', 't', 't.location', 'c.categoryid AS categoryid', 'c.name AS catname', 'co.cid', 'co.shortname', 'cp.shortname AS probshortname', 'cp.color', @@ -159,7 +159,7 @@ public function collectBalloonTable(Contest $contest, bool $todo = false): array $balloondata['contestproblem'] = $balloon->getSubmission()->getContestProblem(); $balloondata['team'] = $balloon->getSubmission()->getTeam(); $balloondata['teamid'] = $balloonsData['teamid']; - $balloondata['location'] = $balloonsData['room']; + $balloondata['location'] = $balloonsData['location']; $balloondata['affiliation'] = $balloonsData['affilshort']; $balloondata['affiliationid'] = $balloonsData['affilid']; $balloondata['category'] = $balloonsData['catname']; diff --git a/webapp/src/Service/DOMJudgeService.php b/webapp/src/Service/DOMJudgeService.php index b6975f0e72c..3c745392f80 100644 --- a/webapp/src/Service/DOMJudgeService.php +++ b/webapp/src/Service/DOMJudgeService.php @@ -410,7 +410,7 @@ public function getUpdates(): array if ($this->checkrole('balloon')) { $balloonsQuery = $this->em->createQueryBuilder() - ->select('b.balloonid', 't.name', 't.room', 'p.name AS pname') + ->select('b.balloonid', 't.name', 't.location', 'p.name AS pname') ->from(Balloon::class, 'b') ->leftJoin('b.submission', 's') ->leftJoin('s.problem', 'p') @@ -714,7 +714,7 @@ public function openZipFile(string $filename): ZipArchive * @param string $username Username of the print job submitter * @param string|null $teamname Teamname of the team this user belongs to, if any * @param string|null $teamid Teamid of the team this user belongs to, if any - * @param string|null $location Room/place of the team, if any. + * @param string|null $location Location of the team, if any. */ public function printFile( string $filename, diff --git a/webapp/src/Service/ICPCCmsService.php b/webapp/src/Service/ICPCCmsService.php index 207403182b1..ff5c308deb6 100644 --- a/webapp/src/Service/ICPCCmsService.php +++ b/webapp/src/Service/ICPCCmsService.php @@ -115,7 +115,7 @@ public function importTeams(string $token, string $contest, ?string &$message = ->setEnabled($enabled) ->setInternalComments('Status: ' . $teamData['status']) ->setIcpcid($teamData['teamId']) - ->setRoom($siteName); + ->setLocation($siteName); $this->em->persist($team); $this->em->flush(); $username = sprintf("team%04d", $team->getTeamid()); @@ -137,7 +137,7 @@ public function importTeams(string $token, string $contest, ?string &$message = ->setEnabled($enabled) ->setInternalComments('Status: ' . $teamData['status']) ->setIcpcid($teamData['teamId']) - ->setRoom($siteName); + ->setLocation($siteName); $user = $this->em->getRepository(User::class)->findOneBy(['username' => $username]); $user?->setName($teamData['teamName']); diff --git a/webapp/src/Service/ImportExportService.php b/webapp/src/Service/ImportExportService.php index b323070015c..62cd77944cc 100644 --- a/webapp/src/Service/ImportExportService.php +++ b/webapp/src/Service/ImportExportService.php @@ -851,7 +851,7 @@ public function importTeamsJson(array $data, ?string &$message = null, ?array &$ 'name' => @$team['name'], 'display_name' => @$team['display_name'], 'publicdescription' => $team['public_description'] ?? @$team['members'], - 'room' => @$team['room'], + 'location' => @$team['location'], ], 'team_affiliation' => [ 'externalid' => $team['organization_id'] ?? null, diff --git a/webapp/templates/jury/balloons.html.twig b/webapp/templates/jury/balloons.html.twig index 0d51e9888da..d1a1011ceef 100644 --- a/webapp/templates/jury/balloons.html.twig +++ b/webapp/templates/jury/balloons.html.twig @@ -46,8 +46,8 @@ diff --git a/webapp/templates/jury/partials/team_form.html.twig b/webapp/templates/jury/partials/team_form.html.twig index 69cbea4d30a..0ad3c087753 100644 --- a/webapp/templates/jury/partials/team_form.html.twig +++ b/webapp/templates/jury/partials/team_form.html.twig @@ -12,7 +12,7 @@ {{ form_row(form.publicdescription) }} {{ form_row(form.affiliation) }} {{ form_row(form.penalty) }} - {{ form_row(form.room) }} + {{ form_row(form.location) }} {{ form_row(form.internalcomments) }} {{ form_row(form.contests) }} {{ form_row(form.enabled) }} diff --git a/webapp/templates/jury/team.html.twig b/webapp/templates/jury/team.html.twig index b6971a3b1c4..063dc3c558d 100644 --- a/webapp/templates/jury/team.html.twig +++ b/webapp/templates/jury/team.html.twig @@ -85,10 +85,10 @@ {{ team.penalty }} {% endif %} - {% if team.room %} + {% if team.location %} Location - {{ team.room }} + {{ team.location }} {% endif %} diff --git a/webapp/templates/partials/team.html.twig b/webapp/templates/partials/team.html.twig index 5ceaa840432..be3bf714da4 100644 --- a/webapp/templates/partials/team.html.twig +++ b/webapp/templates/partials/team.html.twig @@ -45,10 +45,10 @@ {% endif %} {% endif %} - {% if team.room is not empty %} + {% if team.location is not empty %} Location - {{ team.room }} + {{ team.location }} {% endif %} diff --git a/webapp/tests/Unit/Controller/API/TeamControllerTest.php b/webapp/tests/Unit/Controller/API/TeamControllerTest.php index 46bb47ada1e..f172607e996 100644 --- a/webapp/tests/Unit/Controller/API/TeamControllerTest.php +++ b/webapp/tests/Unit/Controller/API/TeamControllerTest.php @@ -2,6 +2,7 @@ namespace App\Tests\Unit\Controller\API; +use App\DataFixtures\Test\AddLocationToTeamFixture; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -21,9 +22,12 @@ class TeamControllerTest extends BaseTestCase 'display_name' => null, 'members' => null, 'photo' => null, + 'location' => 'Utrecht', ], ]; + protected static array $fixtures = [AddLocationToTeamFixture::class]; + protected array $expectedAbsent = ['4242', 'nonexistent']; public function testLogoManagement(): void diff --git a/webapp/tests/Unit/Controller/Jury/TeamControllerTest.php b/webapp/tests/Unit/Controller/Jury/TeamControllerTest.php index 8c248df8cd9..c90d4e8a015 100644 --- a/webapp/tests/Unit/Controller/Jury/TeamControllerTest.php +++ b/webapp/tests/Unit/Controller/Jury/TeamControllerTest.php @@ -18,7 +18,7 @@ class TeamControllerTest extends JuryControllerTestCase protected static string $className = Team::class; protected static array $DOM_elements = ['h1' => ['Teams']]; protected static string $addForm = 'team['; - protected static array $addEntitiesShown = ['icpcid', 'label', 'displayName', 'room']; + protected static array $addEntitiesShown = ['icpcid', 'label', 'displayName', 'location']; protected static array $overviewSingleNotShown = ['addUserForTeam']; protected static array $overviewGeneralNotShown = ['icpcid']; protected static array $addEntitiesCount = ['contests']; @@ -27,7 +27,7 @@ class TeamControllerTest extends JuryControllerTestCase 'category' => '3', 'publicdescription' => 'Some members', 'penalty' => '0', - 'room' => 'The first room', + 'location' => 'The first room', 'internalcomments' => 'This is a team without a user', 'contests' => [], 'enabled' => '1', @@ -38,7 +38,7 @@ class TeamControllerTest extends JuryControllerTestCase 'category' => '1', 'publicdescription' => 'More members', 'penalty' => '20', - 'room' => 'Another room', + 'location' => 'Another room', 'internalcomments' => 'This is a team with a user', 'enabled' => '1', 'addUserForTeam' => Team::CREATE_NEW_USER, @@ -57,9 +57,9 @@ class TeamControllerTest extends JuryControllerTestCase ['name' => 'no_members', 'publicdescription' => '', 'displayName' => 'Team without members'], - ['name' => 'no_room', - 'room' => '', - 'displayName' => 'Team without a room'], + ['name' => 'no_location', + 'location' => '', + 'displayName' => 'Team without a location'], ['name' => 'no_comments', 'internalcomments' => '', 'displayName' => 'Team without comments'], diff --git a/webapp/tests/Unit/Service/ImportExportServiceTest.php b/webapp/tests/Unit/Service/ImportExportServiceTest.php index eb95cbd88ca..550e5c5a4c3 100644 --- a/webapp/tests/Unit/Service/ImportExportServiceTest.php +++ b/webapp/tests/Unit/Service/ImportExportServiceTest.php @@ -675,7 +675,7 @@ public function testImportTeamsTsv(): void self::assertEquals($data['icpcid'], $team->getIcpcId()); self::assertEquals($data['label'], $team->getLabel()); self::assertEquals($data['name'], $team->getName()); - self::assertNull($team->getRoom()); + self::assertNull($team->getLocation()); self::assertEquals($data['category']['externalid'], $team->getCategory()->getExternalid()); self::assertEquals($data['affiliation']['externalid'], $team->getAffiliation()->getExternalid()); self::assertEquals($data['affiliation']['shortname'], $team->getAffiliation()->getShortname()); @@ -697,7 +697,7 @@ public function testImportTeamsJson(): void "group_ids": ["24"], "name": "¡i¡i¡", "organization_id": "INST-42", - "room": "AUD 10" + "location": "AUD 10" }, { "id": "12", "icpc_id": "447837", @@ -720,7 +720,7 @@ public function testImportTeamsJson(): void 'icpcid' => '447047', 'label' => 'team1', 'name' => '¡i¡i¡', - 'room' => 'AUD 10', + 'location' => 'AUD 10', 'category' => [ 'externalid' => '24', ], @@ -732,7 +732,7 @@ public function testImportTeamsJson(): void 'icpcid' => '447837', 'label' => null, 'name' => 'Pleading not FAUlty', - 'room' => null, + 'location' => null, 'category' => [ 'externalid' => '25', ], @@ -744,7 +744,7 @@ public function testImportTeamsJson(): void 'icpcid' => '123456', 'label' => '0', 'name' => 'Team with label 0', - 'room' => null, + 'location' => null, 'category' => [ 'externalid' => '26', ], @@ -774,7 +774,7 @@ public function testImportTeamsJson(): void self::assertNotNull($team, "Team $data[name] does not exist"); self::assertEquals($data['icpcid'], $team->getIcpcId()); self::assertEquals($data['label'], $team->getLabel()); - self::assertEquals($data['room'], $team->getRoom()); + self::assertEquals($data['location'], $team->getLocation()); self::assertEquals($data['name'], $team->getName()); self::assertEquals($data['category']['externalid'], $team->getCategory()->getExternalid()); self::assertEquals($data['affiliation']['externalid'], $team->getAffiliation()->getExternalid());