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>
<style>
table.events td:last-child {
width: 15em;
}
</style>
{% if events|length > 0 %}
<p>{{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + events|length, '%total%' : total } ) }}</p>
<table class="table events">
<table class="table table-bordered border-dark align-middle events">
<thead>
<tr>
<th class="chill-red">{{ 'Name'|trans }}</th>
@ -25,7 +29,7 @@
<ul class="record_actions">
<li>
{# {% 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 }}
</a>
{# {% endif %} #}

View File

@ -24,7 +24,7 @@
{% block content %}
<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>
<tr>
<th class="chill-green">{{ 'Date'|trans }}</th>

View File

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

View File

@ -1,14 +1,14 @@
{% extends '@ChillEvent/layout.html.twig' %}
{% 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 -%}
<div class="col-10">
<h1>{{ 'Details of an event'|trans }}</h1>
<table class="table record_properties">
<table class="table table-bordered border-dark align-middle">
<tbody>
<tr>
<th>{{ 'Name'|trans }}</th>
@ -33,7 +33,7 @@
</tbody>
</table>
<ul class="record_actions">
{% set returnPath = app.request.get('return_path') %}
@ -64,13 +64,13 @@
</li>
</ul>
<h2>{{ 'Participations'|trans }}</h2>
{% set count = event.participations|length %}
<p>{% transchoice count %}%count% participations to this event{% endtranschoice %}</p>
{% if count > 0 %}
<table class="table">
<table class="table table-bordered border-dark align-middle">
<thead>
<tr>
<th>{{ 'Person'|trans }}</th>
@ -108,10 +108,10 @@
{% endfor %}
</tbody>
</table>
{% endif %}
<ul class="record_actions">
{% 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>

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ The event was created: L'événement a été créé
#crud participation
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
Add a participation: Ajouter un participant
Participation creation: Ajouter une participation