Skip to content

Commit

Permalink
Merge pull request #187 from H2-invent/feature/fix-release
Browse files Browse the repository at this point in the history
Feature/fix release
  • Loading branch information
holema authored Jun 6, 2023
2 parents 7244ef9 + b1e5bd8 commit 686c834
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ yarn-error.log
docker.conf

/documentation_jitsi_admin/node_modules/
/secretStorage/.Halite*
12 changes: 6 additions & 6 deletions BranchPipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ echo --------------Schutdown Apache------------------------------------------
echo --------------------------------------------------------------------------
echo ---------------Git pull--------------------------------------------------
echo --------------------------------------------------------------------------
git add .
git stash
git reset --hard
git pull

mv .Halite.key ./secretStorage/.Halite.key
echo ------------Update parameter.yml and install latest packages-------------
php composer.phar install
echo --------------------------------------------------------------------------
echo ----------------Update Database-------------------------------------------
echo --------------------------------------------------------------------------
php bin/console cache:clear
php bin/console doc:mig:mig -y
php bin/console doc:mig:mig -n
php bin/console app:system:repair
echo --------------------------------------------------------------------------
echo -----------------Clear Cache----------------------------------------------
echo --------------------------------------------------------------------------
Expand Down Expand Up @@ -41,9 +41,9 @@ echo -----------------------Install NPM and Assets----------------------------
echo --------------------------------------------------------------------------
npm install
npm run build
rm -r node_modules
echo --------------------------------------------------------------------------
echo -----------------Security Check----------------------------------------------
echo ---------------------Sucessfully installed or updated---------------------
echo --------------------------------------------------------------------------
php security-checker.phar security:check composer.lock


4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ RUN rm -rf node_modules/
#copy all the rest of the app
COPY . /var/www/html
#install all php dependencies
USER docker
RUN composer install
USER root
#do all the directory stuff
RUN chmod -R 775 public/build
RUN mkdir -p var/cache
RUN chown -R www-data:www-data var
RUN chown -R docker:docker var
RUN chmod -R 777 var
USER docker
2 changes: 1 addition & 1 deletion config/packages/encrypt.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ambta_doctrine_encrypt:
encryptor_class: Halite
secret_directory_path: '%kernel.project_dir%' # Default value
secret_directory_path: '%kernel.project_dir%/secretStorage' # Default value
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ services:
- "traefik.http.services.app-odc.loadbalancer.sticky.cookie.secure=true"
volumes:
- datenschutzcenter_uploads:/var/www/html/public/uploads:rw
- datenschutzcenter_secret_storage:/var/www/html/public/uploads:rw
- datenschutzcenter_data:/var/www/html/public/data:rw
- $PWD/dockerupdate.sh:/etc/container/startup.sh

Expand Down Expand Up @@ -155,3 +156,4 @@ volumes:
image_upload:
datenschutzcenter_uploads:
datenschutzcenter_data:
datenschutzcenter_secret_storage:
2 changes: 2 additions & 0 deletions secretStorage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This directory is used to store the Encryption KEy
Don't add any files in this directory. This is done by the installation script.
10 changes: 5 additions & 5 deletions src/Controller/BerichtController.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function reportDataTransfer(
$team = $currentTeamService->getTeamFromSession($this->getUser());

if ($id) {
$daten = $dataTransferRepository->find($id);
$daten = $dataTransferRepository->findBy(['id'=>$id]);
} else {
$daten = $dataTransferRepository->findBy([
'team' => $team,
Expand Down Expand Up @@ -447,7 +447,7 @@ public function reportIncident(
$team = $currentTeamService->getTeamFromSession($this->getUser());

if ($id) {
$daten = $vorfallRepository->find($id);
$daten = $vorfallRepository->findBy(['id'=>$id]);
} else {
$daten = $vorfallRepository->findBy(['team' => $team, 'activ' => true], ['datum' => 'DESC']);
}
Expand Down Expand Up @@ -489,7 +489,7 @@ public function reportPolicy(
$team = $currentTeamService->getTeamFromSession($this->getUser());

if ($id) {
$policies = $policiesRepository->find($id);
$policies = $policiesRepository->findBy(['id'=>$id]);
} else {
$policies = $policiesRepository->findBy(['team' => $team, 'activ' => true], ['createdAt' => 'DESC']);
}
Expand Down Expand Up @@ -532,7 +532,7 @@ public function reportRequest(
$team = $currentTeamService->getTeamFromSession($this->getUser());

if ($id) {
$clientRequest = $clientRequestRepository->find($id);
$clientRequest = $clientRequestRepository->findBy(['id'=>$id]);
$title = $this->translator->trans(id: 'report.about.clientRequestBy', domain: 'bericht') . ' ' . $clientRequest->getName();
} else {
$clientRequest = $clientRequestRepository->findBy(['team' => $team, 'activ' => true], ['createdAt' => 'DESC']);
Expand Down Expand Up @@ -573,7 +573,7 @@ public function reportSoftware(
$team = $currentTeamService->getTeamFromSession($this->getUser());

if ($id) {
$software = $softwareRepository->find($id);
$software = $softwareRepository->findBy(['id'=>$id]);
} else {
$software = $softwareRepository->findBy(['team' => $team, 'activ' => true], ['createdAt' => 'DESC']);
}
Expand Down
1 change: 1 addition & 0 deletions src/Controller/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function dashboard(Request $request,
} elseif (count($this->getUser()->getTeamDsb()) > 0) {
return $this->redirectToRoute('dsb');
} else {

return $this->redirectToRoute('no_team');
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function create(
$em->persist($nTeam);
$em->persist($user);
$em->flush();
return $this->redirectToRoute('manage_teams');
return $this->redirectToRoute('team_edit',['id'=>$nTeam->getId()]);
}
}

Expand Down
31 changes: 31 additions & 0 deletions src/Service/CronService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
namespace App\Service;


use App\Entity\AkademieBuchungen;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;


class CronService
Expand All @@ -22,6 +24,8 @@ public function __construct(
FormFactoryInterface $formBuilder,
private LoggerInterface $logger,
private TranslatorInterface $translator,
private NotificationService $notificationService,
private Environment $environment,
)
{
}
Expand Down Expand Up @@ -52,4 +56,31 @@ function check($request)

return $message;
}

public function sendEmailsForAcademy()
{
$today = new \DateTime();
$buchungen = $this->em->getRepository(AkademieBuchungen::class)->findOffenByDate($today);


$countNeu = 0;
$countWdh = 0;

// TODO: How should users with multiple teams be handled?
foreach ($buchungen as $buchung) {
if (!$buchung->getInvitation()) {
$content = $this->environment->render('email/neuerKurs.html.twig', ['buchung' => $buchung, 'team' => $buchung->getUser()->getTeams()->get(0)]);
$buchung->setInvitation(true);
$em->persist($buchung);
++$countNeu;
} else {
$content = $this->environment->render('email/errinnerungKurs.html.twig', ['buchung' => $buchung, 'team' => $buchung->getUser()->getTeams()->get(0)]);
++$countWdh;
}
$this->notificationService->sendNotificationAkademie($buchung, $content);
}
$this->em->flush();
$message = ['error' => false, 'hinweis' => 'Email mit Benachrichtigung zu offenen Kursen in der Akademie verschickt', 'neu' => $countNeu, 'wdh' => $countWdh];
return $message;
}
}
17 changes: 8 additions & 9 deletions src/Service/CurrentTeamService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ public function getCurrentAdminTeam(User $user): ?Team

public function getTeamFromSession(User $user): ?Team
{
$team = $this->findTeam($user->getTeams());
if (!$team){
if (count($user->getTeams()->toArray())>0){
$team = $user->getTeams()[0];
$this->switchToTeam($team);
}
}
return $team;

return $this->findTeam($user->getTeams());
}

public function switchToTeam(string $team): void
Expand All @@ -51,6 +45,11 @@ private function findTeam(Collection $teams): ?Team
}
}
}
return $teams->get(0);
if (count($teams) === 0){
return null;
}
$team = $teams->get(0);
$this->switchToTeam($team);
return $team;
}
}

0 comments on commit 686c834

Please sign in to comment.