mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-04 07:56: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);
|
$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(
|
$privacyEvent = new PrivacyEvent($person, array(
|
||||||
'element_class' => Participation::class,
|
'element_class' => Participation::class,
|
||||||
'action' => 'list'
|
'action' => 'list'
|
||||||
@ -272,7 +297,8 @@ class EventController extends Controller
|
|||||||
|
|
||||||
return $this->render('ChillEventBundle:Event:listByPerson.html.twig', array(
|
return $this->render('ChillEventBundle:Event:listByPerson.html.twig', array(
|
||||||
'participations' => $participations,
|
'participations' => $participations,
|
||||||
'person' => $person
|
'person' => $person,
|
||||||
|
'paginator' => $paginator
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,11 @@
|
|||||||
<td>
|
<td>
|
||||||
<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', participation.event) %} #}
|
||||||
<a href="{{ path('chill_event__event_show', { 'event_id' : participation.event.id } ) }}" class="sc-button black">
|
<a href="{{ path('chill_event__event_show', { 'event_id' : participation.event.id } ) }}" class="sc-button black">
|
||||||
{{ 'See'|trans }}
|
{{ 'See'|trans }}
|
||||||
</a>
|
</a>
|
||||||
{# {% endif %} #}
|
{% endif %}
|
||||||
{% if is_granted('CHILL_EVENT_UPDATE', participation.event) %}
|
{% 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">
|
<a href="{{ path('chill_event__event_edit', { 'event_id' : participation.event.id } ) }}" class="sc-button bt-update">
|
||||||
{{ 'Edit'|trans }}
|
{{ 'Edit'|trans }}
|
||||||
@ -83,19 +83,22 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
{% if participations|length < paginator.getTotalItems %}
|
||||||
|
{{ chill_pagination(paginator) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
/!\ dev notes
|
/!\ dev notes
|
||||||
=============
|
=============
|
||||||
- problème de cohérence avec le bouton voir et avec le bouton modifier
|
- problème de cohérence avec le bouton voir et avec le bouton modifier
|
||||||
- checker les autorisations pour les boutons
|
- checker les autorisations pour les boutons
|
||||||
- TODO pagination
|
|
||||||
- affichage différencié pour les événements passés/présents/futur
|
- affichage différencié pour les événements passés/présents/futur
|
||||||
- person menu, utiliser authorizationHelper ou authorizationChecker ??
|
- person menu, utiliser authorizationHelper ou authorizationChecker ??
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
{#
|
|
||||||
{{ dump() }}
|
{{ dump() }}
|
||||||
|
{#
|
||||||
#}
|
#}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user