Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(signup): admin (un)subscribe possible before sign-up list opens #1972

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions module/Activity/src/Controller/ActivityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
[
'action' => 'viewSignupList',
'id' => $activityId,
'signupList' => $activity->getSignupLists()->first()->getId(),

Check failure on line 88 in module/Activity/src/Controller/ActivityController.php

View workflow job for this annotation

GitHub Actions / Psalm

PossiblyFalseReference

module/Activity/src/Controller/ActivityController.php:88:75: PossiblyFalseReference: Cannot call method getId on possibly false value (see https://psalm.dev/105)
],
);
}
Expand Down Expand Up @@ -251,7 +251,7 @@

// 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 @@

// 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 @@

// 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 @@ -148,7 +148,7 @@

if (0 !== $updateProposal->count()) {
// If there already is an update proposal for this activity, show that instead of the original activity.
$activity = $updateProposal->first()->getNew();

Check failure on line 151 in module/Activity/src/Controller/AdminController.php

View workflow job for this annotation

GitHub Actions / Psalm

PossiblyFalseReference

module/Activity/src/Controller/AdminController.php:151:51: PossiblyFalseReference: Cannot call method getNew on possibly false value (see https://psalm.dev/105)
}

$activityData = $activity->toArray();
Expand Down Expand Up @@ -305,6 +305,18 @@
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 @@
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.

Loading