-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing the data export configuration for issue #10
- Loading branch information
Showing
24 changed files
with
1,133 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
CREATE TABLE IF NOT EXISTS `cantiga_edk_area_notes` ( | ||
`areaId` int(11) NOT NULL, | ||
`noteType` tinyint(4) NOT NULL, | ||
`content` text NOT NULL, | ||
PRIMARY KEY (`areaId`,`noteType`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
CREATE TABLE IF NOT EXISTS `cantiga_data_export` ( | ||
`id` INT(11) NOT NULL AUTO_INCREMENT, | ||
`name` VARCHAR(40) NOT NULL, | ||
`projectId` INT(11) NOT NULL, | ||
`areaStatusId` INT(11) NULL, | ||
`url` VARCHAR(100) NOT NULL, | ||
`encryptionKey` VARCHAR(128) NOT NULL, | ||
`active` tinyint(1) NOT NULL, | ||
`notes` TEXT NULL, | ||
PRIMARY KEY (`id`), | ||
KEY `projectId` (`projectId`), | ||
KEY `areaStatusId` (`areaStatusId`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
CREATE TABLE IF NOT EXISTS `cantiga_edk_messages` ( | ||
`id` INT(11) NOT NULL AUTO_INCREMENT, | ||
`areaId` INT(11) NOT NULL, | ||
`subject` VARCHAR(100) NOT NULL, | ||
`content` TEXT NOT NULL, | ||
`authorName` VARCHAR(50) NOT NULL, | ||
`authorEmail` VARCHAR(100) NOT NULL, | ||
`authorPhone` VARCHAR(30) NOT NULL, | ||
`createdAt` INT(11) NOT NULL, | ||
`answeredAt` INT(11) NOT NULL, | ||
`completedAt` INT(11) NOT NULL, | ||
`status` TINYINT(1) NOT NULL DEFAULT 0, | ||
`responderId` INT(11) NULL DEFAULT NULL, | ||
PRIMARY KEY (`id`), | ||
KEY `areaId` (`areaId`), | ||
KEY `responderId` (`responderId`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
CREATE TABLE IF NOT EXISTS `cantiga_edk_registration_settings` ( | ||
`routeId` INT(11) NOT NULL, | ||
`areaId` INT(11) NOT NULL, | ||
`registrationType` TINYINT(4) NOT NULL, | ||
`startTime` INT(11) NULL, | ||
`endTime` INT(11) NULL, | ||
`externalRegistrationUrl` VARCHAR(100) NULL, | ||
`participantLimit` INT(11) NULL, | ||
`maxPeoplePerRecord` INT(11) NULL, | ||
`allowLimitExceed` TINYINT(4) NULL, | ||
`participantNum` INT(11) NOT NULL DEFAULT 0, | ||
PRIMARY KEY (`routeId`), | ||
KEY `areaId` (`areaId`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
CREATE TABLE IF NOT EXISTS `cantiga_edk_participants` ( | ||
`id` INT(11) NOT NULL AUTO_INCREMENT, | ||
`accessKey` VARCHAR(40) NOT NULL, | ||
`routeId` INT(11) NOT NULL, | ||
`areaId` INT(11) NOT NULL, | ||
`firstName` VARCHAR(30) NOT NULL, | ||
`lastName` VARCHAR(40) NOT NULL, | ||
`sex` TINYINT(1) NOT NULL, | ||
`age` TINYINT(4) NOT NULL, | ||
`email` VARCHAR(100) NULL, | ||
`peopleNum` TINYINT(1) NOT NULL DEFAULT 1, | ||
`customAnswer` VARCHAR(250), | ||
`whichOnce` TINYINT(4) NOT NULL, | ||
`whyParticipate` VARCHAR(200) NOT NULL, | ||
`findOut` TINYINT(4) NOT NULL, | ||
`findOutOther` VARCHAR(40) NULL, | ||
`confirmationKey` VARCHAR(40) COLLATE utf8_polish_ci NOT NULL, | ||
`termsAccepted` TINYINT(4) NOT NULL, | ||
`isConfirmed` TINYINT(4) NOT NULL DEFAULT '0', | ||
`createdAt` INT(11) NOT NULL, | ||
PRIMARY KEY(`id`), | ||
KEY(`routeId`), | ||
KEY(`areaId`), | ||
KEY `confirmedByArea` (`areaId`,`isConfirmed`), | ||
KEY `byLastName` (`areaId`, `lastName`), | ||
UNIQUE `accessKey` (`accessKey`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
CREATE TABLE IF NOT EXISTS `cantiga_edk_removed_participants` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`areaId` int(11) NOT NULL, | ||
`participantId` int(11) NOT NULL, | ||
`email` varchar(100) COLLATE utf8_polish_ci NOT NULL, | ||
`reason` varchar(150) COLLATE utf8_polish_ci NOT NULL, | ||
`removedAt` int(11) NOT NULL, | ||
`removedById` INT(11) NOT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `participantId` (`participantId`), | ||
KEY `areaId` (`areaId`), | ||
KEY `removedById` (`removedById`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
ALTER TABLE `cantiga_edk_area_notes` | ||
ADD CONSTRAINT `cantiga_edk_area_notes_fk1` FOREIGN KEY (`areaId`) REFERENCES `cantiga_areas` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
ALTER TABLE `cantiga_data_export` | ||
ADD CONSTRAINT `cantiga_data_export_fk1` FOREIGN KEY (`projectId`) REFERENCES `cantiga_projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
ALTER TABLE `cantiga_data_export` | ||
ADD CONSTRAINT `cantiga_data_export_fk2` FOREIGN KEY (`areaStatusId`) REFERENCES `cantiga_area_statuses` (`id`) ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
ALTER TABLE `cantiga_edk_messages` | ||
ADD CONSTRAINT `cantiga_edk_messages_fk1` FOREIGN KEY (`areaId`) REFERENCES `cantiga_areas` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
ALTER TABLE `cantiga_edk_messages` | ||
ADD CONSTRAINT `cantiga_edk_messages_fk2` FOREIGN KEY (`responderId`) REFERENCES `cantiga_users` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE; | ||
|
||
ALTER TABLE `cantiga_edk_registration_settings` | ||
ADD CONSTRAINT `cantiga_edk_registration_settings_fk1` FOREIGN KEY (`routeId`) REFERENCES `cantiga_edk_routes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
ALTER TABLE `cantiga_edk_registration_settings` | ||
ADD CONSTRAINT `cantiga_edk_registration_settings_fk2` FOREIGN KEY (`areaId`) REFERENCES `cantiga_areas` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
ALTER TABLE `cantiga_edk_participants` | ||
ADD CONSTRAINT `cantiga_edk_participants_fk1` FOREIGN KEY (`areaId`) REFERENCES `cantiga_areas` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
ALTER TABLE `cantiga_edk_participants` | ||
ADD CONSTRAINT `cantiga_edk_participants_fk2` FOREIGN KEY (`routeId`) REFERENCES `cantiga_edk_routes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
ALTER TABLE `cantiga_edk_removed_participants` | ||
ADD CONSTRAINT `cantiga_edk_removed_participants_fk1` FOREIGN KEY (`areaId`) REFERENCES `cantiga_areas` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
ALTER TABLE `cantiga_edk_removed_participants` | ||
ADD CONSTRAINT `cantiga_edk_removed_participants_fk2` FOREIGN KEY (`removedById`) REFERENCES `cantiga_users` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/* | ||
* This file is part of Cantiga Project. Copyright 2015 Tomasz Jedrzejewski. | ||
* | ||
* Cantiga Project is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Cantiga Project is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Foobar; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
namespace Cantiga\ExportBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class CantigaExportBundle extends Bundle | ||
{ | ||
|
||
} |
161 changes: 161 additions & 0 deletions
161
src/Cantiga/ExportBundle/Controller/AdminExportController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
<?php | ||
/* | ||
* This file is part of Cantiga Project. Copyright 2015 Tomasz Jedrzejewski. | ||
* | ||
* Cantiga Project is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Cantiga Project is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Foobar; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
namespace Cantiga\ExportBundle\Controller; | ||
|
||
use Cantiga\CoreBundle\Api\Actions\CRUDInfo; | ||
use Cantiga\CoreBundle\Api\Actions\EditAction; | ||
use Cantiga\CoreBundle\Api\Actions\InfoAction; | ||
use Cantiga\CoreBundle\Api\Actions\InsertAction; | ||
use Cantiga\CoreBundle\Api\Actions\RemoveAction; | ||
use Cantiga\CoreBundle\Api\Controller\AdminPageController; | ||
use Cantiga\ExportBundle\Entity\DataExport; | ||
use Cantiga\ExportBundle\Form\DataExportForm; | ||
use Exception; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; | ||
|
||
/** | ||
* @Route("/admin/export") | ||
* @Security("has_role('ROLE_ADMIN')") | ||
*/ | ||
class AdminExportController extends AdminPageController | ||
{ | ||
const REPOSITORY_NAME = 'cantiga.export.repo.export'; | ||
/** | ||
* @var CRUDInfo | ||
*/ | ||
private $crudInfo; | ||
|
||
public function initialize(Request $request, AuthorizationCheckerInterface $authChecker) | ||
{ | ||
$this->crudInfo = $this->newCrudInfo(self::REPOSITORY_NAME) | ||
->setTemplateLocation('CantigaExportBundle:AdminExport:') | ||
->setItemNameProperty('name') | ||
->setPageTitle('Export settings') | ||
->setPageSubtitle('Configure data export to external systems via REST') | ||
->setIndexPage('admin_export_index') | ||
->setInfoPage('admin_export_info') | ||
->setInsertPage('admin_export_insert') | ||
->setEditPage('admin_export_edit') | ||
->setRemovePage('admin_export_remove') | ||
->setItemCreatedMessage('ExportSettingsCreated: 0') | ||
->setItemUpdatedMessage('ExportSettingsUpdated: 0') | ||
->setItemRemovedMessage('ExportSettingsRemoved: 0') | ||
->setRemoveQuestion('ExportSettingsRemoveQuestion: 0'); | ||
|
||
$this->breadcrumbs() | ||
->workgroup('projects') | ||
->entryLink($this->trans('Export settings', [], 'pages'), $this->crudInfo->getIndexPage()); | ||
} | ||
|
||
/** | ||
* @Route("/index", name="admin_export_index") | ||
*/ | ||
public function indexAction(Request $request) | ||
{ | ||
$repository = $this->get(self::REPOSITORY_NAME); | ||
$dataTable = $repository->createDataTable(); | ||
return $this->render($this->crudInfo->getTemplateLocation().'index.html.twig', array( | ||
'pageTitle' => $this->crudInfo->getPageTitle(), | ||
'pageSubtitle' => $this->crudInfo->getPageSubtitle(), | ||
'dataTable' => $dataTable, | ||
'locale' => $request->getLocale(), | ||
'insertPage' => $this->crudInfo->getInsertPage(), | ||
'ajaxListPage' => 'admin_export_ajax_list', | ||
)); | ||
} | ||
|
||
/** | ||
* @Route("/ajax-list", name="admin_export_ajax_list") | ||
*/ | ||
public function ajaxListAction(Request $request) | ||
{ | ||
$routes = $this->dataRoutes() | ||
->link('info_link', 'admin_export_info', ['id' => '::id']) | ||
->link('edit_link', 'admin_export_edit', ['id' => '::id']) | ||
->link('remove_link', 'admin_export_remove', ['id' => '::id']); | ||
|
||
$repository = $this->get(self::REPOSITORY_NAME); | ||
$dataTable = $repository->createDataTable(); | ||
$dataTable->process($request); | ||
return new JsonResponse($routes->process($repository->listData($dataTable))); | ||
} | ||
|
||
/** | ||
* @Route("/ajax-status", name="admin_export_ajax_status") | ||
*/ | ||
public function ajaxStatusAction(Request $request) | ||
{ | ||
$p = $request->get('p'); | ||
try { | ||
$projectRepo = $this->get('cantiga.core.repo.project'); | ||
$statusRepo = $this->get('cantiga.core.repo.project_area_status'); | ||
|
||
$project = $projectRepo->getItem($p); | ||
return new JsonResponse($statusRepo->getFormChoices($project)); | ||
} catch (Exception $ex) { | ||
return new JsonResponse([]); | ||
} | ||
} | ||
|
||
/** | ||
* @Route("/{id}/info", name="admin_export_info") | ||
*/ | ||
public function infoAction($id) | ||
{ | ||
$action = new InfoAction($this->crudInfo); | ||
return $action->run($this, $id); | ||
} | ||
|
||
/** | ||
* @Route("/insert", name="admin_export_insert") | ||
*/ | ||
public function insertAction(Request $request) | ||
{ | ||
$action = new InsertAction($this->crudInfo, new DataExport(), new DataExportForm( | ||
$this->get('cantiga.core.repo.project'), | ||
$this->get('cantiga.core.repo.project_area_status') | ||
)); | ||
return $action->run($this, $request); | ||
} | ||
|
||
/** | ||
* @Route("/{id}/edit", name="admin_export_edit") | ||
*/ | ||
public function editAction($id, Request $request) | ||
{ | ||
$action = new EditAction($this->crudInfo, new DataExportForm( | ||
$this->get('cantiga.core.repo.project'), | ||
$this->get('cantiga.core.repo.project_area_status') | ||
)); | ||
return $action->run($this, $id, $request); | ||
} | ||
|
||
/** | ||
* @Route("/{id}/remove", name="admin_export_remove") | ||
*/ | ||
public function removeAction($id, Request $request) | ||
{ | ||
$action = new RemoveAction($this->crudInfo); | ||
return $action->run($this, $id, $request); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/Cantiga/ExportBundle/DependencyInjection/CantigaExportExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/* | ||
* This file is part of Cantiga Project. Copyright 2015 Tomasz Jedrzejewski. | ||
* | ||
* Cantiga Project is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Cantiga Project is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Foobar; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
namespace Cantiga\ExportBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
|
||
/** | ||
* @author Tomasz Jędrzejewski | ||
*/ | ||
class CantigaExportExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$configuration = new Configuration(); | ||
$config = $this->processConfiguration($configuration, $configs); | ||
|
||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); | ||
$loader->load('services.yml'); | ||
} | ||
} |
Oops, something went wrong.