Merge branch '20-finalisation-cire' into 'master'

Finalisation cire

See merge request Chill-Projet/chill-bundles!529
This commit is contained in:
Mathieu Jaumotte 2023-05-19 08:26:39 +00:00
commit e87420dc57
8 changed files with 47 additions and 43 deletions

View File

@ -2,11 +2,15 @@
<p>{% transchoice total with { '%pattern%' : pattern } %}%total% events match the search %pattern%{% endtranschoice %}</p> <p>{% transchoice total with { '%pattern%' : pattern } %}%total% events match the search %pattern%{% endtranschoice %}</p>
<style>
table.events td:last-child {
width: 15em;
}
</style>
{% if events|length > 0 %} {% if events|length > 0 %}
<p>{{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + events|length, '%total%' : total } ) }}</p> <p>{{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + events|length, '%total%' : total } ) }}</p>
<table class="table table-bordered border-dark align-middle events">
<table class="table events">
<thead> <thead>
<tr> <tr>
<th class="chill-red">{{ 'Name'|trans }}</th> <th class="chill-red">{{ 'Name'|trans }}</th>
@ -25,7 +29,7 @@
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
{# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #} {# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #}
<a href="{{ path('chill_event__event_show', { 'event_id' : event.id } ) }}" class="btn btn-dark"> <a href="{{ path('chill_event__event_show', { 'event_id' : event.id } ) }}" class="btn btn-view">
{{ 'See'|trans }} {{ 'See'|trans }}
</a> </a>
{# {% endif %} #} {# {% endif %} #}

View File

@ -24,7 +24,7 @@
{% block content %} {% block content %}
<h2>{{ 'Events participation' |trans }}</h2> <h2>{{ 'Events participation' |trans }}</h2>
<table class="table table-striped table-bordered mt-3 events"> <table class="table table-striped table-bordered border-dark align-middle mt-3 events">
<thead> <thead>
<tr> <tr>
<th class="chill-green">{{ 'Date'|trans }}</th> <th class="chill-green">{{ 'Date'|trans }}</th>

View File

@ -18,10 +18,10 @@
</a> </a>
</li> </li>
<li> <li>
{{ form_widget(form.submit, { 'attr' : { 'class' : 'btn btn-chill-green' } }) }} {{ form_widget(form.submit, { 'attr' : { 'class' : 'btn btn-submit' } }) }}
</li> </li>
</ul> </ul>
{{ form_end(form) }} {{ form_end(form) }}
</div> </div>
{% endblock %} {% endblock %}

View File

@ -1,14 +1,14 @@
{% extends '@ChillEvent/layout.html.twig' %} {% extends '@ChillEvent/layout.html.twig' %}
{% block title 'Event : %label%'|trans({ '%label%' : event.name } ) %} {% block title 'Event : %label%'|trans({ '%label%' : event.name } ) %}
{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %}
{% block event_content -%} {% block event_content -%}
<div class="col-10"> <div class="col-10">
<h1>{{ 'Details of an event'|trans }}</h1> <h1>{{ 'Details of an event'|trans }}</h1>
<table class="table record_properties"> <table class="table table-bordered border-dark align-middle">
<tbody> <tbody>
<tr> <tr>
<th>{{ 'Name'|trans }}</th> <th>{{ 'Name'|trans }}</th>
@ -33,7 +33,7 @@
</tbody> </tbody>
</table> </table>
<ul class="record_actions"> <ul class="record_actions">
{% set returnPath = app.request.get('return_path') %} {% set returnPath = app.request.get('return_path') %}
@ -64,13 +64,13 @@
</li> </li>
</ul> </ul>
<h2>{{ 'Participations'|trans }}</h2> <h2>{{ 'Participations'|trans }}</h2>
{% set count = event.participations|length %} {% set count = event.participations|length %}
<p>{% transchoice count %}%count% participations to this event{% endtranschoice %}</p> <p>{% transchoice count %}%count% participations to this event{% endtranschoice %}</p>
{% if count > 0 %} {% if count > 0 %}
<table class="table"> <table class="table table-bordered border-dark align-middle">
<thead> <thead>
<tr> <tr>
<th>{{ 'Person'|trans }}</th> <th>{{ 'Person'|trans }}</th>
@ -108,10 +108,10 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% endif %} {% endif %}
<ul class="record_actions"> <ul class="record_actions">
{% if count > 0 %} {% if count > 0 %}
<li><a href="{{ path('chill_event_participation_edit_multiple', { 'event_id' : event.id } ) }}" class="btn btn-edit">{{ 'Edit all the participations'|trans }}</a></li> <li><a href="{{ path('chill_event_participation_edit_multiple', { 'event_id' : event.id } ) }}" class="btn btn-edit">{{ 'Edit all the participations'|trans }}</a></li>

View File

@ -12,13 +12,14 @@ declare(strict_types=1);
namespace Chill\EventBundle\Search; namespace Chill\EventBundle\Search;
use Chill\EventBundle\Entity\Event; use Chill\EventBundle\Entity\Event;
use Chill\EventBundle\Repository\EventRepository;
use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Search\AbstractSearch; use Chill\MainBundle\Search\AbstractSearch;
use Chill\MainBundle\Search\SearchInterface; use Chill\MainBundle\Search\SearchInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Templating\EngineInterface as TemplatingEngine; use Symfony\Component\Templating\EngineInterface as TemplatingEngine;
use function count; use function count;
@ -40,15 +41,17 @@ class EventSearch extends AbstractSearch
{ {
public const NAME = 'event_regular'; public const NAME = 'event_regular';
private $security;
/** /**
* @var EntityRepository * @var EventRepository
*/ */
private $er; private $er;
/** /**
* @var AuthorizationHelper * @var AuthorizationHelper
*/ */
private $helper; private $authorizationHelper;
/** /**
* @var PaginatorFactory * @var PaginatorFactory
@ -60,21 +63,16 @@ class EventSearch extends AbstractSearch
*/ */
private $templating; private $templating;
/**
* @var \Chill\MainBundle\Entity\User
*/
private $user;
public function __construct( public function __construct(
TokenStorageInterface $tokenStorage, Security $security,
EntityRepository $eventRepository, EventRepository $eventRepository,
AuthorizationHelper $authorizationHelper, AuthorizationHelper $authorizationHelper,
TemplatingEngine $templating, TemplatingEngine $templating,
PaginatorFactory $paginatorFactory PaginatorFactory $paginatorFactory
) { ) {
$this->user = $tokenStorage->getToken()->getUser(); $this->security = $security;
$this->er = $eventRepository; $this->er = $eventRepository;
$this->helper = $authorizationHelper; $this->authorizationHelper = $authorizationHelper;
$this->templating = $templating; $this->templating = $templating;
$this->paginationFactory = $paginatorFactory; $this->paginationFactory = $paginatorFactory;
} }
@ -101,7 +99,7 @@ class EventSearch extends AbstractSearch
if ('html' === $format) { if ('html' === $format) {
return $this->templating->render( return $this->templating->render(
'ChillEventBundle:Event:list.html.twig', '@ChillEvent/Event/list.html.twig',
[ [
'events' => $this->search($terms, $start, $limit, $options), 'events' => $this->search($terms, $start, $limit, $options),
'pattern' => $this->recomposePattern($terms, $this->getAvailableTerms(), $terms['_domain']), 'pattern' => $this->recomposePattern($terms, $this->getAvailableTerms(), $terms['_domain']),
@ -140,8 +138,10 @@ class EventSearch extends AbstractSearch
protected function composeQuery(QueryBuilder &$qb, $terms) protected function composeQuery(QueryBuilder &$qb, $terms)
{ {
// add security clauses // add security clauses
$reachableCenters = $this->helper $reachableCenters = $this->authorizationHelper->getReachableCenters(
->getReachableCenters($this->user, 'CHILL_EVENT_SEE'); $this->security->getUser(),
'CHILL_EVENT_SEE'
);
if (count($reachableCenters) === 0) { if (count($reachableCenters) === 0) {
// add a clause to block all events // add a clause to block all events
@ -152,8 +152,9 @@ class EventSearch extends AbstractSearch
$orWhere = $qb->expr()->orX(); $orWhere = $qb->expr()->orX();
foreach ($reachableCenters as $center) { foreach ($reachableCenters as $center) {
$circles = $this->helper->getReachableScopes( $n = $n+1;
$this->user, $circles = $this->authorizationHelper->getReachableScopes(
$this->security->getUser(),
'CHILL_EVENT_SEE', 'CHILL_EVENT_SEE',
$center $center
); );

View File

@ -17,7 +17,7 @@ services:
factory: ['@doctrine.orm.entity_manager', getRepository] factory: ['@doctrine.orm.entity_manager', getRepository]
arguments: arguments:
- 'Chill\EventBundle\Entity\Role' - 'Chill\EventBundle\Entity\Role'
chill_event.repository.status: chill_event.repository.status:
class: Doctrine\ORM\EntityRepository class: Doctrine\ORM\EntityRepository
factory: ['@doctrine.orm.entity_manager', getRepository] factory: ['@doctrine.orm.entity_manager', getRepository]

View File

@ -1,12 +1,11 @@
services: services:
chill_event.search_events: Chill\EventBundle\Search\EventSearch:
class: Chill\EventBundle\Search\EventSearch
arguments: arguments:
- "@security.token_storage" $security: '@Symfony\Component\Security\Core\Security'
- "@chill_event.repository.event" $eventRepository: "@chill_event.repository.event"
- "@chill.main.security.authorization.helper" $authorizationHelper: "@chill.main.security.authorization.helper"
- "@templating" $templating: "@templating"
- "@chill_main.paginator_factory" $paginatorFactory: "@chill_main.paginator_factory"
tags: tags:
- { name: chill.search, alias: 'event_regular' } - { name: chill.search, alias: 'event_regular' }

View File

@ -30,7 +30,7 @@ The event was created: L'événement a été créé
#crud participation #crud participation
Edit all the participations: Modifier toutes les participations Edit all the participations: Modifier toutes les participations
Edit the participation: Modifier la participation Edit the participation: Modifier la participation à l'événement
Participation Edit: Modifier une participation Participation Edit: Modifier une participation
Add a participation: Ajouter un participant Add a participation: Ajouter un participant
Participation creation: Ajouter une participation Participation creation: Ajouter une participation