Compare commits
	
		
			No commits in common. "80e9cb38819c68b788e7ba58533b06b480f51ea5" and "e55603e9eedcf3c2f596236b39703821356be34e" have entirely different histories.
		
	
	
		
			80e9cb3881
			...
			e55603e9ee
		
	
		|  | @ -2,7 +2,6 @@ | |||
| 
 | ||||
| namespace App\Prevention\Actions; | ||||
| 
 | ||||
| use App\Prevention\Enums\Prevention; | ||||
| use App\Prevention\PreventionSettings; | ||||
| use Illuminate\Http\JsonResponse; | ||||
| use Lorisleiva\Actions\Concerns\AsAction; | ||||
|  | @ -15,9 +14,6 @@ class SettingApiAction | |||
|     { | ||||
|         return response()->json([ | ||||
|             'data' => app(PreventionSettings::class)->toFrontend(), | ||||
|             'meta' => [ | ||||
|                 'preventAgainsts' => Prevention::values(), | ||||
|             ] | ||||
|         ]); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -36,7 +36,6 @@ class SettingStoreAction | |||
|         $settings->freshRememberInterval = $request->freshRememberInterval; | ||||
|         $settings->active = $request->active; | ||||
|         $settings->yearlyMemberFilter = FilterScope::from($request->yearlyMemberFilter); | ||||
|         $settings->preventAgainst = $request->preventAgainst; | ||||
|         $settings->save(); | ||||
| 
 | ||||
|         Succeeded::message('Einstellungen gespeichert.')->dispatch(); | ||||
|  |  | |||
|  | @ -29,8 +29,7 @@ class YearlyRememberAction | |||
|             } | ||||
| 
 | ||||
|             $noticePreventions = $member->preventions($expireDate) | ||||
|                 ->filter(fn($prevention) => $prevention->expiresAt($expireDate)) | ||||
|                 ->filter(fn($p) => $p->appliesToSettings($settings)); | ||||
|                 ->filter(fn($prevention) => $prevention->expiresAt($expireDate)); | ||||
| 
 | ||||
|             if ($noticePreventions->count() === 0) { | ||||
|                 continue; | ||||
|  | @ -46,8 +45,7 @@ class YearlyRememberAction | |||
|             } | ||||
| 
 | ||||
|             $preventions = $member->preventions() | ||||
|                 ->filter(fn($prevention) => $prevention->expiresAt(now())) | ||||
|                 ->filter(fn($p) => $p->appliesToSettings($settings)); | ||||
|                 ->filter(fn($prevention) => $prevention->expiresAt(now())); | ||||
| 
 | ||||
|             if ($preventions->count() === 0) { | ||||
|                 continue; | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| namespace App\Prevention\Data; | ||||
| 
 | ||||
| use App\Prevention\Enums\Prevention; | ||||
| use App\Prevention\PreventionSettings; | ||||
| use Carbon\Carbon; | ||||
| use Spatie\LaravelData\Data; | ||||
| 
 | ||||
|  | @ -23,9 +22,4 @@ class PreventionData extends Data | |||
|             fn($str) => $str->append(' (fällig am ' . $this->expires->format('d.m.Y') . ')') | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|     public function appliesToSettings(PreventionSettings $settings): bool | ||||
|     { | ||||
|         return in_array($this->type->name, $settings->preventAgainst); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -49,15 +49,4 @@ enum Prevention | |||
|             'tooltip' => $case->tooltip($preventions->pluck('type')->doesntContain($case)), | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @return array<int, string> | ||||
|      */ | ||||
|     public static function values(): array | ||||
|     { | ||||
|         return collect(static::cases())->map(fn($case) => [ | ||||
|             'id' => $case->name, | ||||
|             'name' => $case->text(), | ||||
|         ])->toArray(); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -15,7 +15,6 @@ class PreventionSettings extends LocalSettings | |||
|     public int $freshRememberInterval; | ||||
|     public bool $active; | ||||
|     public FilterScope $yearlyMemberFilter; | ||||
|     public array $preventAgainst; | ||||
| 
 | ||||
|     public static function group(): string | ||||
|     { | ||||
|  |  | |||
|  | @ -12,6 +12,5 @@ return new class extends SettingsMigration | |||
|         $this->migrator->add('prevention.freshRememberInterval', 12); | ||||
|         $this->migrator->add('prevention.active', false); | ||||
|         $this->migrator->add('prevention.yearlyMemberFilter', FilterScope::from([])->toArray()); | ||||
|         $this->migrator->add('prevention.preventAgainst', []); | ||||
|     } | ||||
| }; | ||||
|  |  | |||
|  | @ -21,7 +21,6 @@ | |||
|                     </div> | ||||
|                     <f-editor v-if="active === 1" id="yearlymail" v-model="data.yearlymail" label="Jährliche Präventions-Erinnerung"></f-editor> | ||||
|                     <f-member-filter id="yearly_member_filter" v-model="data.yearlyMemberFilter" label="nur für folgende Mitglieder erlauben" /> | ||||
|                     <f-multipleselect id="prevent_against" v-model="data.preventAgainst" :options="meta.preventAgainsts" label="An diese Dokumente erinnern" size="sm"></f-multipleselect> | ||||
|                 </div> | ||||
|             </form> | ||||
|         </setting-layout> | ||||
|  | @ -39,7 +38,7 @@ const tabs = [ | |||
| ]; | ||||
| const active = ref(0); | ||||
| 
 | ||||
| const { axios, data, meta, reload } = useApiIndex('/api/prevention', 'prevention'); | ||||
| const { axios, data, reload } = useApiIndex('/api/prevention', 'prevention'); | ||||
| const loaded = ref(false); | ||||
| 
 | ||||
| async function load() { | ||||
|  |  | |||
|  | @ -27,10 +27,6 @@ uses(DatabaseTransactions::class); | |||
| uses(CreatesFormFields::class); | ||||
| uses(EndToEndTestCase::class); | ||||
| 
 | ||||
| beforeEach(function () { | ||||
|     app(PreventionSettings::class)->fill(['preventAgainst' => array_column(Prevention::values(), 'id')])->save(); | ||||
| }); | ||||
| 
 | ||||
| function createForm(): Form | ||||
| { | ||||
|     return Form::factory()->fields([ | ||||
|  | @ -288,17 +284,6 @@ it('testItDoesntRememberParticipantThatHasNoMail', function () { | |||
|     Mail::assertNotSent(PreventionRememberMail::class); | ||||
| }); | ||||
| 
 | ||||
| it('doesnt remember when prevent against doesnt match', function () { | ||||
|     Mail::fake(); | ||||
|     app(PreventionSettings::class)->fill(['preventAgainst' => []])->save(); | ||||
|     createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true]); | ||||
| 
 | ||||
|     sleep(2); | ||||
|     YearlyRememberAction::run(); | ||||
| 
 | ||||
|     Mail::assertNotSent(YearlyMail::class); | ||||
| }); | ||||
| 
 | ||||
| it('doesnt send yearly mail when member has no mail', function () { | ||||
|     Mail::fake(); | ||||
|     createMember(['efz' => now()->subYears(5), 'ps_at' => now(), 'has_vk' => true, 'email' => '', 'email_parents' => '']); | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ | |||
| namespace Tests\Feature\Prevention; | ||||
| 
 | ||||
| use App\Member\FilterScope; | ||||
| use App\Prevention\Enums\Prevention; | ||||
| use App\Prevention\PreventionSettings; | ||||
| use Illuminate\Foundation\Testing\DatabaseTransactions; | ||||
| use Tests\RequestFactories\EditorRequestFactory; | ||||
|  | @ -28,7 +27,6 @@ it('receives settings', function () { | |||
|         'weeks' => 9, | ||||
|         'freshRememberInterval' => 11, | ||||
|         'active' => true, | ||||
|         'preventAgainst' => [Prevention::MOREPS->name], | ||||
|         'yearlyMemberFilter' => FilterScope::from([ | ||||
|             'memberships' => [['group_ids' => [33]]], | ||||
|             'search' => 'searchstring', | ||||
|  | @ -42,10 +40,7 @@ it('receives settings', function () { | |||
|         ->assertJsonPath('data.active', true) | ||||
|         ->assertJsonPath('data.freshRememberInterval', '11') | ||||
|         ->assertJsonPath('data.yearlyMemberFilter.search', 'searchstring') | ||||
|         ->assertJsonPath('data.yearlyMemberFilter.memberships.0.group_ids.0', 33) | ||||
|         ->assertJsonPath('data.preventAgainst', ['MOREPS']) | ||||
|         ->assertJsonPath('meta.preventAgainsts.0.name', 'erweitertes Führungszeugnis') | ||||
|         ->assertJsonPath('meta.preventAgainsts.0.id', 'EFZ'); | ||||
|         ->assertJsonPath('data.yearlyMemberFilter.memberships.0.group_ids.0', 33); | ||||
| }); | ||||
| 
 | ||||
| it('testItStoresSettings', function () { | ||||
|  | @ -57,7 +52,6 @@ it('testItStoresSettings', function () { | |||
|         'weeks' => 9, | ||||
|         'freshRememberInterval' => 11, | ||||
|         'active' => true, | ||||
|         'preventAgainst' => ['EFZ'], | ||||
|         'yearlyMemberFilter' => [ | ||||
|             'memberships' => [['group_ids' => 33]], | ||||
|             'search' => 'searchstring', | ||||
|  | @ -70,5 +64,4 @@ it('testItStoresSettings', function () { | |||
|     test()->assertTrue(app(PreventionSettings::class)->active); | ||||
|     test()->assertEquals([['group_ids' => 33]], app(PreventionSettings::class)->yearlyMemberFilter->memberships); | ||||
|     test()->assertEquals('searchstring', app(PreventionSettings::class)->yearlyMemberFilter->search); | ||||
|     test()->assertEquals('EFZ', app(PreventionSettings::class)->preventAgainst[0]); | ||||
| }); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue