From 70c9f5f2663419c735576e370f1a3b9ca64dc096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Fri, 3 Mar 2023 23:21:19 +0100 Subject: [PATCH] =?UTF-8?q?Vyp=C3=ADnateln=C3=A1=20registrace=20(#958)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * disable registration * config property --- .../ConfigurationModule/Forms/SeminarFormFactory.php | 6 ++++++ app/Model/Settings/Settings.php | 5 +++++ .../Components/TroopApplicationContentControl.php | 3 +++ .../templates/troop_application_content.latte | 10 ++++++++++ 4 files changed, 24 insertions(+) diff --git a/app/AdminModule/ConfigurationModule/Forms/SeminarFormFactory.php b/app/AdminModule/ConfigurationModule/Forms/SeminarFormFactory.php index 28c8957b1..0ebf16d1a 100644 --- a/app/AdminModule/ConfigurationModule/Forms/SeminarFormFactory.php +++ b/app/AdminModule/ConfigurationModule/Forms/SeminarFormFactory.php @@ -5,8 +5,10 @@ namespace App\AdminModule\ConfigurationModule\Forms; use App\AdminModule\Forms\BaseFormFactory; +use App\Model\Settings\Commands\SetSettingBoolValue; use App\Model\Settings\Commands\SetSettingDateValue; use App\Model\Settings\Commands\SetSettingStringValue; +use App\Model\Settings\Queries\SettingBoolValueQuery; use App\Model\Settings\Queries\SettingDateValueQuery; use App\Model\Settings\Queries\SettingStringValueQuery; use App\Model\Settings\Settings; @@ -71,6 +73,8 @@ public function create(): Form $seminarToDate->addRule([$this, 'validateSeminarToDate'], 'admin.configuration.seminar_to_date_before_from', [$seminarToDate, $seminarFromDate]); $editRegistrationTo->addRule([$this, 'validateEditRegistrationTo'], 'admin.configuration.edit_registration_to_after_from', [$editRegistrationTo, $seminarFromDate]); + $form->addCheckbox('groupRegistrationAllowed', 'povolit registraci nových skupin'); + $form->addSubmit('submit', 'admin.common.save'); $form->setDefaults([ @@ -78,6 +82,7 @@ public function create(): Form 'seminarFromDate' => $this->queryBus->handle(new SettingDateValueQuery(Settings::SEMINAR_FROM_DATE)), 'seminarToDate' => $this->queryBus->handle(new SettingDateValueQuery(Settings::SEMINAR_TO_DATE)), 'editRegistrationTo' => $this->queryBus->handle(new SettingDateValueQuery(Settings::EDIT_REGISTRATION_TO)), + 'groupRegistrationAllowed' => $this->queryBus->handle(new SettingBoolValueQuery(Settings::GROUP_REGISTRATION_ALLOWED)), ]); $form->onSuccess[] = [$this, 'processForm']; @@ -100,6 +105,7 @@ public function processForm(Form $form, stdClass $values): void $this->commandBus->handle(new SetSettingDateValue(Settings::SEMINAR_FROM_DATE, $values->seminarFromDate)); $this->commandBus->handle(new SetSettingDateValue(Settings::SEMINAR_TO_DATE, $values->seminarToDate)); $this->commandBus->handle(new SetSettingDateValue(Settings::EDIT_REGISTRATION_TO, $values->editRegistrationTo)); + $this->commandBus->handle(new SetSettingBoolValue(Settings::GROUP_REGISTRATION_ALLOWED, $values->groupRegistrationAllowed)); } /** diff --git a/app/Model/Settings/Settings.php b/app/Model/Settings/Settings.php index 255cde18f..de5e9771d 100644 --- a/app/Model/Settings/Settings.php +++ b/app/Model/Settings/Settings.php @@ -234,6 +234,11 @@ class Settings */ public const CONTACT_FORM_GUESTS_ALLOWED = 'contact_form_guests_allowed'; + /** + * Povolit registraci skupiny. + */ + public const GROUP_REGISTRATION_ALLOWED = 'group_registration_allowed'; + /** * Název položky nastavení. */ diff --git a/app/WebModule/Components/TroopApplicationContentControl.php b/app/WebModule/Components/TroopApplicationContentControl.php index 9d2482a73..7b5c3e228 100644 --- a/app/WebModule/Components/TroopApplicationContentControl.php +++ b/app/WebModule/Components/TroopApplicationContentControl.php @@ -7,6 +7,7 @@ use App\Model\Acl\Repositories\RoleRepository; use App\Model\Acl\Role; use App\Model\Cms\Dto\ContentDto; +use App\Model\Settings\Queries\SettingBoolValueQuery; use App\Model\Settings\Queries\SettingStringValueQuery; use App\Model\Settings\Settings; use App\Model\User\Commands\RegisterTroop; @@ -79,6 +80,8 @@ public function render(?ContentDto $content = null): void $dbuser = $this->userRepository->findById($user->id); $template->dbuser = $dbuser; + $template->registrationAllowed = $this->queryBus->handle(new SettingBoolValueQuery(Settings::GROUP_REGISTRATION_ALLOWED)); + $skautIsUserId = $dbuser->getSkautISUserId(); $skautIsRoles = $this->skautIsService->getUserRoles($skautIsUserId, self::$ALLOWED_ROLE_TYPES); $template->skautIsRoles = $skautIsRoles; diff --git a/app/WebModule/Components/templates/troop_application_content.latte b/app/WebModule/Components/templates/troop_application_content.latte index f273ab25e..7b0a7d94d 100644 --- a/app/WebModule/Components/templates/troop_application_content.latte +++ b/app/WebModule/Components/templates/troop_application_content.latte @@ -46,6 +46,7 @@ + {if $registrationAllowed || $troop->getState() !== 'draft'}
Pracuješ v roli @@ -220,5 +221,14 @@ {control troopConfirmForm}
+ {else} +
+
+
+ Registrace nové skupiny není v tuto chvíli povolena. +
+
+
+ {/if} {/if}