mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-03 23:46:12 +00:00
list events by person, add pagination
This commit is contained in:
parent
7abf403463
commit
d07cbb15da
@ -259,11 +259,36 @@ class EventController extends Controller
|
||||
|
||||
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
||||
|
||||
$participations = $em->getRepository('ChillEventBundle:Participation')
|
||||
->findBy(
|
||||
array('person' => $person)
|
||||
);
|
||||
|
||||
$total = $em
|
||||
->createQuery("
|
||||
SELECT COUNT (participation.id)
|
||||
FROM ChillEventBundle:Participation participation
|
||||
WHERE participation.person = :person_id
|
||||
")
|
||||
->setParameter(':person_id', $person_id)
|
||||
->getSingleScalarResult();
|
||||
|
||||
/* @var $paginatorFactory \Chill\MainBundle\Pagination\PaginatorFactory */
|
||||
$paginatorFactory = $this->get('chill_main.paginator_factory');
|
||||
$paginator = $paginatorFactory->create($total);
|
||||
|
||||
$participations = $em
|
||||
->createQuery("
|
||||
SELECT participation
|
||||
FROM ChillEventBundle:Participation participation
|
||||
WHERE participation.person = :person_id
|
||||
")
|
||||
->setParameters(array(
|
||||
':person_id' => $person_id,
|
||||
))
|
||||
->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber())
|
||||
->setMaxResults($paginator->getItemsPerPage())
|
||||
->getResult()
|
||||
;
|
||||
|
||||
|
||||
$privacyEvent = new PrivacyEvent($person, array(
|
||||
'element_class' => Participation::class,
|
||||
'action' => 'list'
|
||||
@ -272,7 +297,8 @@ class EventController extends Controller
|
||||
|
||||
return $this->render('ChillEventBundle:Event:listByPerson.html.twig', array(
|
||||
'participations' => $participations,
|
||||
'person' => $person
|
||||
'person' => $person,
|
||||
'paginator' => $paginator
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -58,11 +58,11 @@
|
||||
<td>
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
{# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #}
|
||||
<a href="{{ path('chill_event__event_show', { 'event_id' : participation.event.id } ) }}" class="sc-button black">
|
||||
{{ 'See'|trans }}
|
||||
</a>
|
||||
{# {% endif %} #}
|
||||
{% if is_granted('CHILL_EVENT_SEE_DETAILS', participation.event) %} #}
|
||||
<a href="{{ path('chill_event__event_show', { 'event_id' : participation.event.id } ) }}" class="sc-button black">
|
||||
{{ 'See'|trans }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_EVENT_UPDATE', participation.event) %}
|
||||
<a href="{{ path('chill_event__event_edit', { 'event_id' : participation.event.id } ) }}" class="sc-button bt-update">
|
||||
{{ 'Edit'|trans }}
|
||||
@ -83,19 +83,22 @@
|
||||
</table>
|
||||
|
||||
|
||||
{% if participations|length < paginator.getTotalItems %}
|
||||
{{ chill_pagination(paginator) }}
|
||||
{% endif %}
|
||||
|
||||
|
||||
<pre>
|
||||
/!\ dev notes
|
||||
=============
|
||||
- problème de cohérence avec le bouton voir et avec le bouton modifier
|
||||
- checker les autorisations pour les boutons
|
||||
- TODO pagination
|
||||
- affichage différencié pour les événements passés/présents/futur
|
||||
- person menu, utiliser authorizationHelper ou authorizationChecker ??
|
||||
</pre>
|
||||
|
||||
{#
|
||||
{{ dump() }}
|
||||
{#
|
||||
#}
|
||||
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user