Skip to content

Commit

Permalink
Merge pull request #302 from H2-invent/hotfix/history
Browse files Browse the repository at this point in the history
Hotfix/history
  • Loading branch information
holzi1005 authored Feb 8, 2025
2 parents 0fa0a90 + 872aa1e commit f42cad4
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 110 deletions.
53 changes: 29 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
ARG PHP_IMAGE_VERSION=3.20.6
FROM git.h2-invent.com/public-system-design/alpine-php8-webserver:${PHP_IMAGE_VERSION}
FROM thecodingmachine/php:8.3-v4-fpm-node22 AS builder
ARG VERSION

COPY . /var/www/html

USER root

RUN npm install \
&& npm run build

RUN composer install --no-scripts

RUN sed -i "s/^laF_version=.*/laF_version=${VERSION}/" .env

RUN tar \
--exclude='./.github' \
--exclude='./.git' \
--exclude='./node_modules' \
--exclude='./var/cache' \
--exclude='./var/log' \
-zcvf /artifact.tgz .


FROM git.h2-invent.com/public-system-design/alpine-php8-cron-webserver:3.20.7
ARG VERSION
ARG SUPERCRONIC_VERSION=0.2.33

LABEL version="${VERSION}" \
Maintainer="H2 invent GmbH" \
Expand All @@ -18,26 +39,8 @@ LABEL version="${VERSION}" \

USER root

RUN apk --no-cache add \
unzip \
&& rm -rf /var/cache/apk/*

RUN mkdir /etc/service/cron \
&& echo "#!/bin/sh" > /etc/service/cron/run \
&& echo "exec 2>&1 /supercronic /var/crontab" >> /etc/service/cron/run \
&& chown -R nobody:nobody /etc/service/cron \
&& chmod -R +x /etc/service/cron

RUN wget https://github.com/aptible/supercronic/releases/download/v${SUPERCRONIC_VERSION}/supercronic-linux-amd64 -O /supercronic \
&& chmod +x /supercronic

RUN wget https://git.h2-invent.com/Public-System-Design/Public-Helperscripts/raw/branch/main/distributed_cron.sh -O /distributed_cron.sh \
&& chmod +x /distributed_cron.sh

RUN echo "# Docker Cron Jobs" > /var/crontab \
&& echo "SHELL=/bin/sh" >> /var/crontab \
&& echo "* * * * * date" >> /var/crontab \
&& echo "0 1 * * * curl https://open-datenschutzcenter.de/health/check" >> /var/crontab \
&& echo "0 9 * * 1-5 /bin/sh /distributed_cron.sh 'data/cron_log' 'php /var/www/html/bin/console app:cron'" >> /var/crontab \
&& echo "" >> /var/crontab

Expand All @@ -49,11 +52,13 @@ RUN echo "#!/bin/sh" > /docker-entrypoint-init.d/01-symfony.sh \

USER nobody

RUN wget https://github.com/H2-invent/open-datenschutzcenter/releases/download/${VERSION}/application.zip -O artifact.zip \
&& unzip artifact.zip \
COPY --from=builder /artifact.tgz artifact.tgz

RUN tar -zxvf artifact.tgz \
&& mkdir data \
&& rm -r var/cache \
&& rm artifact.zip
&& mkdir -p var/log \
&& mkdir -p var/cache \
&& rm artifact.tgz

ENV nginx_root_directory=/var/www/html/public \
upload_max_filesize=10M
6 changes: 3 additions & 3 deletions 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 Expand Up @@ -340,7 +340,7 @@ public function indexAuftragsverarbeitung(
return $this->redirectToRoute('dashboard');
}

$daten = $transferRepository->findAllOrderProcessingsByTeam($team);
$daten = $transferRepository->findActiveOrderProcessingsByTeam($team);
return $this->render('datenweitergabe/indexAuftragsverarbeitung.html.twig', [
'table' => $daten,
'title' => $this->translator->trans(id: 'orderProcessing.disclaimer', domain: 'datenweitergabe'),
Expand All @@ -360,7 +360,7 @@ public function indexDataTransfer(
return $this->redirectToRoute('dashboard');
}

$daten = $transferRepository->findAllTransfersByTeam($team);
$daten = $transferRepository->findActiveTransfersByTeam($team);
return $this->render('datenweitergabe/index.html.twig', [
'table' => $daten,
'title' => $this->translator->trans(id: 'dataTransfer.disclaimer', domain: 'datenweitergabe'),
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
7 changes: 5 additions & 2 deletions src/Controller/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ public function create(
{
$user = $this->getUser();

if ($securityService->superAdminCheck($user) === false) {
return $this->redirectToRoute('dashboard');
// Check for number of teams for initial team creation and after the first team, check if user is superAdmin
if (sizeof($teamRepository->findAll()) !== 0) {
if ($securityService->superAdminCheck($user) === false) {
return $this->redirectToRoute('dashboard');
}
}

$teams = $teamRepository->findAll();
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
2 changes: 1 addition & 1 deletion src/Controller/VorfallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function editVorfall(

$newVorgang = $vorfallService->cloneVorfall($vorgang, $this->getUser());

$form = $vorfallService->createForm($newVorgang, $team);
$form = $vorfallService->createForm($newVorgang, $team, ['disabled' => $vorgang->getActiv() !== true]);
$form->handleRequest($request);
$assign = $assignService->createForm($vorgang, $team);
$errors = array();
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/VvtController.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function editVvt(
$latestCategories[] = $latestCategory;
}

$isEditable = $vvt->getTeam() === $team;
$isEditable = $vvt->getTeam() === $team && $vvt->getActiv() === 1;
$form = $VVTService->createForm($newVvt, $team, ['disabled' => !$isEditable]);
$form->remove('nummer');
$form->handleRequest($request);
Expand Down
9 changes: 6 additions & 3 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 All @@ -64,7 +66,8 @@ public function findAllTransfersByTeam(Team $team): mixed
public function findActiveOrderProcessingsByTeam(Team $team): mixed
{
$queryBuilder = $this->getBaseQueryBuilder(team: $team);
$queryBuilder->andWhere('a.art = 2');
$queryBuilder->andWhere('a.art = 2')
->andWhere('a.activ = 1');
return $queryBuilder->getQuery()->getResult();
}

Expand All @@ -81,6 +84,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 +96,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
4 changes: 2 additions & 2 deletions src/Service/VorfallService.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ function cloneVorfall(Vorfall $input, User $user)
return $data;
}

function createForm(Vorfall $vorfall, Team $team)
function createForm(Vorfall $vorfall, Team $team, array $options = [])
{
$personen = $this->em->getRepository(VVTPersonen::class)->findActiveByTeam($team);
$kategorien = $this->em->getRepository(VVTDatenkategorie::class)->findByTeam($team);

$form = $this->formBuilder->create(VorfallType::class, $vorfall, ['personen' => $personen, 'daten' => $kategorien]);
$form = $this->formBuilder->create(VorfallType::class, $vorfall, array_merge(['personen' => $personen, 'daten' => $kategorien], $options));

return $form;
}
Expand Down
8 changes: 5 additions & 3 deletions templates/software/__config.html.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{% trans_default_domain 'software' %}
<div class="mb-5">
<a href="{{ path('software_config_new',{'id':software.id}) }}" class="btn">
{% trans %}config.create{% endtrans %}
</a>
{% if isEditable %}
<a href="{{ path('software_config_new',{'id':software.id}) }}" class="btn">
{% trans %}config.create{% endtrans %}
</a>
{% endif %}
<button class="btn" type="button" data-type="dialogs" data-target="#modal-software-config-info">
{% trans from 'general' %}info{% endtrans %}
</button>
Expand Down
Loading

0 comments on commit f42cad4

Please sign in to comment.