Skip to content

Commit

Permalink
fix(signup): admin (un)subscribe possible before sign-up list opens
Browse files Browse the repository at this point in the history
Should not be possible, as this prevents someone from editing the activity due
to the underlying limitations to editing (yes, ideally that should be fixed but
that is complex).
  • Loading branch information
tomudding committed Jan 11, 2025
1 parent 7e289b5 commit ab163de
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 18 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
9 changes: 0 additions & 9 deletions module/Activity/src/Service/Signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,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 ab163de

Please sign in to comment.