Compare commits
5 Commits
baea21807a
...
57b1efb065
Author | SHA1 | Date |
---|---|---|
|
57b1efb065 | |
|
3e563f8390 | |
|
0a5590d533 | |
|
10deaf15a1 | |
|
ae447a7a60 |
|
@ -7,6 +7,7 @@ use App\Form\Models\Form;
|
|||
use App\Form\Models\Participant;
|
||||
use App\Member\Member;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
|
@ -19,6 +20,10 @@ class RegisterAction
|
|||
*/
|
||||
public function handle(Form $form, array $input): Participant
|
||||
{
|
||||
if (!$form->canRegister()) {
|
||||
throw ValidationException::withMessages(['event' => 'Anmeldung zzt nicht möglich.']);
|
||||
}
|
||||
|
||||
$memberQuery = FieldCollection::fromRequest($form, $input)
|
||||
->withNamiType()
|
||||
->reduce(fn ($query, $field) => $field->namiType->performQuery($query, $field->value), (new Member())->newQuery());
|
||||
|
|
|
@ -188,4 +188,17 @@ class Form extends Model implements HasMedia
|
|||
{
|
||||
return Sorting::from($this->meta['sorting']);
|
||||
}
|
||||
|
||||
public function canRegister(): bool
|
||||
{
|
||||
if ($this->registration_from && $this->registration_from->gt(now())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->registration_until && $this->registration_until->lt(now())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ class FormApiResource extends JsonResource
|
|||
'image' => $this->getMedia('headerImage')->first()->getFullUrl('square'),
|
||||
'is_active' => $this->is_active,
|
||||
'is_private' => $this->is_private,
|
||||
'can_register' => $this->getModel()->canRegister(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
20
bin/run
20
bin/run
|
@ -1,5 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
FILESHARE=false
|
||||
WEB=false
|
||||
|
||||
while getopts f opt; do
|
||||
case $opt in
|
||||
f) FILESHARE=true ;;
|
||||
w) WEB=true ;;
|
||||
esac
|
||||
done
|
||||
|
||||
tmux new-session -d -s test
|
||||
tmux send-keys -t test "a serve" Enter
|
||||
|
||||
|
@ -12,11 +24,11 @@ tmux send-keys -t test "SS start docker && duu socketi" Enter
|
|||
tmux new-window -t test
|
||||
tmux send-keys -t test "nrh" Enter
|
||||
|
||||
tmux new-window -t test
|
||||
tmux send-keys -t test "ggwdk && cd plugins/silva/adrema/assets/vendor/adrema-form && nrd" Enter
|
||||
$WEB && tmux new-window -t test
|
||||
$WEB && tmux send-keys -t test "ggwdk && cd plugins/silva/adrema/assets/vendor/adrema-form && nrd" Enter
|
||||
|
||||
tmux new-window -t test
|
||||
tmux send-keys -t test "cd tests/Fileshare && docker compose up" Enter
|
||||
$FILESHARE && tmux new-window -t test
|
||||
$FILESHARE && tmux send-keys -t test "cd tests/Fileshare && docker compose up" Enter
|
||||
|
||||
tmux attach-session -t test
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ use App\Form\Models\Form;
|
|||
use App\Lib\Editor\Condition;
|
||||
use Database\Factories\Traits\FakesMedia;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Tests\Feature\Form\FormtemplateFieldRequest;
|
||||
use Tests\Feature\Form\FormtemplateSectionRequest;
|
||||
use Tests\RequestFactories\EditorRequestFactory;
|
||||
|
@ -48,8 +49,8 @@ class FormFactory extends Factory
|
|||
'config' => ['sections' => []],
|
||||
'from' => $this->faker->dateTimeBetween('+1 week', '+4 weeks')->format('Y-m-d H:i:s'),
|
||||
'to' => $this->faker->dateTimeBetween('+1 week', '+4 weeks')->format('Y-m-d H:i:s'),
|
||||
'registration_from' => $this->faker->dateTimeBetween('-2 weeks', 'now')->format('Y-m-d H:i:s'),
|
||||
'registration_until' => $this->faker->dateTimeBetween('now', '+2 weeks')->format('Y-m-d H:i:s'),
|
||||
'registration_from' => $this->faker->dateTimeBetween(Carbon::parse('-2 weeks'), now())->format('Y-m-d H:i:s'),
|
||||
'registration_until' => $this->faker->dateTimeBetween(now(), Carbon::parse('+2 weeks'))->format('Y-m-d H:i:s'),
|
||||
'mail_top' => EditorRequestFactory::new()->toData(),
|
||||
'mail_bottom' => EditorRequestFactory::new()->toData(),
|
||||
'is_active' => true,
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
></f-singlefile>
|
||||
<f-text id="from" v-model="single.from" type="date" label="Von" required></f-text>
|
||||
<f-text id="to" v-model="single.to" type="date" label="Bis" required></f-text>
|
||||
<f-text id="registration_from" v-model="single.registration_from" type="datetime-local" label="Registrierung von" required></f-text>
|
||||
<f-text id="registration_until" v-model="single.registration_until" type="datetime-local" label="Registrierung bis" required></f-text>
|
||||
<f-textarea
|
||||
id="excerpt"
|
||||
v-model="single.excerpt"
|
||||
|
@ -64,13 +66,15 @@
|
|||
:rows="5"
|
||||
required
|
||||
></f-textarea>
|
||||
<f-editor id="description" v-model="single.description" name="description" label="Beschreibung" :rows="10" required></f-editor>
|
||||
</div>
|
||||
<div v-if="active === 1">
|
||||
<f-editor id="description" v-model="single.description" name="description" label="Beschreibung" :rows="10" required></f-editor>
|
||||
</div>
|
||||
<div v-if="active === 2">
|
||||
<ui-note class="mt-2"> Sobald sich der erste Teilnehmer für die Veranstaltung angemeldet hat, kann dieses Formular nicht mehr geändert werden. </ui-note>
|
||||
<form-builder v-model="single.config" :meta="meta"></form-builder>
|
||||
</div>
|
||||
<div v-show="active === 2" class="grid grid-cols-[1fr_300px] gap-3">
|
||||
<div v-show="active === 3" class="grid grid-cols-[1fr_300px] gap-3">
|
||||
<ui-note class="mt-2 col-span-full">
|
||||
Hier kannst du die E-Mail anpassen, die nach der Anmeldung an den Teilnehmer verschickt wird.<br />
|
||||
Es gibt dafür einen ersten E-Mail-Teil und einen zweiten E-Mail-Teil. Dazwischen werden die Daten des Teilnehmers aufgelistet.<br />
|
||||
|
@ -108,14 +112,14 @@
|
|||
</template>
|
||||
</f-multiplefiles>
|
||||
</div>
|
||||
<div v-if="active === 3">
|
||||
<div v-if="active === 4">
|
||||
<div class="grid gap-3">
|
||||
<ui-remote-resource id="export" v-model="single.export.root" label="Haupt-Ordner"></ui-remote-resource>
|
||||
<f-select id="group_by" v-model="single.export.group_by" :options="allFields" label="Gruppieren nach" name="group_by"></f-select>
|
||||
<f-select id="to_group_field" v-model="single.export.to_group_field" :options="allFields" label="Nach Gruppe schreiben" name="to_group_field"></f-select>
|
||||
</div>
|
||||
</div>
|
||||
<div v-show="active === 4" class="grid grid-cols-2 gap-3">
|
||||
<div v-show="active === 5" class="grid grid-cols-2 gap-3">
|
||||
<f-switch id="needs_prevention" v-model="single.needs_prevention" name="needs_prevention" label="Prävention"></f-switch>
|
||||
<f-editor
|
||||
id="prevention_text"
|
||||
|
@ -207,7 +211,7 @@ const fileSettingPopup = ref(null);
|
|||
|
||||
const active = ref(0);
|
||||
const activeMailTab = ref(0);
|
||||
const tabs = [{ title: 'Allgemeines' }, { title: 'Formular' }, { title: 'Bestätigungs-E-Mail' }, { title: 'Export' }, { title: 'Prävention' }];
|
||||
const tabs = [{ title: 'Allgemeines' }, { title: 'Beschreibung' }, { title: 'Formular' }, { title: 'Bestätigungs-E-Mail' }, { title: 'Export' }, { title: 'Prävention' }];
|
||||
const mailTabs = [{ title: 'vor Daten' }, { title: 'nach Daten' }];
|
||||
|
||||
const allFields = computed(() => {
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
|
||||
trait CreatesApplication
|
||||
{
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
* @return \Illuminate\Foundation\Application
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
return $app;
|
||||
}
|
||||
}
|
|
@ -3,14 +3,12 @@
|
|||
namespace Tests\EndToEnd\Form;
|
||||
|
||||
use App\Form\Models\Form;
|
||||
use App\Membership\TestersBlock;
|
||||
use App\Subactivity;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\Feature\Form\FormtemplateSectionRequest;
|
||||
use Tests\RequestFactories\EditorRequestFactory;
|
||||
use Tests\TestCase;
|
||||
|
||||
uses(FormTestCase::class);
|
||||
uses(DatabaseTransactions::class);
|
||||
|
@ -42,11 +40,24 @@ it('testItDisplaysForms', function () {
|
|||
->assertJsonPath('data.0.dates', '05.05.2023 - 07.06.2023')
|
||||
->assertJsonPath('data.0.from_human', '05.05.2023')
|
||||
->assertJsonPath('data.0.to_human', '07.06.2023')
|
||||
->assertJsonPath('data.0.can_register', true)
|
||||
->assertJsonPath('meta.per_page', 15)
|
||||
->assertJsonPath('meta.base_url', url(''))
|
||||
->assertJsonPath('meta.total', 1);
|
||||
});
|
||||
|
||||
it('displays registration not possible', function () {
|
||||
Storage::fake('temp');
|
||||
$this->loginNami()->withoutExceptionHandling();
|
||||
Form::factory()
|
||||
->registrationFrom(now()->addDay())
|
||||
->withImage('headerImage', 'lala-2.jpg')
|
||||
->create();
|
||||
|
||||
sleep(1);
|
||||
$this->get('/api/form?perPage=15')->assertJsonPath('data.0.can_register', false);
|
||||
});
|
||||
|
||||
it('testItDisplaysDefaultValueOfField', function () {
|
||||
Storage::fake('temp');
|
||||
$this->loginNami()->withoutExceptionHandling();
|
||||
|
|
|
@ -55,6 +55,22 @@ class FormRegisterActionTest extends FormTestCase
|
|||
$this->assertEquals('Abraham', $participants->first()->data['spitzname']);
|
||||
}
|
||||
|
||||
public function testItCannotRegisterWhenRegistrationFromReached(): void
|
||||
{
|
||||
$this->login()->loginNami();
|
||||
$form = Form::factory()->registrationFrom(now()->addDay())->create();
|
||||
|
||||
$this->register($form, [])->assertJsonValidationErrors(['event' => 'Anmeldung zzt nicht möglich.']);
|
||||
}
|
||||
|
||||
public function testItCannotRegisterWhenRegistrationUntilReached(): void
|
||||
{
|
||||
$this->login()->loginNami();
|
||||
$form = Form::factory()->registrationUntil(now()->subDay())->create();
|
||||
|
||||
$this->register($form, [])->assertJsonValidationErrors(['event' => 'Anmeldung zzt nicht möglich.']);
|
||||
}
|
||||
|
||||
public function testItSendsEmailToParticipant(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
|
|
|
@ -5,8 +5,6 @@ namespace Tests\Feature\Form;
|
|||
use App\Fileshare\Data\FileshareResourceData;
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\Models\Form;
|
||||
use App\Lib\Editor\Condition;
|
||||
use App\Lib\Editor\EditorData;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\RequestFactories\EditorRequestFactory;
|
||||
|
||||
|
@ -31,6 +29,20 @@ class FormUpdateActionTest extends FormTestCase
|
|||
$this->assertTrue($form->config->sections->get(0)->fields->get(0)->maxToday);
|
||||
}
|
||||
|
||||
public function testItSetsRegistrationDates(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
$form = Form::factory()->create();
|
||||
$payload = FormRequest::new()->registrationFrom('2023-05-04 01:00:00')->registrationUntil('2023-07-07 01:00:00')->create();
|
||||
|
||||
$this->patchJson(route('form.update', ['form' => $form]), $payload)->assertOk();
|
||||
|
||||
$form = $form->fresh();
|
||||
|
||||
$this->assertEquals('2023-05-04 01:00', $form->registration_from->format('Y-m-d H:i'));
|
||||
$this->assertEquals('2023-07-07 01:00', $form->registration_until->format('Y-m-d H:i'));
|
||||
}
|
||||
|
||||
public function testItSetsTexts(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
|
|
|
@ -21,7 +21,6 @@ use Zoomyboy\TableDocument\TestsExcelDocuments;
|
|||
|
||||
class TestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
use TestsInertia;
|
||||
use MakesHttpCalls;
|
||||
use TestsExcelDocuments;
|
||||
|
|
Loading…
Reference in New Issue