Merge branch 'master' into social_action_exports

This commit is contained in:
2022-07-28 15:45:46 +02:00
73 changed files with 1108 additions and 757 deletions

View File

@@ -92,5 +92,8 @@ final class PostalCodeAPIController extends ApiController
$qb->where('e.country = :country')
->setParameter('country', $request->query->get('country'));
}
$qb->andWhere('e.origin = :zero')
->setParameter('zero', 0);
}
}

View File

@@ -12,7 +12,9 @@ declare(strict_types=1);
namespace Chill\MainBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class UserApiController extends ApiController
@@ -58,4 +60,14 @@ class UserApiController extends ApiController
['groups' => ['read']]
);
}
/**
* @param QueryBuilder $query
*/
protected function customizeQuery(string $action, Request $request, $query): void
{
if ('_index' === $action) {
$query->andWhere($query->expr()->eq('e.enabled', "'TRUE'"));
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\MainBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Symfony\Component\HttpFoundation\Request;
class UserJobApiController extends ApiController
{
protected function customizeQuery(string $action, Request $request, $query): void
{
if ('_index' === $action) {
$query->andWhere($query->expr()->eq('e.active', "'TRUE'"));
}
}
}

View File

@@ -19,6 +19,7 @@ use Chill\MainBundle\Controller\LanguageController;
use Chill\MainBundle\Controller\LocationController;
use Chill\MainBundle\Controller\LocationTypeController;
use Chill\MainBundle\Controller\UserController;
use Chill\MainBundle\Controller\UserJobApiController;
use Chill\MainBundle\Controller\UserJobController;
use Chill\MainBundle\DependencyInjection\Widget\Factory\WidgetFactoryInterface;
use Chill\MainBundle\Doctrine\DQL\GetJsonFieldByKey;
@@ -501,6 +502,7 @@ class ChillMainExtension extends Extension implements
'name' => 'user_job',
'base_path' => '/api/1.0/main/user-job',
'base_role' => 'ROLE_USER',
'controller' => UserJobApiController::class,
'actions' => [
'_index' => [
'methods' => [

View File

@@ -75,8 +75,6 @@ class PickCenterType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$export = $this->exportManager->getExport($options['export_alias']);
$centers = $this->authorizationHelper->getReachableCenters(
$this->user,

View File

@@ -119,8 +119,8 @@ final class PostalCodeRepository implements ObjectRepository
$pertinenceClause = ['STRICT_WORD_SIMILARITY(canonical, UNACCENT(?))'];
$pertinenceArgs = [$pattern];
$orWhere = ['canonical %>> UNACCENT(?)'];
$orWhereArgs = [$pattern];
$andWhere = ['canonical %>> UNACCENT(?)'];
$andWhereArgs = [$pattern];
foreach (explode(' ', $pattern) as $part) {
$part = trim($part);
@@ -129,8 +129,8 @@ final class PostalCodeRepository implements ObjectRepository
continue;
}
$orWhere[] = "canonical LIKE '%' || UNACCENT(LOWER(?)) || '%'";
$orWhereArgs[] = $part;
$andWhere[] = "canonical LIKE '%' || UNACCENT(LOWER(?)) || '%'";
$andWhereArgs[] = $part;
$pertinenceClause[] =
"(EXISTS (SELECT 1 FROM unnest(string_to_array(canonical, ' ')) AS t WHERE starts_with(t, UNACCENT(LOWER(?)))))::int";
$pertinenceClause[] =
@@ -139,7 +139,7 @@ final class PostalCodeRepository implements ObjectRepository
}
$query
->setSelectPertinence(implode(' + ', $pertinenceClause), $pertinenceArgs)
->andWhereClause(implode(' OR ', $orWhere), $orWhereArgs);
->andWhereClause(implode(' AND ', $andWhere), $andWhereArgs);
return $query;
}

View File

@@ -47,12 +47,12 @@ final class Version20210505153727 extends AbstractMigration
');
$this->addSql('
WITH hydrated_addresses AS (
SELECT *, rank() OVER (PARTITION BY pa_a.person_id ORDER BY validfrom)
SELECT *, rank() OVER (PARTITION BY pa_a.person_id ORDER BY validfrom, id)
FROM chill_main_address AS aa JOIN chill_person_persons_to_addresses AS pa_a ON aa.id = pa_a.address_id
)
UPDATE chill_main_address AS b
SET validto = (
SELECT validfrom - INTERVAL \'1 DAY\'
SELECT validfrom
FROM hydrated_addresses
WHERE hydrated_addresses.id = (
SELECT a1.id

View File

@@ -0,0 +1,39 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20220711150006 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_main_workflow_entity_step
DROP CONSTRAINT chill_custom_only_one_step_opened');
}
public function getDescription(): string
{
return 'Add a constraint to ensure that only one step is available at a time';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_main_workflow_entity_step
ADD CONSTRAINT chill_custom_only_one_step_opened
EXCLUDE (
entityworkflow_id WITH =
) WHERE (transitionafter IS NULL)
DEFERRABLE INITIALLY DEFERRED');
}
}