Skip to content

Commit dc0d05b

Browse files
committed
Add new API role for problem upload
This is for an usecase like EUC where there is an Ad-Hoc group which doesn't know each other yet (or even the system). The responsibility for the upload of the problems lies with one team which does not want admin access to make sure nothing gets broken.
1 parent b404383 commit dc0d05b

File tree

2 files changed

+53
-9
lines changed

2 files changed

+53
-9
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
final class Version20240629154640 extends AbstractMigration
11+
{
12+
private const NEW_ROLES = ['api_problem_change' => 'API Problem Changer'];
13+
14+
public function getDescription(): string
15+
{
16+
return 'Add new roles to the database.';
17+
}
18+
19+
public function up(Schema $schema): void
20+
{
21+
foreach(self::NEW_ROLES as $role => $description) {
22+
$existingRole = $this->connection->fetchAssociative('SELECT * FROM role WHERE role = :role', ['role' => $role]);
23+
if (!$existingRole) {
24+
$this->addSql(
25+
'INSERT INTO role (`role`, `description`) VALUES (:role, :desc)',
26+
['role' => $role, 'desc' => $description]
27+
);
28+
}
29+
}
30+
}
31+
32+
public function down(Schema $schema): void
33+
{
34+
foreach(array_keys(self::NEW_ROLES) as $role) {
35+
$this->addSql('DELETE FROM role WHERE role = ' . $role );
36+
}
37+
}
38+
39+
public function isTransactional(): bool
40+
{
41+
return false;
42+
}
43+
}

webapp/src/DataFixtures/DefaultData/RoleFixture.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ public function load(ObjectManager $manager): void
2020
{
2121
// Mapping from role to description
2222
$roles = [
23-
'admin' => 'Administrative User',
24-
'jury' => 'Jury User',
25-
'team' => 'Team Member',
26-
'balloon' => 'Balloon runner',
27-
'judgehost' => '(Internal/System) Judgehost',
28-
'api_reader' => 'API reader',
29-
'api_writer' => 'API writer',
30-
'api_source_reader' => 'Source code reader',
31-
'clarification_rw' => 'Clarification handler',
23+
'admin' => 'Administrative User',
24+
'jury' => 'Jury User',
25+
'team' => 'Team Member',
26+
'balloon' => 'Balloon runner',
27+
'judgehost' => '(Internal/System) Judgehost',
28+
'api_reader' => 'API reader',
29+
'api_writer' => 'API writer',
30+
'api_source_reader' => 'Source code reader',
31+
'clarification_rw' => 'Clarification handler',
32+
'api_problem_change' => 'API Problem Changer'
3233
];
3334
foreach ($roles as $roleName => $description) {
3435
if (!($role = $manager->getRepository(Role::class)->findOneBy(['dj_role' => $roleName]))) {

0 commit comments

Comments
 (0)