diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-manual.yml similarity index 98% rename from .github/workflows/deploy-production.yml rename to .github/workflows/deploy-manual.yml index a0512e015..7b2318009 100644 --- a/.github/workflows/deploy-production.yml +++ b/.github/workflows/deploy-manual.yml @@ -1,4 +1,4 @@ -name: deploy-production +name: deploy-manual on: workflow_dispatch: @@ -10,7 +10,7 @@ on: jobs: deploy: - name: "Deploy to production" + name: "Manual deployment" environment: ${{ github.event.inputs.environment }} runs-on: ubuntu-18.04 container: diff --git a/README.md b/README.md index d802a2b0f..673239e8b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Skautský rezervační systém -[![test](https://github.com/skaut/SRS/actions/workflows/test.yml/badge.svg)](https://github.com/skaut/SRS/actions/workflows/test.yml) [![deploy-dev](https://github.com/skaut/SRS/actions/workflows/deploy-dev.yml/badge.svg)](https://github.com/skaut/SRS/actions/workflows/deploy-dev.yml) [![deploy-staging](https://github.com/skaut/SRS/actions/workflows/deploy-staging.yml/badge.svg)](https://github.com/skaut/SRS/actions/workflows/deploy-staging.yml) [![deploy-production](https://github.com/skaut/SRS/actions/workflows/deploy-production.yml/badge.svg)](https://github.com/skaut/SRS/actions/workflows/deploy-production.yml) [![codecov](https://codecov.io/gh/skaut/SRS/branch/master/graph/badge.svg)](https://codecov.io/gh/skaut/SRS) +[![test](https://github.com/skaut/SRS/actions/workflows/test.yml/badge.svg)](https://github.com/skaut/SRS/actions/workflows/test.yml) [![deploy-dev](https://github.com/skaut/SRS/actions/workflows/deploy-dev.yml/badge.svg)](https://github.com/skaut/SRS/actions/workflows/deploy-dev.yml) [![deploy-staging](https://github.com/skaut/SRS/actions/workflows/deploy-staging.yml/badge.svg)](https://github.com/skaut/SRS/actions/workflows/deploy-staging.yml) [![deploy-manual](https://github.com/skaut/SRS/actions/workflows/deploy-manual.yml/badge.svg)](https://github.com/skaut/SRS/actions/workflows/deploy-manual.yml) [![codecov](https://codecov.io/gh/skaut/SRS/branch/master/graph/badge.svg)](https://codecov.io/gh/skaut/SRS) Skautský rezervační systém (neboli SRS) byl vytvořen jako webový nástroj pro podporu vzdělávacích seminářů Junáka - českého skauta, na které se typicky přihlašují účastníci, kteří si následně vybírají vlastní podobu programu, kterou na akci absolvovat. Cílem tohoto webového systému je zjednodušit či zautomatizovat organizační procesy, kterými musí každý seminář projít. diff --git a/app/ActionModule/Presenters/MailingPresenter.php b/app/ActionModule/Presenters/MailingPresenter.php index d0a9e709a..29e4714af 100644 --- a/app/ActionModule/Presenters/MailingPresenter.php +++ b/app/ActionModule/Presenters/MailingPresenter.php @@ -7,7 +7,6 @@ use App\Model\Acl\Permission; use App\Model\Acl\SrsResource; use App\Model\Settings\Commands\SetSettingStringValue; -use App\Model\Settings\Exceptions\SettingsItemNotFoundException; use App\Model\Settings\Queries\SettingStringValueQuery; use App\Model\Settings\Settings; use App\Services\CommandBus; @@ -29,7 +28,6 @@ class MailingPresenter extends ActionBasePresenter /** * Ověří e-mail semináře. * - * @throws SettingsItemNotFoundException * @throws AbortException * @throws Throwable */ diff --git a/app/ActionModule/Presenters/MaturityPresenter.php b/app/ActionModule/Presenters/MaturityPresenter.php index 8fffd73cd..ec50835e5 100644 --- a/app/ActionModule/Presenters/MaturityPresenter.php +++ b/app/ActionModule/Presenters/MaturityPresenter.php @@ -9,7 +9,6 @@ use App\Model\Enums\ApplicationState; use App\Model\Mailing\Template; use App\Model\Mailing\TemplateVariable; -use App\Model\Settings\Exceptions\SettingsItemNotFoundException; use App\Model\Settings\Queries\SettingIntValueQuery; use App\Model\Settings\Queries\SettingStringValueQuery; use App\Model\Settings\Settings; @@ -23,7 +22,6 @@ use Doctrine\ORM\EntityManagerInterface; use Nette\Application\Responses\TextResponse; use Throwable; -use Ublaboo\Mailing\Exception\MailingMailCreationException; /** * Presenter obsluhující kontrolu splatnosti přihlášek. @@ -51,7 +49,6 @@ class MaturityPresenter extends ActionBasePresenter /** * Zruší přihlášky po splatnosti. * - * @throws SettingsItemNotFoundException * @throws Throwable */ public function actionCancelApplications(): void @@ -108,9 +105,7 @@ public function actionCancelApplications(): void /** * Rozešle přípomínky splatnosti. * - * @throws SettingsItemNotFoundException * @throws Throwable - * @throws MailingMailCreationException */ public function actionSendReminders(): void { diff --git a/app/AdminModule/CmsModule/Components/DocumentTagsGridControl.php b/app/AdminModule/CmsModule/Components/DocumentTagsGridControl.php index 9484dd9e1..a147e923e 100644 --- a/app/AdminModule/CmsModule/Components/DocumentTagsGridControl.php +++ b/app/AdminModule/CmsModule/Components/DocumentTagsGridControl.php @@ -8,13 +8,12 @@ use App\Model\Cms\Repositories\TagRepository; use App\Model\Cms\Tag; use App\Services\AclService; -use Doctrine\ORM\ORMException; use Nette\Application\AbortException; use Nette\Application\UI\Control; use Nette\Application\UI\Form; use Nette\Forms\Container; use Nette\Forms\Controls\TextInput; -use Nette\Localization\ITranslator; +use Nette\Localization\Translator; use stdClass; use Ublaboo\DataGrid\DataGrid; use Ublaboo\DataGrid\Exception\DataGridException; @@ -28,7 +27,7 @@ */ class DocumentTagsGridControl extends Control { - private ITranslator $translator; + private Translator $translator; private RoleRepository $roleRepository; @@ -37,7 +36,7 @@ class DocumentTagsGridControl extends Control private TagRepository $tagRepository; public function __construct( - ITranslator $translator, + Translator $translator, RoleRepository $roleRepository, AclService $aclService, TagRepository $tagRepository @@ -121,9 +120,6 @@ public function createComponentDocumentTagsGrid(string $name): void /** * Zpracuje přidání štítku dokumentu. - * - * @throws ORMException - * @throws AbortException */ public function add(stdClass $values): void { @@ -135,15 +131,11 @@ public function add(stdClass $values): void $this->tagRepository->save($tag); $this->getPresenter()->flashMessage('admin.cms.documents.tags.message.save_success', 'success'); - - $this->redirect('this'); + $this->getPresenter()->redrawControl('flashes'); } /** * Zpracuje úpravu štítku dokumentu. - * - * @throws ORMException - * @throws AbortException */ public function edit(string $id, stdClass $values): void { @@ -155,14 +147,12 @@ public function edit(string $id, stdClass $values): void $this->tagRepository->save($tag); $this->getPresenter()->flashMessage('admin.cms.documents.tags.message.save_success', 'success'); - - $this->redirect('this'); + $this->getPresenter()->redrawControl('flashes'); } /** * Zpracuje odstranění štítku dokumentu. * - * @throws ORMException * @throws AbortException */ public function handleDelete(int $id): void @@ -170,8 +160,8 @@ public function handleDelete(int $id): void $tag = $this->tagRepository->findById($id); $this->tagRepository->remove($tag); - $this->getPresenter()->flashMessage('admin.cms.documents.tags.message.delete_success', 'success'); - - $this->redirect('this'); + $p = $this->getPresenter(); + $p->flashMessage('admin.cms.documents.tags.message.delete_success', 'success'); + $p->redirect('this'); } } diff --git a/app/AdminModule/CmsModule/Components/DocumentsGridControl.php b/app/AdminModule/CmsModule/Components/DocumentsGridControl.php index ea63287b9..54aea795a 100644 --- a/app/AdminModule/CmsModule/Components/DocumentsGridControl.php +++ b/app/AdminModule/CmsModule/Components/DocumentsGridControl.php @@ -10,13 +10,12 @@ use App\Services\FilesService; use App\Utils\Helpers; use DateTimeImmutable; -use Doctrine\ORM\ORMException; use Nette\Application\AbortException; use Nette\Application\UI\Control; use Nette\Application\UI\Form; use Nette\Forms\Container; use Nette\Http\FileUpload; -use Nette\Localization\ITranslator; +use Nette\Localization\Translator; use Nette\Utils\Html; use stdClass; use Ublaboo\DataGrid\DataGrid; @@ -32,7 +31,7 @@ */ class DocumentsGridControl extends Control { - private ITranslator $translator; + private Translator $translator; private DocumentRepository $documentRepository; @@ -41,7 +40,7 @@ class DocumentsGridControl extends Control private TagRepository $tagRepository; public function __construct( - ITranslator $translator, + Translator $translator, DocumentRepository $documentRepository, TagRepository $tagRepository, FilesService $filesService @@ -95,7 +94,7 @@ public function createComponentDocumentsGrid(string $name): void ->setAttribute('href', $document->getFile()) ->setAttribute('target', '_blank') ->setAttribute('class', 'btn btn-xs btn-secondary') - ->addHtml(Html::el('span')->setAttribute('class', 'fa fa-download')) + ->addHtml(Html::el('span')->setAttribute('class', 'fa fa-file-arrow-down')) ->addText(' ' . basename($document->getFile())); }); @@ -152,9 +151,6 @@ public function createComponentDocumentsGrid(string $name): void /** * Zpracuje přidání dokumentu. - * - * @throws ORMException - * @throws AbortException */ public function add(stdClass $values): void { @@ -172,15 +168,11 @@ public function add(stdClass $values): void $this->documentRepository->save($document); $this->getPresenter()->flashMessage('admin.cms.documents.message.save_success', 'success'); - - $this->redirect('this'); + $this->getPresenter()->redrawControl('flashes'); } /** * Zpracuje úpravu dokumentu. - * - * @throws ORMException - * @throws AbortException */ public function edit(string $id, stdClass $values): void { @@ -202,14 +194,12 @@ public function edit(string $id, stdClass $values): void $this->documentRepository->save($document); $this->getPresenter()->flashMessage('admin.cms.documents.message.save_success', 'success'); - - $this->redirect('this'); + $this->getPresenter()->redrawControl('flashes'); } /** * Zpracuje odstranění dokumentu. * - * @throws ORMException * @throws AbortException */ public function handleDelete(int $id): void @@ -218,8 +208,8 @@ public function handleDelete(int $id): void $this->filesService->delete($document->getFile()); $this->documentRepository->remove($document); - $this->getPresenter()->flashMessage('admin.cms.documents.message.delete_success', 'success'); - - $this->redirect('this'); + $p = $this->getPresenter(); + $p->flashMessage('admin.cms.documents.message.delete_success', 'success'); + $p->redirect('this'); } } diff --git a/app/AdminModule/CmsModule/Components/FaqGridControl.php b/app/AdminModule/CmsModule/Components/FaqGridControl.php index 55adff6de..a9b272538 100644 --- a/app/AdminModule/CmsModule/Components/FaqGridControl.php +++ b/app/AdminModule/CmsModule/Components/FaqGridControl.php @@ -9,7 +9,7 @@ use Doctrine\ORM\ORMException; use Nette\Application\AbortException; use Nette\Application\UI\Control; -use Nette\Localization\ITranslator; +use Nette\Localization\Translator; use Ublaboo\DataGrid\DataGrid; use Ublaboo\DataGrid\Exception\DataGridColumnStatusException; use Ublaboo\DataGrid\Exception\DataGridException; @@ -19,11 +19,11 @@ */ class FaqGridControl extends Control { - private ITranslator $translator; + private Translator $translator; private FaqRepository $faqRepository; - public function __construct(ITranslator $translator, FaqRepository $faqRepository) + public function __construct(Translator $translator, FaqRepository $faqRepository) { $this->translator = $translator; $this->faqRepository = $faqRepository; @@ -93,7 +93,6 @@ public function createComponentFaqGrid(string $name): DataGrid /** * Zpracuje odstranění otázky. * - * @throws ORMException * @throws AbortException */ public function handleDelete(int $id): void @@ -101,9 +100,9 @@ public function handleDelete(int $id): void $faq = $this->faqRepository->findById($id); $this->faqRepository->remove($faq); - $this->getPresenter()->flashMessage('admin.cms.faq.message.delete_success', 'success'); - - $this->redirect('this'); + $p = $this->getPresenter(); + $p->flashMessage('admin.cms.faq.message.delete_success', 'success'); + $p->redirect('this'); } /** @@ -121,10 +120,9 @@ public function handleSort(?string $item_id, ?string $prev_id, ?string $next_id) if ($p->isAjax()) { $p->redrawControl('flashes'); - $faqGrid = $this->getComponent('faqGrid'); - $faqGrid->reload(); + $this->getComponent('faqGrid')->reload(); } else { - $this->redirect('this'); + $p->redirect('this'); } } @@ -146,10 +144,9 @@ public function changeStatus(string $id, string $public): void if ($p->isAjax()) { $p->redrawControl('flashes'); - $faqGrid = $this->getComponent('faqGrid'); - $faqGrid->redrawItem($id); + $this->getComponent('faqGrid')->redrawItem($id); } else { - $this->redirect('this'); + $p->redirect('this'); } } } diff --git a/app/AdminModule/CmsModule/Components/NewsGridControl.php b/app/AdminModule/CmsModule/Components/NewsGridControl.php index c1f67ab4d..2a80af48d 100644 --- a/app/AdminModule/CmsModule/Components/NewsGridControl.php +++ b/app/AdminModule/CmsModule/Components/NewsGridControl.php @@ -9,7 +9,7 @@ use Doctrine\ORM\ORMException; use Nette\Application\AbortException; use Nette\Application\UI\Control; -use Nette\Localization\ITranslator; +use Nette\Localization\Translator; use Ublaboo\DataGrid\DataGrid; use Ublaboo\DataGrid\Exception\DataGridColumnStatusException; use Ublaboo\DataGrid\Exception\DataGridException; @@ -19,11 +19,11 @@ */ class NewsGridControl extends Control { - private ITranslator $translator; + private Translator $translator; private NewsRepository $newsRepository; - public function __construct(ITranslator $translator, NewsRepository $newsRepository) + public function __construct(Translator $translator, NewsRepository $newsRepository) { $this->translator = $translator; $this->newsRepository = $newsRepository; @@ -89,7 +89,6 @@ public function createComponentNewsGrid(string $name): DataGrid /** * Zpracuje odstranění aktuality. * - * @throws ORMException * @throws AbortException */ public function handleDelete(int $id): void @@ -97,9 +96,9 @@ public function handleDelete(int $id): void $news = $this->newsRepository->findById($id); $this->newsRepository->remove($news); - $this->getPresenter()->flashMessage('admin.cms.news.message.delete_success', 'success'); - - $this->redirect('this'); + $p = $this->getPresenter(); + $p->flashMessage('admin.cms.news.message.delete_success', 'success'); + $p->redirect('this'); } /** @@ -119,10 +118,9 @@ public function changePinned(string $id, string $pinned): void if ($p->isAjax()) { $p->redrawControl('flashes'); - $newsGrid = $this->getComponent('newsGrid'); - $newsGrid->redrawItem($id); + $this->getComponent('newsGrid')->redrawItem($id); } else { - $this->redirect('this'); + $p->redirect('this'); } } } diff --git a/app/AdminModule/CmsModule/Components/PagesGridControl.php b/app/AdminModule/CmsModule/Components/PagesGridControl.php index c42ec9852..b91b3ee4a 100644 --- a/app/AdminModule/CmsModule/Components/PagesGridControl.php +++ b/app/AdminModule/CmsModule/Components/PagesGridControl.php @@ -18,7 +18,7 @@ use Nette\Application\UI\Form; use Nette\Forms\Container; use Nette\Forms\Controls\TextInput; -use Nette\Localization\ITranslator; +use Nette\Localization\Translator; use stdClass; use Ublaboo\DataGrid\DataGrid; use Ublaboo\DataGrid\Exception\DataGridColumnStatusException; @@ -33,7 +33,7 @@ */ class PagesGridControl extends Control { - private ITranslator $translator; + private Translator $translator; private CmsService $cmsService; @@ -44,7 +44,7 @@ class PagesGridControl extends Control private AclService $aclService; public function __construct( - ITranslator $translator, + Translator $translator, CmsService $cmsService, PageRepository $pageRepository, RoleRepository $roleRepository, @@ -173,7 +173,6 @@ public function createComponentPagesGrid(string $name): DataGrid /** * Zpracuje přidání stránky. * - * @throws AbortException * @throws NonUniqueResultException * @throws ORMException * @throws OptimisticLockException @@ -189,14 +188,12 @@ public function add(stdClass $values): void $p = $this->getPresenter(); $p->flashMessage('admin.cms.pages.message.save_success', 'success'); - - $this->redirect('this'); + $p->redrawControl('flashes'); } /** * Zpracuje upravení stránky. * - * @throws AbortException * @throws NonUniqueResultException * @throws ORMException * @throws OptimisticLockException @@ -214,16 +211,13 @@ public function edit(string $id, stdClass $values): void $p = $this->getPresenter(); $p->flashMessage('admin.cms.pages.message.save_success', 'success'); - - $this->redirect('this'); + $p->redrawControl('flashes'); } /** * Zpracuje odstranění stránky. * * @throws AbortException - * @throws ORMException - * @throws OptimisticLockException * @throws PageException */ public function handleDelete(int $id): void @@ -231,9 +225,9 @@ public function handleDelete(int $id): void $page = $this->pageRepository->findById($id); $this->cmsService->removePage($page); - $this->getPresenter()->flashMessage('admin.cms.pages.message.delete_success', 'success'); - - $this->redirect('this'); + $p = $this->getPresenter(); + $p->flashMessage('admin.cms.pages.message.delete_success', 'success'); + $p->redirect('this'); } /** @@ -252,10 +246,9 @@ public function handleSort(?string $item_id, ?string $prev_id, ?string $next_id) if ($p->isAjax()) { $p->redrawControl('flashes'); - $pagesGrid = $this->getComponent('pagesGrid'); - $pagesGrid->reload(); + $this->getComponent('pagesGrid')->reload(); } else { - $this->redirect('this'); + $p->redirect('this'); } } @@ -284,10 +277,9 @@ public function changeStatus(string $id, string $public): void if ($p->isAjax()) { $p->redrawControl('flashes'); - $pagesGrid = $this->getComponent('pagesGrid'); - $pagesGrid->redrawItem($id); + $this->getComponent('pagesGrid')->redrawItem($id); } else { - $this->redirect('this'); + $p->redirect('this'); } } } diff --git a/app/AdminModule/CmsModule/Forms/NewsFormFactory.php b/app/AdminModule/CmsModule/Forms/NewsFormFactory.php index 179816f78..fc49eaeb2 100644 --- a/app/AdminModule/CmsModule/Forms/NewsFormFactory.php +++ b/app/AdminModule/CmsModule/Forms/NewsFormFactory.php @@ -8,7 +8,6 @@ use App\Model\Cms\News; use App\Model\Cms\Repositories\NewsRepository; use DateTimeImmutable; -use Doctrine\ORM\ORMException; use Nette; use Nette\Application\UI\Form; use Nextras\FormComponents\Controls\DateTimeControl; @@ -86,8 +85,6 @@ public function create(?int $id): Form /** * Zpracuje formulář. - * - * @throws ORMException */ public function processForm(Form $form, stdClass $values): void { diff --git a/app/AdminModule/CmsModule/Forms/PageForm.php b/app/AdminModule/CmsModule/Forms/PageForm.php index e64961321..e595cce89 100644 --- a/app/AdminModule/CmsModule/Forms/PageForm.php +++ b/app/AdminModule/CmsModule/Forms/PageForm.php @@ -117,6 +117,15 @@ public function render(): void $this->template->render(); } + /** + * Vykreslí skripty komponenty. + */ + public function renderScripts(): void + { + $this->template->setFile(__DIR__ . '/templates/page_form_scripts.latte'); + $this->template->render(); + } + /** * Vytvoří komponentu. * diff --git a/app/AdminModule/CmsModule/Forms/templates/page_form.latte b/app/AdminModule/CmsModule/Forms/templates/page_form.latte index 4e990d18b..8f68991cb 100644 --- a/app/AdminModule/CmsModule/Forms/templates/page_form.latte +++ b/app/AdminModule/CmsModule/Forms/templates/page_form.latte @@ -1,44 +1,3 @@ -{include '../../../Presenters/templates/includes/tinymce_init.latte'} - - - {form form class => form-horizontal}
@@ -202,3 +193,18 @@ {/snippet} {/block} + +{block scripts} + {include #parent} + +{/block} diff --git a/app/AdminModule/Presenters/templates/Users/sidebar.latte b/app/AdminModule/Presenters/templates/Users/sidebar.latte index c4271847e..6f2a0e993 100644 --- a/app/AdminModule/Presenters/templates/Users/sidebar.latte +++ b/app/AdminModule/Presenters/templates/Users/sidebar.latte @@ -1,32 +1,9 @@ -{block head} - {include #parent} - - -{/block} - {block sidebar}

{_admin.users.users_search_heading}

- +
@@ -39,4 +16,22 @@
{/snippet} +{/block} + +{block scripts} + {include #parent} + + {/block} \ No newline at end of file diff --git a/app/AdminModule/Presenters/templates/includes/main_menu.latte b/app/AdminModule/Presenters/templates/includes/main_menu.latte index 7d797b2c6..68f22ea40 100644 --- a/app/AdminModule/Presenters/templates/includes/main_menu.latte +++ b/app/AdminModule/Presenters/templates/includes/main_menu.latte @@ -87,12 +87,12 @@