Skip to content

Commit

Permalink
Fix history access
Browse files Browse the repository at this point in the history
fix #301
  • Loading branch information
melegiul committed Jan 17, 2025
1 parent 2b6ce5f commit 433864e
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/Controller/DatenweitergabeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function editDatenweitergabe(
}

$newDaten = $datenweitergabeService->cloneDatenweitergabe($daten, $this->getUser());
$isEditable = $daten->getTeam() === $team;
$isEditable = $daten->getTeam() === $team && $daten->getActiv() === 1;
$form = $datenweitergabeService->createForm($newDaten, $team, ['disabled' => !$isEditable]);
$form->remove('nummer');
$form->handleRequest($request);
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/PoliciesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function editPolicy(
return $this->redirectToRoute('policies');
}
$newPolicy = $policiesService->clonePolicy($policy, $this->getUser());
$isEditable = $policy->getTeam() === $team;
$isEditable = $policy->getTeam() === $team && $policy->getActiv() === 1;
$form = $policiesService->createForm($newPolicy, $team, ['disabled' => !$isEditable]);
$form->handleRequest($request);
$assign = $assignService->createForm($policy, $team, ['disabled' => !$isEditable]);
Expand Down Expand Up @@ -239,7 +239,7 @@ public function index(
return $this->redirectToRoute('dashboard');
}

$policies = $policiesRepository->findAllByTeam($team);
$policies = $policiesRepository->findActiveByTeam($team);

return $this->render('policies/index.html.twig', [
'data' => $policies,
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/SoftwareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function editSoftware(
return $this->redirectToRoute('software');
}
$newSoftware = $softwareService->cloneSoftware($software, $this->getUser());
$isEditable = $software->getTeam() === $team;
$isEditable = $software->getTeam() === $team && $software->getActiv() === true;
$form = $softwareService->createForm($newSoftware, $team, ['disabled' => !$isEditable]);
$form->handleRequest($request);
$assign = $assignService->createForm($software, $team, ['disabled' => !$isEditable]);
Expand Down Expand Up @@ -301,7 +301,7 @@ public function index(
if ($securityService->teamCheck($team) === false) {
return $this->redirectToRoute('dashboard');
}
$software = $softwareRepository->findAllByTeam($team);
$software = $softwareRepository->findActiveByTeam($team);

return $this->render('software/index.html.twig', [
'data' => $software,
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/TomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function editTom(

$newTom = $tomService->cloneTom($tom, $this->getUser());

$isEditable = $tom->getTeam() === $team;
$isEditable = $tom->getTeam() === $team && $tom->getActiv() === 1;
$form = $this->createForm(TomType::class, $newTom, ['disabled' => !$isEditable]);
$form->remove('titel');
$form->handleRequest($request);
Expand Down Expand Up @@ -226,7 +226,7 @@ public function index(
return $this->redirectToRoute('dashboard');
}

$tom = $tomRepository->findAllByTeam($team);
$tom = $tomRepository->findActiveByTeam($team);

return $this->render('tom/index.html.twig', [
'tom' => $tom,
Expand Down
6 changes: 4 additions & 2 deletions src/Repository/DatenweitergabeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function __construct(
public function findActiveByTeam(Team $team)
{
$queryBuilder = $this->getBaseQueryBuilder($team);
$queryBuilder->andWhere('a.activ = 1');
return $queryBuilder->getQuery()->getResult();
}

Expand All @@ -45,7 +46,8 @@ public function findAllByTeam(Team $team)
public function findActiveTransfersByTeam(Team $team): mixed
{
$queryBuilder = $this->getBaseQueryBuilder(team: $team);
$queryBuilder->andWhere('a.art = 1');
$queryBuilder->andWhere('a.art = 1')
->andWhere('a.activ = 1');
return $queryBuilder->getQuery()->getResult();
}

Expand Down Expand Up @@ -81,6 +83,7 @@ public function findActiveByTeamAndUser(Team $team, User $user)
$queryBuilder
->andWhere('a.assignedUser = :user')
->setParameter('user', $user)
->andWhere('a.activ = 1')
;
return $queryBuilder->getQuery()->getResult();
}
Expand All @@ -92,7 +95,6 @@ private function getBaseQueryBuilder(Team $team, bool $all = false) :QueryBuilde
$queryBuilder = $this->createQueryBuilder('a')
->leftJoin('a.verfahren', 'process')
->andWhere('a.team = :team OR process.inherited = 1 AND process.activ = 1 AND process.team IN (:teamPath)')
->andWhere('a.activ = 1')
->setParameter('teamPath', $teamPath)
->setParameter('team', $team)
->orderBy('a.createdAt', 'DESC')
Expand Down
3 changes: 2 additions & 1 deletion src/Repository/PoliciesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function __construct(
public function findActiveByTeam(Team $team)
{
$queryBuilder = $this->getBaseQueryBuilder(team: $team);
$queryBuilder->andWhere('a.activ = 1');
$this->excludeIgnored(team: $team, queryBuilder: $queryBuilder);
return $queryBuilder->getQuery()->getResult();
}
Expand All @@ -48,6 +49,7 @@ public function findPublicByTeam(Team $team)
public function findActiveByTeamAndUser($team, $user)
{
$queryBuilder = $this->getBaseQueryBuilder(team: $team);
$queryBuilder->andWhere('a.activ = 1');
$this->excludeIgnored(team: $team, queryBuilder: $queryBuilder);
$queryBuilder
->andWhere('a.assignedUser = :user')
Expand All @@ -73,7 +75,6 @@ private function getBaseQueryBuilder(Team $team) :QueryBuilder
return $this->createQueryBuilder('a')
->leftJoin('a.processes', 'process')
->andWhere('a.team = :team OR process.inherited = 1 AND process.activ = 1 AND process.team IN (:teamPath)')
->andWhere('a.activ = 1')
->setParameter('teamPath', $teamPath)
->setParameter('team', $team)
->orderBy('a.createdAt', 'DESC')
Expand Down
3 changes: 2 additions & 1 deletion src/Repository/SoftwareRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ public function __construct(
public function findActiveByTeam(Team $team)
{
$queryBuilder = $this->getBaseQueryBuilder();
$queryBuilder->andWhere('sw.activ = 1');
$this->filterByTeam(queryBuilder: $queryBuilder, team: $team);
return $queryBuilder->getQuery()->getResult();
}

public function findActiveByTeamAndUser($team, $user)
{
$queryBuilder = $this->getBaseQueryBuilder();
$queryBuilder->andWhere('sw.activ = 1');
$this->filterByTeam(queryBuilder: $queryBuilder, team: $team);
$this->filterByUser(queryBuilder: $queryBuilder, user: $user);
return $queryBuilder->getQuery()->getResult();
Expand Down Expand Up @@ -73,7 +75,6 @@ private function getBaseQueryBuilder() :QueryBuilder
->leftJoin('sw.vvts', 'sp')
->leftJoin('sw.datenweitergabe', 'dw')
->leftJoin('dw.verfahren', 'dp')
->andWhere('sw.activ = 1')
;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Repository/TomRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function __construct(
public function findActiveByTeam(Team $team)
{
$queryBuilder = $this->getBaseQueryBuilder($team);
$queryBuilder->andWhere('a.activ = 1');
$this->excludeIgnored($team, $queryBuilder);
return $queryBuilder->getQuery()->getResult();
}
Expand Down Expand Up @@ -54,7 +55,6 @@ private function getBaseQueryBuilder(Team $team) :QueryBuilder
return $this->createQueryBuilder('a')
->leftJoin('a.vvts', 'process')
->andWhere('a.team = :team OR process.inherited = 1 AND process.activ = 1 AND process.team IN (:teamPath)')
->andWhere('a.activ = 1')
->setParameter('teamPath', $teamPath)
->setParameter('team', $team)
->orderBy('a.createdAt', 'DESC')
Expand Down
9 changes: 2 additions & 7 deletions src/Service/SoftwareService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,8 @@ public function createConfigForm(SoftwareConfig $softwareConfig): FormInterface

public function createForm(Software $software, Team $team, array $options = []): FormInterface
{
if (array_key_exists('disabled', $options) && $options['disabled']) {
$processes = $this->processRepository->findAllByTeam($team);
$transfers = $this->transferRepository->findAllByTeam($team);
} else {
$processes = $this->processRepository->findActiveByTeam($team);
$transfers = $this->transferRepository->findActiveByTeam($team);
}
$processes = $this->processRepository->findActiveByTeam($team);
$transfers = $this->transferRepository->findActiveByTeam($team);

return $this->formBuilder->create(SoftwareType::class, $software, array_merge([
'processes' => $processes,
Expand Down
12 changes: 3 additions & 9 deletions src/Service/VVTService.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,9 @@ function cloneVvt(VVT $vvt, User $user)

function createForm(VVT $VVT, Team $team, array $options = []): FormInterface
{
if (array_key_exists('disabled', $options) && $options['disabled']) {
$tom = $this->tomRepository->findAllByTeam($team);
$software = $this->softwareRepository->findAllByTeam($team);
$transfers = $this->transferRepository->findAllByTeam($team);
} else {
$tom = $this->tomRepository->findActiveByTeam($team);
$software = $this->softwareRepository->findActiveByTeam($team);
$transfers = $this->transferRepository->findActiveByTeam($team);
}
$tom = $this->tomRepository->findActiveByTeam($team);
$software = $this->softwareRepository->findActiveByTeam($team);
$transfers = $this->transferRepository->findActiveByTeam($team);

$statuses = $this->processStatusRepository->findActiveByTeam($team);
$people = $this->processPeopleRepository->findActiveByTeam($team);
Expand Down

0 comments on commit 433864e

Please sign in to comment.