Disable registration when form is inactive

This commit is contained in:
philipp lang 2025-07-16 14:51:31 +02:00
parent e5ecd0a2c0
commit 4b50c85fd6
2 changed files with 12 additions and 0 deletions

View File

@ -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;
}

View File

@ -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();