Skip to content

Commit 928befb

Browse files
Change jury team pages to use external IDs instead of internal IDs
Part of #3024
1 parent dd0d6dd commit 928befb

File tree

6 files changed

+33
-45
lines changed

6 files changed

+33
-45
lines changed

webapp/src/Controller/Jury/RejudgingController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ public function createAction(Request $request): Response
705705
'language' => 'l.externalid',
706706
'problem' => 'p.externalid',
707707
'submission' => 's.externalid',
708-
'team' => 's.team',
708+
'team' => 't.externalid',
709709
'user' => 's.user',
710710
'rejudging' => 'j2.rejudging',
711711
];

webapp/src/Controller/Jury/TeamController.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ public function indexAction(): Response
9191
$teams_that_solved = array_column($teams_that_solved, 'num_correct', 'teamid');
9292

9393
$table_fields = [
94-
'teamid' => ['title' => 'ID', 'sort' => true, 'default_sort' => true],
95-
'externalid' => ['title' => 'external ID', 'sort' => true],
94+
'externalid' => ['title' => 'ID', 'sort' => true, 'default_sort' => true],
9695
'label' => ['title' => 'label', 'sort' => true,],
9796
'effective_name' => ['title' => 'name', 'sort' => true,],
9897
'category' => ['title' => 'category', 'sort' => true,],
@@ -120,7 +119,7 @@ public function indexAction(): Response
120119
$teamdata = [];
121120
$teamactions = [];
122121

123-
$this->addEntityCheckbox($teamdata, $t, $t->getTeamid(), 'team-checkbox', fn(Team $team) => !$team->isLocked());
122+
$this->addEntityCheckbox($teamdata, $t, $t->getExternalid(), 'team-checkbox', fn(Team $team) => !$team->isLocked());
124123

125124
// Get whatever fields we can from the team object itself.
126125
foreach ($table_fields as $k => $v) {
@@ -155,14 +154,14 @@ public function indexAction(): Response
155154
'icon' => 'edit',
156155
'title' => 'edit this team',
157156
'link' => $this->generateUrl('jury_team_edit', [
158-
'teamId' => $t->getTeamid(),
157+
'teamId' => $t->getExternalid(),
159158
]),
160159
];
161160
$teamactions[] = [
162161
'icon' => 'trash-alt',
163162
'title' => 'delete this team',
164163
'link' => $this->generateUrl('jury_team_delete', [
165-
'teamId' => $t->getTeamId(),
164+
'teamId' => $t->getExternalid(),
166165
]),
167166
'ajaxModal' => true,
168167
];
@@ -171,7 +170,7 @@ public function indexAction(): Response
171170
'icon' => 'envelope',
172171
'title' => 'send clarification to this team',
173172
'link' => $this->generateUrl('jury_clarification_new', [
174-
'teamto' => $t->getTeamId(),
173+
'teamto' => $t->getExternalid(),
175174
])
176175
];
177176

@@ -218,7 +217,7 @@ public function indexAction(): Response
218217
$teams_table[] = [
219218
'data' => $teamdata,
220219
'actions' => $teamactions,
221-
'link' => $this->generateUrl('jury_team', ['teamId' => $t->getTeamId()]),
220+
'link' => $this->generateUrl('jury_team', ['teamId' => $t->getExternalid()]),
222221
'cssclass' => ($t->getCategory() ? ("category" . $t->getCategory()->getCategoryId()) : '') .
223222
($t->getEnabled() ? '' : ' disabled'),
224223
];
@@ -325,10 +324,10 @@ public function viewAction(
325324
}
326325

327326
#[IsGranted('ROLE_ADMIN')]
328-
#[Route(path: '/{teamId<\d+>}/edit', name: 'jury_team_edit')]
329-
public function editAction(Request $request, int $teamId): Response
327+
#[Route(path: '/{teamId}/edit', name: 'jury_team_edit')]
328+
public function editAction(Request $request, string $teamId): Response
330329
{
331-
$team = $this->em->getRepository(Team::class)->find($teamId);
330+
$team = $this->em->getRepository(Team::class)->findByExternalId($teamId);
332331
if (!$team) {
333332
throw new NotFoundHttpException(sprintf('Team with ID %s not found', $teamId));
334333
}
@@ -341,7 +340,7 @@ public function editAction(Request $request, int $teamId): Response
341340
$this->possiblyAddUser($team);
342341
$this->assetUpdater->updateAssets($team);
343342
$this->saveEntity($team, $team->getTeamid(), false);
344-
return $this->redirectToRoute('jury_team', ['teamId' => $team->getTeamid()]);
343+
return $this->redirectToRoute('jury_team', ['teamId' => $team->getExternalid()]);
345344
}
346345

347346
return $this->render('jury/team_edit.html.twig', [
@@ -351,10 +350,10 @@ public function editAction(Request $request, int $teamId): Response
351350
}
352351

353352
#[IsGranted('ROLE_ADMIN')]
354-
#[Route(path: '/{teamId<\d+>}/delete', name: 'jury_team_delete')]
355-
public function deleteAction(Request $request, int $teamId): Response
353+
#[Route(path: '/{teamId}/delete', name: 'jury_team_delete')]
354+
public function deleteAction(Request $request, string $teamId): Response
356355
{
357-
$team = $this->em->getRepository(Team::class)->find($teamId);
356+
$team = $this->em->getRepository(Team::class)->findByExternalId($teamId);
358357
if (!$team) {
359358
throw new NotFoundHttpException(sprintf('Team with ID %s not found', $teamId));
360359
}
@@ -363,13 +362,13 @@ public function deleteAction(Request $request, int $teamId): Response
363362
}
364363

365364
#[IsGranted('ROLE_ADMIN')]
366-
#[Route(path: '/delete-multiple', name: 'jury_team_delete_multiple', methods: ['GET', 'POST'])]
365+
#[Route(path: '/delete-multiple', name: 'jury_team_delete_multiple', methods: ['GET', 'POST'], priority: 1)]
367366
public function deleteMultipleAction(Request $request): Response
368367
{
369368
return $this->deleteMultiple(
370369
$request,
371370
Team::class,
372-
'teamid',
371+
'externalid',
373372
'jury_teams',
374373
'No teams could be deleted (they might be in a locked contest).',
375374
fn(Team $team) => !$team->isLocked()
@@ -388,7 +387,7 @@ public function addAction(Request $request): Response
388387

389388
if ($response = $this->processAddFormForExternalIdEntity(
390389
$form, $team,
391-
fn() => $this->generateUrl('jury_team', ['teamId' => $team->getTeamid()]),
390+
fn() => $this->generateUrl('jury_team', ['teamId' => $team->getExternalid()]),
392391
function () use ($team) {
393392
$this->possiblyAddUser($team);
394393
$this->em->persist($team);

webapp/src/Form/Type/TeamType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
6767
]);
6868
$builder->add('category', EntityType::class, [
6969
'class' => TeamCategory::class,
70+
'choice_value' => 'externalid',
7071
]);
7172
$builder->add('publicdescription', TextareaType::class, [
7273
'label' => 'Public description',
@@ -76,6 +77,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
7677
'class' => TeamAffiliation::class,
7778
'required' => false,
7879
'choice_label' => 'name',
80+
'choice_value' => 'externalid',
7981
'placeholder' => '-- no affiliation --',
8082
'query_builder' => fn(EntityRepository $er) => $er->createQueryBuilder('a')->orderBy('a.name'),
8183
]);
@@ -97,6 +99,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
9799
'class' => Contest::class,
98100
'required' => false,
99101
'choice_label' => 'name',
102+
'choice_value' => 'externalid',
100103
'multiple' => true,
101104
'by_reference' => false,
102105
'query_builder' => fn(EntityRepository $er) => $er
@@ -132,6 +135,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
132135
'label' => "User",
133136
'required' => true,
134137
'choice_label' => 'name',
138+
'choice_value' => 'externalid',
135139
]);
136140
$builder->add('newUsername', TextType::class, [
137141
'label' => 'Username',

webapp/templates/jury/partials/team_score_and_submissions.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Submissions
99
{% if restrictionText %}
1010
<small class="text-muted">
11-
restricted to {{ restrictionText }} (<a href="{{ path('jury_team', {'teamId': team.teamid}) }}">show all</a>)
11+
restricted to {{ restrictionText }} (<a href="{{ path('jury_team', {'teamId': team.externalid}) }}">show all</a>)
1212
</small>
1313
{% endif %}
1414
</h2>

webapp/templates/jury/team.html.twig

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends "jury/base.html.twig" %}
22
{% import "jury/jury_macros.twig" as macros %}
33

4-
{% block title %}Team {{ team.teamid }} - {{ parent() }}{% endblock %}
4+
{% block title %}Team {{ team.externalid }} - {{ parent() }}{% endblock %}
55

66
{% block extrahead %}
77
{{ parent() }}
@@ -18,10 +18,6 @@
1818
<table class="table table-sm table-striped">
1919
<tr>
2020
<th>ID</th>
21-
<td>{{ team.teamid }}</td>
22-
</tr>
23-
<tr>
24-
<th>External ID</th>
2521
<td>{{ team.externalid }}</td>
2622
</tr>
2723
<tr>
@@ -94,10 +90,10 @@
9490
<th>User</th>
9591
<td>
9692
{% for user in team.users %}
97-
<a href="{{ path('jury_user', {'userId': user.userid}) }}">{{ user.username }}</a>
93+
<a href="{{ path('jury_user', {'userId': user.externalid}) }}">{{ user.username }}</a>
9894
{% else %}
9995
{%- if is_granted('ROLE_ADMIN') -%}
100-
<a href="{{ path('jury_user_add', {'team': team.teamid}) }}">
96+
<a href="{{ path('jury_user_add', {'team': team.externalid}) }}">
10197
<i class="fas fa-user-plus"></i> add user
10298
</a>
10399
{% endif %}
@@ -113,7 +109,7 @@
113109
<th>Category</th>
114110
<td>
115111
{% if team.category %}
116-
<a href="{{ path('jury_team_category', {'categoryId': team.category.categoryid}) }}">
112+
<a href="{{ path('jury_team_category', {'categoryId': team.category.externalid}) }}">
117113
{{ team.category.name }}
118114
</a>
119115
{% else %}
@@ -131,7 +127,7 @@
131127
<img src="{{ asset(affiliationLogo) }}" alt="{{ team.affiliation.shortname }}"
132128
title="{{ team.affiliation.shortname }}" class="affiliation-logo"/>
133129
{% endif %}
134-
<a href="{{ path('jury_team_affiliation', {'affilId': team.affiliation.affilid}) }}">
130+
<a href="{{ path('jury_team_affiliation', {'affilId': team.affiliation.externalid}) }}">
135131
{{ team.affiliation.name }}
136132
</a>
137133
</td>
@@ -150,7 +146,7 @@
150146
<th>Contests</th>
151147
<td>
152148
{% for ucontest in team.contests %}
153-
<a href="{{ path('jury_contest', {'contestId': ucontest.cid}) }}">{{ ucontest.shortname }}</a>
149+
<a href="{{ path('jury_contest', {'contestId': ucontest.externalid}) }}">{{ ucontest.shortname }}</a>
154150
{% endfor %}
155151
</td>
156152
</tr>
@@ -183,11 +179,11 @@
183179

184180
<div class="button-row">
185181
{%- if is_granted('ROLE_ADMIN') -%}
186-
{{ button(path('jury_team_edit', {'teamId': team.teamid}), 'Edit', 'primary', 'edit') }}
187-
{{ button(path('jury_team_delete', {'teamId': team.teamid}), 'Delete', 'danger', 'trash-alt', true) }}
182+
{{ button(path('jury_team_edit', {'teamId': team.externalid}), 'Edit', 'primary', 'edit') }}
183+
{{ button(path('jury_team_delete', {'teamId': team.externalid}), 'Delete', 'danger', 'trash-alt', true) }}
188184
{% endif %}
189-
{{ button(path('jury_clarification_new', {'teamto': team.teamid}), 'Send message', 'secondary', 'envelope') }}
190-
{% include 'jury/partials/rejudge_form.html.twig' with {table: 'team', id: team.teamid, buttonClass: 'btn-secondary'} %}
185+
{{ button(path('jury_clarification_new', {'teamto': team.externalid}), 'Send message', 'secondary', 'envelope') }}
186+
{% include 'jury/partials/rejudge_form.html.twig' with {table: 'team', id: team.externalid, buttonClass: 'btn-secondary'} %}
191187
</div>
192188

193189
<div data-ajax-refresh-target>
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends "jury/base.html.twig" %}
22
{% import "jury/jury_macros.twig" as macros %}
33

4-
{% block title %}Edit team {{ team.teamid }} - {{ parent() }}{% endblock %}
4+
{% block title %}Edit team {{ team.externalid }} - {{ parent() }}{% endblock %}
55

66
{% block extrahead %}
77
{{ parent() }}
@@ -12,17 +12,6 @@
1212

1313
<h1>Edit team {{ team.teamid }}</h1>
1414

15-
<div class="row">
16-
<div class="col-lg-4">
17-
<table class="table table-sm table-striped">
18-
<tr>
19-
<th>Team ID</th>
20-
<td>{{ team.teamid }}</td>
21-
</tr>
22-
</table>
23-
</div>
24-
</div>
25-
2615
{% include 'jury/partials/team_form.html.twig' %}
2716

2817
{% endblock %}

0 commit comments

Comments
 (0)