From 4b50c85fd6349758d7d4906ba4e64e4f6c52735c Mon Sep 17 00:00:00 2001 From: philipp lang Date: Wed, 16 Jul 2025 14:51:31 +0200 Subject: [PATCH] Disable registration when form is inactive --- app/Form/Models/Form.php | 4 ++++ tests/Feature/Form/FormRegisterActionTest.php | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/app/Form/Models/Form.php b/app/Form/Models/Form.php index 7ef62e47..627b594e 100644 --- a/app/Form/Models/Form.php +++ b/app/Form/Models/Form.php @@ -192,6 +192,10 @@ class Form extends Model implements HasMedia public function canRegister(): bool { + if (!$this->is_active) { + return false; + } + if ($this->registration_from && $this->registration_from->gt(now())) { return false; } diff --git a/tests/Feature/Form/FormRegisterActionTest.php b/tests/Feature/Form/FormRegisterActionTest.php index 884ed0d4..a62f0e30 100644 --- a/tests/Feature/Form/FormRegisterActionTest.php +++ b/tests/Feature/Form/FormRegisterActionTest.php @@ -270,6 +270,14 @@ it('testItSavesParticipantAsModel', function () { $this->assertEquals('Abraham', $participants->first()->data['spitzname']); }); + +it('cannot register when event is inactive', function () { + $this->login()->loginNami(); + $form = Form::factory()->isActive(false)->create(); + + $this->register($form, [])->assertJsonValidationErrors(['event' => 'Anmeldung zzt nicht möglich.']); +}); + it('testItCannotRegisterWhenRegistrationFromReached', function () { $this->login()->loginNami(); $form = Form::factory()->registrationFrom(now()->addDay())->create();