diff --git a/doc/manual/import.rst b/doc/manual/import.rst index 11878e11db..2b685943b4 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 -- ``location`` (optional): the location of the team +- ``location.description`` (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", - "location": "AUD 10" + "location": {"description": "AUD 10"} }, { "id": "2", "icpc_id": "447837", diff --git a/webapp/src/Entity/Team.php b/webapp/src/Entity/Team.php index 73c749f47e..1de127be10 100644 --- a/webapp/src/Entity/Team.php +++ b/webapp/src/Entity/Team.php @@ -3,6 +3,7 @@ namespace App\Entity; use App\Controller\API\AbstractRestController as ARC; +use App\Helpers\TeamLocation; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; @@ -88,7 +89,7 @@ class Team extends BaseApiEntity implements ExternalRelationshipEntityInterface, #[ORM\Column(nullable: true, options: ['comment' => 'Physical location of team'])] #[OA\Property(nullable: true)] - #[Serializer\Groups([ARC::GROUP_NONSTRICT])] + #[Serializer\Exclude] private ?string $location = null; #[ORM\Column( @@ -297,6 +298,14 @@ public function getLocation(): ?string return $this->location; } + #[Serializer\Groups([ARC::GROUP_NONSTRICT])] + #[Serializer\VirtualProperty] + #[Serializer\SerializedName('location')] + public function getLocationForApi(): ?TeamLocation + { + return $this->location ? new TeamLocation($this->location) : null; + } + public function setInternalComments(?string $comments): Team { $this->internalComments = $comments; diff --git a/webapp/src/Helpers/TeamLocation.php b/webapp/src/Helpers/TeamLocation.php new file mode 100644 index 0000000000..ee0120ec96 --- /dev/null +++ b/webapp/src/Helpers/TeamLocation.php @@ -0,0 +1,10 @@ + @$team['name'], 'display_name' => @$team['display_name'], 'publicdescription' => $team['public_description'] ?? @$team['members'], - 'location' => @$team['location'], + 'location' => @$team['location']['description'], ], 'team_affiliation' => [ 'externalid' => $team['organization_id'] ?? null, diff --git a/webapp/tests/Unit/Controller/API/TeamControllerTest.php b/webapp/tests/Unit/Controller/API/TeamControllerTest.php index f172607e99..c84171f6cb 100644 --- a/webapp/tests/Unit/Controller/API/TeamControllerTest.php +++ b/webapp/tests/Unit/Controller/API/TeamControllerTest.php @@ -22,7 +22,7 @@ class TeamControllerTest extends BaseTestCase 'display_name' => null, 'members' => null, 'photo' => null, - 'location' => 'Utrecht', + 'location' => ['description' => 'Utrecht'], ], ]; diff --git a/webapp/tests/Unit/Service/ImportExportServiceTest.php b/webapp/tests/Unit/Service/ImportExportServiceTest.php index 550e5c5a4c..1794fa5f02 100644 --- a/webapp/tests/Unit/Service/ImportExportServiceTest.php +++ b/webapp/tests/Unit/Service/ImportExportServiceTest.php @@ -697,7 +697,7 @@ public function testImportTeamsJson(): void "group_ids": ["24"], "name": "¡i¡i¡", "organization_id": "INST-42", - "location": "AUD 10" + "location": {"description": "AUD 10"} }, { "id": "12", "icpc_id": "447837",