Disable registration when form is inactive
This commit is contained in:
parent
e5ecd0a2c0
commit
4b50c85fd6
|
@ -192,6 +192,10 @@ class Form extends Model implements HasMedia
|
||||||
|
|
||||||
public function canRegister(): bool
|
public function canRegister(): bool
|
||||||
{
|
{
|
||||||
|
if (!$this->is_active) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->registration_from && $this->registration_from->gt(now())) {
|
if ($this->registration_from && $this->registration_from->gt(now())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,6 +270,14 @@ it('testItSavesParticipantAsModel', function () {
|
||||||
$this->assertEquals('Abraham', $participants->first()->data['spitzname']);
|
$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 () {
|
it('testItCannotRegisterWhenRegistrationFromReached', function () {
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$form = Form::factory()->registrationFrom(now()->addDay())->create();
|
$form = Form::factory()->registrationFrom(now()->addDay())->create();
|
||||||
|
|
Loading…
Reference in New Issue