Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes related to import. #2173

Merged
merged 3 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion misc-tools/import-contest.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def import_images(entity: str, property: str, filename_regexes: List[str]):
if not os.path.isdir(entity):
return
images_per_entity = {}
for entity_id in listdir(entity):
with open(f'{entity}.json') as entityFile:
entities = json.load(entityFile)
entity_ids = [entity['id'] for entity in entities]
for entity_id in entity_ids:
entity_dir = f'{entity}/{entity_id}'
if not os.path.isdir(entity_dir):
continue
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Controller/API/OrganizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function singleAction(Request $request, string $id): Response
* Get the logo for the given organization.
*/
#[Rest\Get('contests/{cid}/organizations/{id}/logo', name: 'organization_logo')]
#[Rest\Get('organizations/{id}/logo')]
#[Rest\Get('organizations/{id}/logo', name: 'no_contest_organization_logo')]
#[OA\Response(
response: 200,
description: 'Returns the given organization logo in PNG, JPG or SVG format',
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Controller/API/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function singleAction(Request $request, string $id): Response
* Get the photo for the given team.
*/
#[Rest\Get('contests/{cid}/teams/{id}/photo', name: 'team_photo')]
#[Rest\Get('teams/{id}/photo')]
#[Rest\Get('teams/{id}/photo', name: 'no_contest_team_photo')]
#[OA\Response(
response: 200,
description: 'Returns the given team photo in PNG, JPG or SVG format',
Expand Down
18 changes: 11 additions & 7 deletions webapp/src/Serializer/TeamAffiliationVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,17 @@ public function onPostSerialize(ObjectEvent $event): void
$parts = explode('.', $affiliationLogo);
$extension = $parts[count($parts) - 1];

$route = $this->dj->apiRelativeUrl(
'v4_organization_logo',
[
'cid' => $this->requestStack->getCurrentRequest()->attributes->get('cid'),
'id' => $id,
]
);
if ($cid = $this->requestStack->getCurrentRequest()->attributes->get('cid')) {
$route = $this->dj->apiRelativeUrl(
'v4_organization_logo',
[
'cid' => $cid,
'id' => $id,
]
);
} else {
$route = $this->dj->apiRelativeUrl('v4_no_contest_organization_logo', ['id' => $id]);
}
$property = new StaticPropertyMetadata(
TeamAffiliation::class,
'logo',
Expand Down
18 changes: 11 additions & 7 deletions webapp/src/Serializer/TeamVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,17 @@ public function onPostSerialize(ObjectEvent $event): void

$imageSize = Utils::getImageSize($teamPhoto);

$route = $this->dj->apiRelativeUrl(
'v4_team_photo',
[
'cid' => $this->requestStack->getCurrentRequest()->attributes->get('cid'),
'id' => $id,
]
);
if ($cid = $this->requestStack->getCurrentRequest()->attributes->get('cid')) {
$route = $this->dj->apiRelativeUrl(
'v4_team_photo',
[
'cid' => $cid,
'id' => $id,
]
);
} else {
$route = $this->dj->apiRelativeUrl('v4_no_contest_team_photo', ['id' => $id,]);
}
$property = new StaticPropertyMetadata(
Team::class,
'photo',
Expand Down
8 changes: 7 additions & 1 deletion webapp/src/Service/DOMJudgeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,13 @@ public function internalApiRequest(string $url, string $method = Request::METHOD
return null;
}

return $this->jsonDecode($response->getContent());
$content = $response->getContent();

if ($content === '') {
return null;
meisterT marked this conversation as resolved.
Show resolved Hide resolved
}

return $this->jsonDecode($content);
}

public function getDomjudgeEtcDir(): string
Expand Down
Loading