Skip to content

Commit

Permalink
Use admin as advanced jury user
Browse files Browse the repository at this point in the history
This now adds the team role so admins can make submissions
  • Loading branch information
vmcj committed May 27, 2022
1 parent c1e7a5d commit af7ca3d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
12 changes: 8 additions & 4 deletions webapp/src/Service/ImportExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -851,10 +851,12 @@ public function importAccountsJson(array $data, ?string &$message = null, ?array
switch ($account['type']) {
case 'admin':
$roles[] = $adminRole;
break;
// Don't break so we can also add the jury features
case 'jury': // We don't break to let non existing role jury be interpret as role judge
case 'judge':
$roles[] = $juryRole;
if ($account['type'] !== 'admin') {
$roles[] = $juryRole;
}
$roles[] = $teamRole;
$juryTeam = [
'name' => $account['name'] ?? $account['username'],
Expand Down Expand Up @@ -1159,10 +1161,12 @@ protected function importAccountsTsv(array $content, ?string &$message = null):
switch ($line[0]) {
case 'admin':
$roles[] = $adminRole;
break;
// Don't break so we can also add the jury features
case 'jury': // We don't break to let non existing role jury be interpret as role judge
case 'judge':
$roles[] = $juryRole;
if ($line[0] !== 'admin') {
$roles[] = $juryRole;
}
$roles[] = $teamRole;
$juryTeam = ['name' => $line[1], 'externalid' => $line[2], 'category' => $juryCategory, 'publicdescription' => $line[1]];
break;
Expand Down
14 changes: 12 additions & 2 deletions webapp/tests/Unit/Service/ImportExportServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,16 +504,26 @@ protected function testImportAccounts(int $importCount, ?string $message, bool $
],
],
[
'roles' => ['admin'],
'roles' => ['admin','team'],
'name' => 'Some admin',
'username' => 'adminx',
'password' => 'password7',
'team' => [
'name' => 'Some admin',
'category' => 'Jury',
'members' => 'Some admin',
],
],
[
'roles' => ['admin'],
'roles' => ['admin','team'],
'name' => 'Another admin',
'username' => 'adminy',
'password' => 'password8',
'team' => [
'name' => 'Another admin',
'category' => 'Jury',
'members' => 'Another admin',
],
],
[
'roles' => ['balloon'],
Expand Down

0 comments on commit af7ca3d

Please sign in to comment.