Skip to content

Commit

Permalink
Merge pull request #516 from H2-invent/hotfix/showing-sheduling-users…
Browse files Browse the repository at this point in the history
…-not-voting

* now the participants not selected any date will be shown but with s…
  • Loading branch information
holzi1005 authored Mar 14, 2024
2 parents 364ed37 + 68c8044 commit a559c2c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
18 changes: 15 additions & 3 deletions src/Controller/ScheduleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,11 @@ private function validateVote(int $vote, bool $allowMaybe): bool
#[Route(path: 'schedule/download/csv/{id}', name: 'schedule_download_csv', methods: ['GET'])]
public function generateVoteCsv(
Rooms $room

): Response
{
$votingsAndTimes = $this->getUserVotes($room);

$user = $room->getUser();
if (!isset($votingsAndTimes['times']) || count($votingsAndTimes['times']) === 0) {
$this->addFlash('danger', $this->translator->trans('error.scheduler.noSchedules'));

Expand All @@ -416,7 +417,6 @@ public function generateVoteCsv(
preg_replace('/[[:^print:]]/', '', $room->getName()) . '-' . (new DateTime())->format('d-m-Y_H-i') . '.csv',
)
);

return $response;
}

Expand All @@ -433,7 +433,19 @@ private function getVoteString(int $vote): ?string
private function getUserVotes(Rooms $room): array
{
$votings = [];
foreach ($room->getUser() as $user) {
$userId = $user->getId();
$name = implode(' ', [$user->getFirstName(), $user->getLastName()]);

// Füge den Nutzer zum Array hinzu, wenn er noch nicht erfasst wurde
if (!isset($votings['user'][$userId])) {
$votings['user'][$userId] = [
'Name' => $name,
'Email' => $user->getEmail(),
];

}
}
foreach ($room->getSchedulings() as $scheduling) {
foreach ($scheduling->getSchedulingTimes() as $schedulingTime) {
$schedulingTimeString = $schedulingTime->getTime()->format('d-m-Y H:i:s');
Expand Down Expand Up @@ -474,7 +486,7 @@ private function fillAllVotings(array $userVotings, array $times): array
if (isset($userVoting[$time])) {
$filledUpVoting[$time] = $userVoting[$time];
} else {
$filledUpVoting[$time] = 'null';
$filledUpVoting[$time] = '----';
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Controller/ScheduleControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ public function testGenerateVoteCsv(): void
$actualResponse = $this->subject->generateVoteCsv($room);

$expected = 'Name;Email;'. $dateTime2->format('d-m-Y H:i:s') .';' .$dateTime1->format('d-m-Y H:i:s');
$expected .= PHP_EOL . 'user1 test1;email1;null;Ja' . PHP_EOL . 'user2 test2;email2;Unter Vorbehalt;Nein' . PHP_EOL;
$expected .= 'user3 test3;email3;Unter Vorbehalt;null';
$expected .= PHP_EOL . 'user1 test1;email1;----;Ja' . PHP_EOL . 'user2 test2;email2;Unter Vorbehalt;Nein' . PHP_EOL;
$expected .= 'user3 test3;email3;Unter Vorbehalt;----';

$this->assertEquals($expected, $actualResponse->getContent());
}
Expand Down
8 changes: 2 additions & 6 deletions translations/messages+intl-icu.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1409,11 +1409,11 @@
</trans-unit>
<trans-unit id="FS5GaQX" resname="addParticipants.lobbyModerator.add">
<source>addParticipants.lobbyModerator.add</source>
<target>Wollen Sie den Teilnehmenden als Lobymoderator hinzufügen?</target>
<target>Wollen Sie den Teilnehmenden als Lobbymoderator hinzufügen?</target>
</trans-unit>
<trans-unit id="Bwt9pET" resname="addParticipants.lobbyModerator.remove">
<source>addParticipants.lobbyModerator.remove</source>
<target>Wollen Sie den Teilnehmenden als Lobymoderator entfernen?</target>
<target>Wollen Sie den Teilnehmenden als Lobbymoderator entfernen?</target>
</trans-unit>
<trans-unit id="0ZGJDsh" resname="openRoom.addParticipants.help">
<source>openRoom.addParticipants.help</source>
Expand Down Expand Up @@ -2074,10 +2074,6 @@
<source>Bewertungen</source>
<target>Bewertungen</target>
</trans-unit>
<trans-unit id="47DEQpj" resname="">
<source></source>
<target>__</target>
</trans-unit>
<trans-unit id="kKLiefR" resname="Profileinstellungen">
<source>Profileinstellungen</source>
<target>Profileinstellungen</target>
Expand Down

0 comments on commit a559c2c

Please sign in to comment.