Compare commits

...

7 Commits

Author SHA1 Message Date
philipp lang 146b7dd6e3 Add frontend for later link
continuous-integration/drone/push Build is failing Details
2025-09-05 15:49:03 +02:00
philipp lang dafda4883d Add later registration backend
continuous-integration/drone/push Build is failing Details
2025-08-14 23:55:50 +02:00
philipp lang e6526ee326 Update CHANGELOG
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is failing Details
2025-07-16 15:52:31 +02:00
philipp lang 44e8da9a37 Lint
continuous-integration/drone/push Build is passing Details
2025-07-16 15:19:47 +02:00
philipp lang 4e43609619 Add tags to form overview
continuous-integration/drone/push Build is passing Details
2025-07-16 15:14:46 +02:00
philipp lang 32246e534e Add descriptions to form fields 2025-07-16 15:02:58 +02:00
philipp lang 4b50c85fd6 Disable registration when form is inactive 2025-07-16 14:51:31 +02:00
16 changed files with 260 additions and 12 deletions

View File

@ -1,5 +1,10 @@
# Letzte Änderungen # Letzte Änderungen
### 1.12.19
- Zuschusslisten können nun aus Veranstaltungs-Daten erstellt werden
- Veranstaltungs-Übersicht zeigt nun Tags an
### 1.12.18 ### 1.12.18
- Fix: Initialisierung klappt nun auch, wenn Mitgliedsnummer mit einer 0 beginnt - Fix: Initialisierung klappt nun auch, wenn Mitgliedsnummer mit einer 0 beginnt

View File

@ -0,0 +1,28 @@
<?php
namespace App\Form\Actions;
use App\Form\FormSettings;
use App\Form\Models\Form;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\URL;
use Lorisleiva\Actions\Concerns\AsAction;
class FormGenerateLaterlinkAction
{
use AsAction;
public function asController(Form $form)
{
$registerUrl = str(app(FormSettings::class)->registerUrl)->replace('{slug}', $form->slug)->toString();
$laterId = str()->uuid()->toString();
$laterUrl = URL::signedRoute('form.register', ['form' => $form, 'later' => '1', 'id' => $laterId]);
$urlParts = parse_url($laterUrl);
Cache::remember('later_'.$laterId, 2592000, fn () => $form->id); // Link ist 40 Tage gültig
return response()->json([
'url' => $registerUrl.'?'.data_get($urlParts, 'query')
]);
}
}

View File

@ -7,6 +7,9 @@ use App\Form\Models\Form;
use App\Form\Models\Participant; use App\Form\Models\Participant;
use App\Member\Member; use App\Member\Member;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Lorisleiva\Actions\ActionRequest; use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\AsAction;
@ -20,13 +23,9 @@ class RegisterAction
*/ */
public function handle(Form $form, array $input): Participant 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) $memberQuery = FieldCollection::fromRequest($form, $input)
->withNamiType() ->withNamiType()
->reduce(fn ($query, $field) => $field->namiType->performQuery($query, $field->value), (new Member())->newQuery()); ->reduce(fn($query, $field) => $field->namiType->performQuery($query, $field->value), (new Member())->newQuery());
$member = $form->getFields()->withNamiType()->count() && $memberQuery->count() === 1 ? $memberQuery->first() : null; $member = $form->getFields()->withNamiType()->count() && $memberQuery->count() === 1 ? $memberQuery->first() : null;
$participant = $form->participants()->create([ $participant = $form->participants()->create([
@ -34,7 +33,7 @@ class RegisterAction
'member_id' => $member?->id, 'member_id' => $member?->id,
]); ]);
$form->getFields()->each(fn ($field) => $field->afterRegistration($form, $participant, $input)); $form->getFields()->each(fn($field) => $field->afterRegistration($form, $participant, $input));
$participant->sendConfirmationMail(); $participant->sendConfirmationMail();
ExportSyncAction::dispatch($form->id); ExportSyncAction::dispatch($form->id);
@ -77,8 +76,34 @@ class RegisterAction
public function asController(ActionRequest $request, Form $form): JsonResponse public function asController(ActionRequest $request, Form $form): JsonResponse
{ {
if (!$form->canRegister() && !$this->isRegisteringLater($request, $form)) {
throw ValidationException::withMessages(['event' => 'Anmeldung zzt nicht möglich.']);
}
$participant = $this->handle($form, $request->validated()); $participant = $this->handle($form, $request->validated());
if ($this->isRegisteringLater($request, $form)) {
Cache::forget('later_'.request('id'));
}
return response()->json($participant); return response()->json($participant);
} }
public function isRegisteringLater(ActionRequest $request, Form $form): bool {
if (!is_array($request->query())) {
return false;
}
$validator = Validator::make($request->query(), [
'later' => 'required|numeric|in:1',
'id' => 'required|string|uuid:4',
'signature' => 'required|string',
]);
if (!URL::hasValidSignature($request) || $validator->fails()) {
return false;
}
return Cache::get('later_'.data_get($validator->validated(), 'id')) === $form->id;
}
} }

View File

@ -190,8 +190,7 @@ class Form extends Model implements HasMedia
return Sorting::from($this->meta['sorting']); return Sorting::from($this->meta['sorting']);
} }
public function canRegister(): bool public function isInDates(): bool {
{
if ($this->registration_from && $this->registration_from->gt(now())) { if ($this->registration_from && $this->registration_from->gt(now())) {
return false; return false;
} }
@ -202,4 +201,9 @@ class Form extends Model implements HasMedia
return true; return true;
} }
public function canRegister(): bool
{
return $this->is_active && $this->isInDates();
}
} }

View File

@ -46,6 +46,7 @@ class FormResource extends JsonResource
'mail_bottom' => $this->mail_bottom, 'mail_bottom' => $this->mail_bottom,
'registration_from' => $this->registration_from?->format('Y-m-d H:i:s'), 'registration_from' => $this->registration_from?->format('Y-m-d H:i:s'),
'registration_until' => $this->registration_until?->format('Y-m-d H:i:s'), 'registration_until' => $this->registration_until?->format('Y-m-d H:i:s'),
'is_in_dates' => $this->isInDates(),
'config' => $this->config, 'config' => $this->config,
'participants_count' => $this->participants_count, 'participants_count' => $this->participants_count,
'is_active' => $this->is_active, 'is_active' => $this->is_active,
@ -69,6 +70,7 @@ class FormResource extends JsonResource
'export' => route('form.export', $this->getModel()), 'export' => route('form.export', $this->getModel()),
'copy' => route('form.copy', $this->getModel()), 'copy' => route('form.copy', $this->getModel()),
'contribution' => route('form.contribution', $this->getModel()), 'contribution' => route('form.contribution', $this->getModel()),
'laterlink' => route('form.laterlink', $this->getModel()),
] ]
]; ];
} }

42
package-lock.json generated
View File

@ -30,6 +30,7 @@
"uuid": "^11.1.0", "uuid": "^11.1.0",
"vite": "^4.5.2", "vite": "^4.5.2",
"vue": "^3.3.4", "vue": "^3.3.4",
"vue-clipboard3": "^2.0.0",
"vue-toastification": "^2.0.0-rc.5", "vue-toastification": "^2.0.0-rc.5",
"vuedraggable": "^4.1.0", "vuedraggable": "^4.1.0",
"wnumb": "^1.2.0" "wnumb": "^1.2.0"
@ -1872,6 +1873,16 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/clipboard": {
"version": "2.0.11",
"resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.11.tgz",
"integrity": "sha512-C+0bbOqkezLIsmWSvlsXS0Q0bmkugu7jcfMIACB+RDEntIzQIkdr148we28AfSloQLRdZlYL/QYyrq05j/3Faw==",
"dependencies": {
"good-listener": "^1.2.2",
"select": "^1.1.2",
"tiny-emitter": "^2.0.0"
}
},
"node_modules/cliui": { "node_modules/cliui": {
"version": "8.0.1", "version": "8.0.1",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
@ -2140,6 +2151,11 @@
"node": ">=0.4.0" "node": ">=0.4.0"
} }
}, },
"node_modules/delegate": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz",
"integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw=="
},
"node_modules/didyoumean": { "node_modules/didyoumean": {
"version": "1.2.2", "version": "1.2.2",
"resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz",
@ -2848,6 +2864,14 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/good-listener": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz",
"integrity": "sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw==",
"dependencies": {
"delegate": "^3.1.2"
}
},
"node_modules/gopd": { "node_modules/gopd": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
@ -4075,6 +4099,11 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/select": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz",
"integrity": "sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA=="
},
"node_modules/semver": { "node_modules/semver": {
"version": "7.7.2", "version": "7.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
@ -4545,6 +4574,11 @@
"node": ">=0.8" "node": ">=0.8"
} }
}, },
"node_modules/tiny-emitter": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz",
"integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q=="
},
"node_modules/tinyglobby": { "node_modules/tinyglobby": {
"version": "0.2.14", "version": "0.2.14",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz",
@ -4952,6 +4986,14 @@
"vue": "^3.0.0 || ^2.0.0" "vue": "^3.0.0 || ^2.0.0"
} }
}, },
"node_modules/vue-clipboard3": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/vue-clipboard3/-/vue-clipboard3-2.0.0.tgz",
"integrity": "sha512-Q9S7dzWGax7LN5iiSPcu/K1GGm2gcBBlYwmMsUc5/16N6w90cbKow3FnPmPs95sungns4yvd9/+JhbAznECS2A==",
"dependencies": {
"clipboard": "^2.0.6"
}
},
"node_modules/vue-demi": { "node_modules/vue-demi": {
"version": "0.14.10", "version": "0.14.10",
"resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz", "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz",

View File

@ -47,6 +47,7 @@
"uuid": "^11.1.0", "uuid": "^11.1.0",
"vite": "^4.5.2", "vite": "^4.5.2",
"vue": "^3.3.4", "vue": "^3.3.4",
"vue-clipboard3": "^2.0.0",
"vue-toastification": "^2.0.0-rc.5", "vue-toastification": "^2.0.0-rc.5",
"vuedraggable": "^4.1.0", "vuedraggable": "^4.1.0",
"wnumb": "^1.2.0" "wnumb": "^1.2.0"

View File

@ -1,3 +1,7 @@
.v-popper__popper {
@apply max-w-lg;
}
.v-popper--theme-tooltip .v-popper__inner { .v-popper--theme-tooltip .v-popper__inner {
@apply bg-primary-400 text-primary-800 px-3 py-1 text-sm; @apply bg-primary-400 text-primary-800 px-3 py-1 text-sm;
} }

View File

@ -0,0 +1,4 @@
<svg x="0px" y="0px" viewBox="0 0 511.626 511.627" xml:space="preserve">
<path d="M392.857,292.354h-18.274c-2.669,0-4.859,0.855-6.563,2.573c-1.718,1.708-2.573,3.897-2.573,6.563v91.361 c0,12.563-4.47,23.315-13.415,32.262c-8.945,8.945-19.701,13.414-32.264,13.414H82.224c-12.562,0-23.317-4.469-32.264-13.414 c-8.945-8.946-13.417-19.698-13.417-32.262V155.31c0-12.562,4.471-23.313,13.417-32.259c8.947-8.947,19.702-13.418,32.264-13.418 h200.994c2.669,0,4.859-0.859,6.57-2.57c1.711-1.713,2.566-3.9,2.566-6.567V82.221c0-2.662-0.855-4.853-2.566-6.563 c-1.711-1.713-3.901-2.568-6.57-2.568H82.224c-22.648,0-42.016,8.042-58.102,24.125C8.042,113.297,0,132.665,0,155.313v237.542 c0,22.647,8.042,42.018,24.123,58.095c16.086,16.084,35.454,24.13,58.102,24.13h237.543c22.647,0,42.017-8.046,58.101-24.13 c16.085-16.077,24.127-35.447,24.127-58.095v-91.358c0-2.669-0.856-4.859-2.574-6.57 C397.709,293.209,395.519,292.354,392.857,292.354z"/>
<path d="M506.199,41.971c-3.617-3.617-7.905-5.424-12.85-5.424H347.171c-4.948,0-9.233,1.807-12.847,5.424 c-3.617,3.615-5.428,7.898-5.428,12.847s1.811,9.233,5.428,12.85l50.247,50.248L198.424,304.067 c-1.906,1.903-2.856,4.093-2.856,6.563c0,2.479,0.953,4.668,2.856,6.571l32.548,32.544c1.903,1.903,4.093,2.852,6.567,2.852 s4.665-0.948,6.567-2.852l186.148-186.148l50.251,50.248c3.614,3.617,7.898,5.426,12.847,5.426s9.233-1.809,12.851-5.426 c3.617-3.616,5.424-7.898,5.424-12.847V54.818C511.626,49.866,509.813,45.586,506.199,41.971z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -17,4 +17,4 @@ var options = {
}, },
}; };
export {Plugin, options}; export { Plugin, options };

View File

@ -23,8 +23,8 @@
<div v-show="active === 0" class="grid grid-cols-4 gap-3"> <div v-show="active === 0" class="grid grid-cols-4 gap-3">
<div class="flex space-x-3 col-span-2"> <div class="flex space-x-3 col-span-2">
<f-text id="name" v-model="single.name" class="grow" label="Name" required /> <f-text id="name" v-model="single.name" class="grow" label="Name" required />
<f-switch id="is_active" v-model="single.is_active" name="is_active" label="Aktiv" /> <f-switch id="is_active" v-model="single.is_active" name="is_active" label="Aktiv" hint="Inaktive Veranstaltungen werden außerhalb von Adrema wie nicht existierende Veranstaltungen betrachtet. Insbesondere ist eine Anmeldung dann nicht möglich und die Veranstaltung erscheint auch nicht in der Veranstaltungs-Übersicht." />
<f-switch id="is_private" v-model="single.is_private" name="is_private" label="Privat" /> <f-switch id="is_private" v-model="single.is_private" name="is_private" label="Privat" hint="Ist eine Veranstaltung privat, so wird diese nicht auf der Website angezeigt. Eine Anmeldung ist jedoch trotzdem möglich, wenn man über den Anmelde-Link verfügt." />
</div> </div>
<f-singlefile id="header_image" <f-singlefile id="header_image"
v-model="single.header_image" v-model="single.header_image"
@ -41,7 +41,7 @@
<f-text id="zip" v-model="single.zip" label="PLZ" /> <f-text id="zip" v-model="single.zip" label="PLZ" />
<f-text id="location" v-model="single.location" label="Ort" /> <f-text id="location" v-model="single.location" label="Ort" />
<f-select id="country" v-model="single.country" class="col-span-2" name="country" label="Land" :options="meta.countries" /> <f-select id="country" v-model="single.country" class="col-span-2" name="country" label="Land" :options="meta.countries" />
<f-text id="registration_from" v-model="single.registration_from" type="datetime-local" label="Registrierung von" required /> <f-text id="registration_from" v-model="single.registration_from" type="datetime-local" label="Registrierung von" hint="Ist eine Anmeldung laut dieser zwei Datumsangaben möglich, kann man sich anmelden. Andernfalls wird die Veranstaltung (mit Beschreibungstext) auf der Übersichtsseite angezeigt, man kommt allerdings nicht zum Anmeldeformular." required />
<f-text id="registration_until" v-model="single.registration_until" type="datetime-local" label="Registrierung bis" required /> <f-text id="registration_until" v-model="single.registration_until" type="datetime-local" label="Registrierung bis" required />
<f-textarea id="excerpt" <f-textarea id="excerpt"
v-model="single.excerpt" v-model="single.excerpt"
@ -146,6 +146,7 @@
<th>Name</th> <th>Name</th>
<th>Von</th> <th>Von</th>
<th>Bis</th> <th>Bis</th>
<th>Tags</th>
<th>Anzahl TN</th> <th>Anzahl TN</th>
<th /> <th />
</tr> </tr>
@ -162,6 +163,13 @@
<td> <td>
<div v-text="form.to_human" /> <div v-text="form.to_human" />
</td> </td>
<td>
<div class="bool-row">
<ui-bool true-comment="aktiv" false-comment="inaktiv" :value="form.is_active">A</ui-bool>
<ui-bool true-comment="private Veranstaltung" false-comment="nicht private Veranstaltung" :value="form.is_private">P</ui-bool>
<ui-bool true-comment="Anmeldung möglich (lt. 'Registrierung von / bis')" false-comment="Anmeldeschluss erreicht" :value="form.is_in_dates">D</ui-bool>
</div>
</td>
<td> <td>
<div v-text="form.participants_count" /> <div v-text="form.participants_count" />
</td> </td>
@ -171,6 +179,7 @@
<ui-action-button tooltip="Teilnehmende anzeigen" class="btn-info" icon="user" @click.prevent="showParticipants(form)" /> <ui-action-button tooltip="Teilnehmende anzeigen" class="btn-info" icon="user" @click.prevent="showParticipants(form)" />
<ui-action-button :href="form.links.frontend" target="_BLANK" tooltip="zur Anmeldeseite" class="btn-info" icon="eye" /> <ui-action-button :href="form.links.frontend" target="_BLANK" tooltip="zur Anmeldeseite" class="btn-info" icon="eye" />
<ui-action-button tooltip="Kopieren" class="btn-info" icon="copy" @click="onCopy(form)" /> <ui-action-button tooltip="Kopieren" class="btn-info" icon="copy" @click="onCopy(form)" />
<ui-action-button tooltip="Nachmelde-Link kopieren" class="btn-info" icon="externallink" @click="copyLaterLink(form)" />
<ui-action-button tooltip="Zuschuss-Liste erstellen" class="btn-info" icon="contribution" @click="onGenerateContribution(form)" /> <ui-action-button tooltip="Zuschuss-Liste erstellen" class="btn-info" icon="contribution" @click="onGenerateContribution(form)" />
<ui-action-button :href="form.links.export" target="_BLANK" tooltip="als Tabellendokument exportieren" class="btn-info" icon="document" /> <ui-action-button :href="form.links.export" target="_BLANK" tooltip="als Tabellendokument exportieren" class="btn-info" icon="document" />
<ui-action-button tooltip="Löschen" class="btn-danger" icon="trash" @click.prevent="onDelete(form)" /> <ui-action-button tooltip="Löschen" class="btn-danger" icon="trash" @click.prevent="onDelete(form)" />
@ -195,12 +204,14 @@ import ConditionsForm from './ConditionsForm.vue';
import { useToast } from 'vue-toastification'; import { useToast } from 'vue-toastification';
import useSwal from '@/stores/swalStore.ts'; import useSwal from '@/stores/swalStore.ts';
import useDownloads from '@/composables/useDownloads.ts'; import useDownloads from '@/composables/useDownloads.ts';
import useClipboard from 'vue-clipboard3';
const props = defineProps(indexProps); const props = defineProps(indexProps);
const { meta, data, reloadPage, reload, create, single, edit, cancel, submit, remove, getFilter, setFilter } = useIndex(props.data, 'form'); const { meta, data, reloadPage, reload, create, single, edit, cancel, submit, remove, getFilter, setFilter } = useIndex(props.data, 'form');
const axios = inject('axios'); const axios = inject('axios');
const toast = useToast(); const toast = useToast();
const {download} = useDownloads(); const {download} = useDownloads();
const {toClipboard} = useClipboard();
const showing = ref(null); const showing = ref(null);
const fileSettingPopup = ref(null); const fileSettingPopup = ref(null);
@ -258,6 +269,12 @@ function setTemplate(template) {
single.value.mail_bottom = template.mail_bottom; single.value.mail_bottom = template.mail_bottom;
} }
async function copyLaterLink(form) {
const response = await axios.get(form.links.laterlink);
await toClipboard(response.data.url);
toast.success('Link in Zwischenablage kopiert');
}
async function saveFileConditions(conditions) { async function saveFileConditions(conditions) {
await axios.patch(`/mediaupload/${fileSettingPopup.value.id}`, { await axios.patch(`/mediaupload/${fileSettingPopup.value.id}`, {
properties: { properties: {

View File

@ -24,6 +24,7 @@ use App\Fileshare\Actions\ListFilesAction;
use App\Form\Actions\ExportAction as ActionsExportAction; use App\Form\Actions\ExportAction as ActionsExportAction;
use App\Form\Actions\FormCopyAction; use App\Form\Actions\FormCopyAction;
use App\Form\Actions\FormDestroyAction; use App\Form\Actions\FormDestroyAction;
use App\Form\Actions\FormGenerateLaterlinkAction;
use App\Form\Actions\FormIndexAction; use App\Form\Actions\FormIndexAction;
use App\Group\Actions\GroupBulkstoreAction; use App\Group\Actions\GroupBulkstoreAction;
use App\Group\Actions\GroupIndexAction; use App\Group\Actions\GroupIndexAction;
@ -180,6 +181,7 @@ Route::group(['middleware' => 'auth:web'], function (): void {
Route::post('/form/{form}/participant', ParticipantStoreAction::class)->name('form.participant.store'); Route::post('/form/{form}/participant', ParticipantStoreAction::class)->name('form.participant.store');
Route::post('/form/{form}/copy', FormCopyAction::class)->name('form.copy'); Route::post('/form/{form}/copy', FormCopyAction::class)->name('form.copy');
Route::get('/form/{form}/contribution', GenerateContributionAction::class)->name('form.contribution'); Route::get('/form/{form}/contribution', GenerateContributionAction::class)->name('form.contribution');
Route::get('/form/{form}/laterlink', FormGenerateLaterlinkAction::class)->name('form.laterlink');
// ------------------------------------ fileshare ----------------------------------- // ------------------------------------ fileshare -----------------------------------
Route::post('/fileshare', FileshareStoreAction::class)->name('fileshare.store'); Route::post('/fileshare', FileshareStoreAction::class)->name('fileshare.store');

View File

@ -70,6 +70,7 @@ it('testItDisplaysForms', function () {
->assertInertiaPath('data.data.0.links.participant_index', route('form.participant.index', ['form' => $form])) ->assertInertiaPath('data.data.0.links.participant_index', route('form.participant.index', ['form' => $form]))
->assertInertiaPath('data.data.0.links.export', route('form.export', ['form' => $form])) ->assertInertiaPath('data.data.0.links.export', route('form.export', ['form' => $form]))
->assertInertiaPath('data.data.0.links.contribution', route('form.contribution', ['form' => $form])) ->assertInertiaPath('data.data.0.links.contribution', route('form.contribution', ['form' => $form]))
->assertInertiaPath('data.data.0.links.laterlink', route('form.laterlink', ['form' => $form]))
->assertInertiaPath('data.meta.links.store', route('form.store')) ->assertInertiaPath('data.meta.links.store', route('form.store'))
->assertInertiaPath('data.meta.links.formtemplate_index', route('formtemplate.index')) ->assertInertiaPath('data.meta.links.formtemplate_index', route('formtemplate.index'))
->assertInertiaPath('data.meta.default.name', '') ->assertInertiaPath('data.meta.default.name', '')
@ -183,6 +184,22 @@ it('testItDoesntReturnInactiveForms', function () {
$this->callFilter('form.index', ['inactive' => false])->assertInertiaCount('data.data', 2); $this->callFilter('form.index', ['inactive' => false])->assertInertiaCount('data.data', 2);
}); });
it('returns in dates', function () {
$this->withoutExceptionHandling()->login()->loginNami();
Form::factory()->create();
sleep(1);
$this->callFilter('form.index', [])->assertInertiaPath('data.data.0.is_in_dates', true);
});
it('returns not in dates', function () {
$this->withoutExceptionHandling()->login()->loginNami();
Form::factory()->registrationFrom(now()->addDay(2))->create();
sleep(1);
$this->callFilter('form.index', [])->assertInertiaPath('data.data.0.is_in_dates', false);
});
it('testItOrdersByStartDateDesc', function () { it('testItOrdersByStartDateDesc', function () {
$this->withoutExceptionHandling()->login()->loginNami(); $this->withoutExceptionHandling()->login()->loginNami();
$form1 = Form::factory()->from(now()->addDays(4))->to(now()->addYear())->create(); $form1 = Form::factory()->from(now()->addDays(4))->to(now()->addYear())->create();

View File

@ -0,0 +1,35 @@
<?php
namespace Tests\Feature\Form;
use App\Form\FormSettings;
use App\Form\Models\Form;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Mail;
use Tests\Lib\CreatesFormFields;
uses(DatabaseTransactions::class);
uses(CreatesFormFields::class);
beforeEach(function () {
test()->setUpForm();
Mail::fake();
});
it('generates a later link', function () {
$this->login()->loginNami()->withoutExceptionHandling();
app(FormSettings::class)->fill(['registerUrl' => 'https://example.com/register/{slug}'])->save();
$form = Form::factory()->name('fff')->create();
$url = $this->get(route('form.laterlink', ['form' => $form]))->json('url');
test()->assertNotNull($url);
$this->assertTrue(str($url)->startsWith('https://example.com/register/fff'));
$query = data_get(parse_url($url), 'query');
parse_str($query, $queryParts);
$this->assertEquals('1', $queryParts['later']);
$this->assertEquals($form->id, Cache::get('later_'.$queryParts['id']));
});

View File

@ -11,6 +11,7 @@ use App\Group\Enums\Level;
use Carbon\Carbon; use Carbon\Carbon;
use Database\Factories\Member\MemberFactory; use Database\Factories\Member\MemberFactory;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Mail;
use Tests\Lib\CreatesFormFields; use Tests\Lib\CreatesFormFields;
@ -270,6 +271,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();
@ -727,3 +736,39 @@ it('testItSetsRegionIfMemberIsDirectRegionMember', function () {
$this->register($form, ['bezirk' => $bezirk->id, 'members' => [['id' => '5505']]])->assertOk(); $this->register($form, ['bezirk' => $bezirk->id, 'members' => [['id' => '5505']]])->assertOk();
$this->assertEquals($bezirk->id, $form->participants->get(1)->data['bezirk']); $this->assertEquals($bezirk->id, $form->participants->get(1)->data['bezirk']);
}); });
it('registers via later link', function () {
$this->login()->loginNami();
$laterId = str()->uuid()->toString();
$form = Form::factory()->fields([])
->registrationUntil(now()->subDay())
->create();
Cache::set('later_'.$laterId, $form->id);
$this->registerLater($form, [], $laterId)->assertOk();
$this->assertDatabaseCount('participants', 1);
$this->assertNull(Cache::get('later_'.$laterId));
});
it('checks signature of later link', function () {
$this->login()->loginNami();
$form = Form::factory()->fields([])
->registrationUntil(now()->subDay())
->create();
$this->registerLaterWithWrongSignature($form, [], str()->uuid())->assertStatus(422);
$this->assertDatabaseCount('participants', 0);
});
it('checks if later links is from current form', function () {
$this->login()->loginNami();
$foreignForm = Form::factory()->create();
$form = Form::factory()->fields([])
->registrationUntil(now()->subDay())
->create();
$laterId = str()->uuid()->toString();
Cache::set('later_'.$laterId, $foreignForm->id);
$this->registerLater($form, [], $laterId)->assertStatus(422);
$this->assertDatabaseCount('participants', 0);
});

View File

@ -18,6 +18,7 @@ use App\Form\Models\Form;
use App\Member\Member; use App\Member\Member;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\URL;
use Illuminate\Testing\TestResponse; use Illuminate\Testing\TestResponse;
use Tests\Feature\Form\FormtemplateFieldRequest; use Tests\Feature\Form\FormtemplateFieldRequest;
@ -42,6 +43,22 @@ trait CreatesFormFields
return $this->postJson(route('form.register', ['form' => $form]), $payload); return $this->postJson(route('form.register', ['form' => $form]), $payload);
} }
/**
* @param array<string, mixed> $payload
*/
public function registerLater(Form $form, array $payload, string $laterId): TestResponse
{
return $this->postJson(URL::signedRoute('form.register', ['form' => $form, 'later' => '1', 'id' => $laterId]), $payload);
}
/**
* @param array<string, mixed> $payload
*/
public function registerLaterWithWrongSignature(Form $form, array $payload, string $laterId): TestResponse
{
return $this->postJson(route('form.register', ['form' => $form, 'later' => '1', 'id' => $laterId, 'signature' => '-1']), $payload);
}
public function setUpForm() { public function setUpForm() {
app(FormSettings::class)->fill(['clearCacheUrl' => 'http://event.com/clear-cache'])->save(); app(FormSettings::class)->fill(['clearCacheUrl' => 'http://event.com/clear-cache'])->save();