This commit is contained in:
Marc Ducobu 2016-03-23 18:22:17 +01:00
commit 2cb4ee8bb9
7 changed files with 90 additions and 35 deletions

View File

@ -91,21 +91,21 @@ class EventController extends Controller
* Finds and displays a Event entity.
*
*/
public function showAction($id)
public function showAction($event_id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('ChillEventBundle:Event')->find($id);
$entity = $em->getRepository('ChillEventBundle:Event')->find($event_id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Event entity.');
}
$deleteForm = $this->createDeleteForm($id);
$this->denyAccessUnlessGranted('CHILL_EVENT_SEE_DETAILS', $entity,
"You are not allowed to see details on this event");
return $this->render('ChillEventBundle:Event:show.html.twig', array(
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
'event' => $entity
));
}

View File

@ -3,7 +3,7 @@ event:
defaults: { _controller: "ChillEventBundle:Event:index" }
event_show:
path: /{id}/show
path: /{event_id}/show
defaults: { _controller: "ChillEventBundle:Event:show" }
event_new:

View File

@ -3,8 +3,17 @@ Name: Nom
Date: Date
Event type : Type d'événement
See: Voir
Event: Événement
'Event : %label%': Événement "%label%"
Participation: Participation
Status: Statut
Last update: Dernière mise à jour
'%count% participations to this event': '{0} Aucun participant à l''événement | {1} Un participant à l''événement | ]1,Inf] %count% participants à l''événement'
#CRUD
Details of an event: Détails d'un événement
Edit all the participations: Modifier toutes les participations
#search
Event search: Recherche d'événements

View File

@ -22,11 +22,11 @@
<td>
<ul class="record_actions">
<li>
{% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %}
<a href="#" class="sc-button btn-action">
{# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #}
<a href="{{ path('event_show', { 'event_id' : event.id } ) }}" class="sc-button btn-action">
{{ 'See'|trans }}
</a>
{% endif %}
{# {% endif %} #}
{% if is_granted('CHILL_EVENT_UPDATE', event) %}
<a href="#" class="sc-button btn-edit">
{{ 'Edit'|trans }}

View File

@ -1,36 +1,81 @@
{% extends '::base.html.twig' %}
{% extends 'ChillEventBundle::layout.html.twig' %}
{% block body -%}
<h1>Event</h1>
{% block title 'Event : %label%'|trans({ '%label%' : event.label } ) %}
{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %}
{% block event_content -%}
<h1>{{ 'Details of an event'|trans }}</h1>
<table class="record_properties">
<tbody>
<tr>
<th>Id</th>
<td>{{ entity.id }}</td>
<th>{{ 'Name'|trans }}</th>
<td>{{ event.label }}</td>
</tr>
<tr>
<th>Label</th>
<td>{{ entity.label }}</td>
<th>{{ 'Date'|trans }}</th>
<td>{{ event.date|localizeddate('long', 'none') }}</td>
</tr>
<tr>
<th>Date</th>
<td>{{ entity.date|date('Y-m-d H:i:s') }}</td>
<th>{{ 'Event type'|trans }}</th>
<td>{{ event.type.label|localize_translatable_string }}</td>
</tr>
<tr>
<th>{{ 'Circle'|trans }}</th>
<td>{{ event.circle.name|localize_translatable_string }}</td>
</tr>
</tbody>
</table>
<ul class="record_actions">
<li>
<a href="{{ path('event') }}">
Back to the list
<a href="{{ path('event_edit', { 'id': event.id }) }}" class="sc-button btn-edit">
{{ 'Edit'|trans }}
</a>
</li>
</ul>
<h2>{{ 'Participation'|trans }}</h2>
{% set count = event.participations|length %}
<p>{% transchoice count %}%count% participations to this event{% endtranschoice %}</p>
{% if count > 0 %}
<table>
<thead>
<tr>
<th>{{ 'Person'|trans }}</th>
<th>{{ 'Role'|trans }}</th>
<th>{{ 'Status'|trans }}</th>
<th>{{ 'Last update'|trans }}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{% for participation in event.participations %}
<tr>
<td>{{ person_macro.render(participation.person) }}</td>
<td>{{ participation.role.label|localize_translatable_string }}</td>
<td>{{ participation.status.label|localize_translatable_string }}</td>
<td>{{ participation.lastUpdate|localizeddate("long", "none") }}</td>
<td>
<ul class="record_actions">
<li>
<a href="{{ path('event_edit', { 'id': entity.id }) }}">
Edit
<a href="#" class="sc-button btn-edit">
{{ 'Edit'|trans }}
</a>
</li>
<li>{{ form(delete_form) }}</li>
</ul>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul class="record_actions">
<li><a href="#" class="sc-button btn-edit">{{ 'Edit all the participations'|trans }}</a></li>
</ul>
{% endif %}
{% endblock %}

View File

@ -25,7 +25,7 @@
{% endblock %}
{% block layout_wvm_content %}
{% block event_content %}}<!-- block event content empty -->
{% block event_content %}<!-- block event content empty -->
<h1>{{ 'Event' |trans }}</h1>
{% endblock %}
{% endblock %}

View File

@ -8,6 +8,7 @@ use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
use Chill\MainBundle\Security\ProvideRoleInterface;
use Chill\EventBundle\Entity\Event;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Entity\User;
/**
* Description of EventVoter
@ -47,7 +48,7 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleInterface
return false;
}
return $this->helper->userHasAccess($user, $event, $attribute);
return $this->authorizationHelper->userHasAccess($user, $event, $attribute);
}
public function getRoles()