Skip to content

Commit

Permalink
Merge pull request #1972 from tomudding/fix/admin-signup-and-signoff-…
Browse files Browse the repository at this point in the history
…possible-outside-sign-up-list-being-open

fix(signup): admin (un)subscribe possible before sign-up list opens
  • Loading branch information
tomudding authored Jan 11, 2025
2 parents 7e289b5 + 1405d12 commit bfc2fd9
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 19 deletions.
6 changes: 3 additions & 3 deletions module/Activity/src/Controller/ActivityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function signupAction(): Response|ViewModel

// Ensure that the action is within the subscription window
if (
!$this->signupService->isInSubscriptionWindow($signupList->getOpenDate(), $signupList->getCloseDate())
!$signupList->isOpen()
|| ActivityModel::STATUS_APPROVED !== $signupList->getActivity()->getStatus()
) {
$error = $this->translator->translate('You cannot subscribe to this activity at this moment in time');
Expand Down Expand Up @@ -356,7 +356,7 @@ public function externalSignupAction(): Response|ViewModel

// Ensure that the action is within the subscription window
if (
!$this->signupService->isInSubscriptionWindow($signupList->getOpenDate(), $signupList->getCloseDate())
!$signupList->isOpen()
|| ActivityModel::STATUS_APPROVED !== $signupList->getActivity()->getStatus()
) {
$error = $this->translator->translate('You cannot subscribe to this activity at this moment in time');
Expand Down Expand Up @@ -417,7 +417,7 @@ public function signoffAction(): Response|ViewModel

// Ensure that the action is within the subscription window
if (
!$this->signupService->isInSubscriptionWindow($signupList->getOpenDate(), $signupList->getCloseDate())
!$signupList->isOpen()
|| ActivityModel::STATUS_APPROVED !== $signupList->getActivity()->getStatus()
) {
$error = $this->translator->translate(
Expand Down
24 changes: 24 additions & 0 deletions module/Activity/src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,18 @@ public function externalSignupAction(): Response|ViewModel
throw new NotAllowedException($this->translator->translate('You are not allowed to use this form'));
}

if (
!$signupList->isOpen()
|| ActivityModel::STATUS_APPROVED !== $signupList->getActivity()->getStatus()
) {
return $this->redirectActivityAdminRequest(
$activityId,
$signupListId,
false,
$this->translator->translate('Cannot subscribe external participant at this point in time'),
);
}

/** @var Request $request */
$request = $this->getRequest();
$activityAdminSession = new SessionContainer('activityAdminRequest');
Expand Down Expand Up @@ -400,6 +412,18 @@ public function externalSignoffAction(): Response|ViewModel
throw new NotAllowedException($this->translator->translate('You are not allowed to use this form'));
}

if (
!$signupList->isOpen()
|| ActivityModel::STATUS_APPROVED !== $signupList->getActivity()->getStatus()
) {
return $this->redirectActivityAdminRequest(
$signupList->getActivity()->getId(),
$signupList->getId(),
false,
$this->translator->translate('Cannot unsubscribe external participant at this point in time'),
);
}

/** @var Request $request */
$request = $this->getRequest();

Expand Down
10 changes: 0 additions & 10 deletions module/Activity/src/Service/Signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Activity\Model\SignupList as SignupListModel;
use Activity\Model\SignupOption as SignupOptionModel;
use Activity\Model\UserSignup as UserSignupModel;
use DateTime;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\OptimisticLockException;
Expand Down Expand Up @@ -370,15 +369,6 @@ public function deleteOldSignups(): void
}
}

public static function isInSubscriptionWindow(
DateTime $openDate,
DateTime $closeDate,
): bool {
$currentTime = new DateTime();

return $openDate < $currentTime && $currentTime < $closeDate;
}

/**
* Is the currently logged-in user allowed to signup.
*/
Expand Down
10 changes: 8 additions & 2 deletions module/Application/language/en.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions module/Application/language/gewisweb.pot

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions module/Application/language/nl.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bfc2fd9

Please sign in to comment.