Skip to content

Commit 6ee27fb

Browse files
Add location to team API.
Fixes #2283. Also rename room to location in database and UI to be more consistent.
1 parent 98157a2 commit 6ee27fb

22 files changed

+104
-46
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Version 8.3.0DEV
2727
- Fix medal awards when skipping categories.
2828
- Add direct button to public page for registering when enabled.
2929
- Scale batch size of judge tasks dynamically.
30+
- Rename room to location for teams.
3031

3132
Version 8.2.0 - 6 March 2023
3233
----------------------------

doc/manual/import.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ fields:
166166
- ``display_name`` (optional): the team display name. If provided, will display
167167
this instead of the team name in certain places, like the scoreboard
168168
- ``organization_id``: the ID of the team affiliation this team belongs to
169-
- ``room`` (optional): the room of the team
169+
- ``location`` (optional): the location of the team
170170

171171
If the ``data_source`` setting of DOMjudge is set to external, the ``id`` field will be the
172172
ID used for the team and the ``group_ids`` and ``organization_id`` fields are the values as
@@ -183,7 +183,7 @@ Example ``teams.json``::
183183
"group_ids": ["24"],
184184
"name": "¡i¡i¡",
185185
"organization_id": "INST-42",
186-
"room": "AUD 10"
186+
"location": "AUD 10"
187187
}, {
188188
"id": "2",
189189
"icpc_id": "447837",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20240112100916 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return 'Change room to location for teams.';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql('ALTER TABLE team CHANGE room location VARCHAR(255) DEFAULT NULL COMMENT \'Physical location of team\'');
24+
}
25+
26+
public function down(Schema $schema): void
27+
{
28+
// this down() migration is auto-generated, please modify it to your needs
29+
$this->addSql('ALTER TABLE team CHANGE location room VARCHAR(255) DEFAULT NULL COMMENT \'Physical location of team\'');
30+
}
31+
32+
public function isTransactional(): bool
33+
{
34+
return false;
35+
}
36+
}

webapp/public/js/domjudge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ function updateMenuBalloons(data)
658658
$("#num-alerts-balloons").html(num);
659659
$("#num-alerts-balloons").show();
660660
for (var i=0; i<num; i++) {
661-
var text = (data[i].room !== null) ? data[i].room+': ' : '';
661+
var text = (data[i].location !== null) ? data[i].location+': ' : '';
662662
text += data[i].pname + ' ' + data[i].name;
663663
sendNotification('New balloon:',
664664
{'tag': 'ball_' + data[i].baloonid,

webapp/src/Controller/Jury/BalloonController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ public function indexAction(BalloonService $balloonService): Response
9191
if (isset($filters['location-str'])) {
9292
/** @var Team[] $filteredLocations */
9393
$filteredLocations = $this->em->createQueryBuilder()
94-
->from(Team::class, 'a', 'a.room')
94+
->from(Team::class, 'a', 'a.location')
9595
->select('a')
96-
->where('a.room IN (:rooms)')
97-
->setParameter('rooms', $filters['location-str'])
96+
->where('a.location IN (:locations)')
97+
->setParameter('locations', $filters['location-str'])
9898
->getQuery()
9999
->getResult();
100100
}

webapp/src/Controller/Jury/JuryMiscController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ public function ajaxDataAction(Request $request, string $datatype): JsonResponse
8383
}, $affiliations);
8484
} elseif ($datatype === 'locations') {
8585
$locations = $qb->from(Team::class, 'a')
86-
->select('DISTINCT a.room')
87-
->where($qb->expr()->like('a.room', '?1'))
88-
->orderBy('a.room', 'ASC')
86+
->select('DISTINCT a.location')
87+
->where($qb->expr()->like('a.location', '?1'))
88+
->orderBy('a.location', 'ASC')
8989
->getQuery()->setParameter(1, '%' . $q . '%')
9090
->getResult();
9191

9292
$results = array_map(fn(array $location) => [
93-
'id' => $location['room'],
94-
'text' => $location['room']
93+
'id' => $location['location'],
94+
'text' => $location['location']
9595
], $locations);
9696
} elseif (!$this->isGranted('ROLE_JURY')) {
9797
throw new AccessDeniedHttpException('Permission denied');

webapp/src/Controller/Jury/TeamController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function indexAction(): Response
9393
'affiliation' => ['title' => 'affiliation', 'sort' => true,],
9494
'num_contests' => ['title' => '# contests', 'sort' => true,],
9595
'ip_address' => ['title' => 'last IP', 'sort' => true,],
96-
'room' => ['title' => 'room', 'sort' => true,],
96+
'location' => ['title' => 'location', 'sort' => true,],
9797
'status' => ['title' => '', 'sort' => false,],
9898
'stats' => ['title' => 'stats', 'sort' => true,],
9999
];

webapp/src/Controller/Team/MiscController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function printAction(Request $request): Response
184184
$teamId = (string)$team->getTeamid();
185185
}
186186
$ret = $this->dj->printFile($realfile, $originalfilename, $langid,
187-
$username, $team->getEffectiveName(), $teamId, $team->getRoom());
187+
$username, $team->getEffectiveName(), $teamId, $team->getLocation());
188188

189189
return $this->render('team/print_result.html.twig', [
190190
'success' => $ret[0],
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace App\DataFixtures\Test;
4+
5+
use App\Entity\Team;
6+
use Doctrine\Persistence\ObjectManager;
7+
8+
class AddLocationToTeamFixture extends AbstractTestDataFixture
9+
{
10+
public function load(ObjectManager $manager): void
11+
{
12+
$team = $manager->getRepository(Team::class)->findOneBy(['name' => 'Example teamname']);
13+
$team->setLocation('Utrecht');
14+
$manager->flush();
15+
}
16+
}

webapp/src/Entity/Team.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ class Team extends BaseApiEntity implements ExternalRelationshipEntityInterface,
8787
private ?string $publicDescription = null;
8888

8989
#[ORM\Column(nullable: true, options: ['comment' => 'Physical location of team'])]
90-
#[Serializer\Exclude]
91-
private ?string $room = null;
90+
#[OA\Property(nullable: true)]
91+
#[Serializer\Groups([ARC::GROUP_NONSTRICT])]
92+
private ?string $location = null;
9293

9394
#[ORM\Column(
9495
name: 'internalcomments',
@@ -285,15 +286,15 @@ public function getPublicDescription(): ?string
285286
return $this->publicDescription;
286287
}
287288

288-
public function setRoom(?string $room): Team
289+
public function setLocation(?string $location): Team
289290
{
290-
$this->room = $room;
291+
$this->location = $location;
291292
return $this;
292293
}
293294

294-
public function getRoom(): ?string
295+
public function getLocation(): ?string
295296
{
296-
return $this->room;
297+
return $this->location;
297298
}
298299

299300
public function setInternalComments(?string $comments): Team

0 commit comments

Comments
 (0)