Jelajahi Sumber

Suppression film uniquement par admin

François 6 tahun lalu
induk
melakukan
b9a18becd5

+ 2 - 0
src/AppBundle/Controller/VideothequeController.php

@@ -2,6 +2,7 @@
 
 namespace AppBundle\Controller;
 
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 use Symfony\Component\Routing\Annotation\Route;
 use Symfony\Component\HttpFoundation\Request;
@@ -83,6 +84,7 @@ class VideothequeController extends Controller
 
 	/**
 	 * @Route("/supprimer/{id}", name="videotheque_supprimer")
+     * @Security("has_role('ROLE_ADMIN')")
 	 */
 	public function supprimerAction(Request $request, Film $film)
 	{

+ 11 - 8
src/AppBundle/Resources/views/videotheque/liste.html.twig

@@ -6,7 +6,8 @@
 	<table class="table table-bordered table-hover table-sm">
 	<thead class="thead-dark">
 		<tr>
-			<th>Auteur</th>
+			<th>Voir</th>
+			<th>Ajouté par</th>
 			<th>Titre du film</th>
 			<th>Réalisateur</th>
 			<th>Année</th>
@@ -18,6 +19,14 @@
 	<tbody>
 		{% for film in listeFilms %}
 		<tr>
+			<td>
+                {%  if film.usersWantToView.contains(app.user) %}
+					<a href="#" class="boutonVoir" data-content="{{ film.id }}"><i class="fas fa-star"></i></a>
+                {%  else %}
+					<a href="#" class="boutonVoir" data-content="{{ film.id }}"><i class="far fa-star"></i></a>
+
+                {%  endif %}
+			</td>
 			<td>{%  if film.authered is defined %}{{ film.authered.username }}{% endif %}</td>
 			<td>{{ film.titre }}</td>
 			<td>
@@ -33,14 +42,8 @@
 			<td>{{ film.commentaire }}</td>
 			<td>{{ film.note }}</td>
 			<td>
-				<a href="{{ path('videotheque_supprimer', {'id': film.id})  }}"><i class="fas fa-trash", style="color:Tomato;"></i></a>
+				{% if is_granted('ROLE_ADMIN') %}<a href="{{ path('videotheque_supprimer', {'id': film.id})  }}"><i class="fas fa-trash", style="color:Tomato;"></i></a>{% endif %}
 				<a href="{{ path('videotheque_modifier', {'id': film.id})  }}"><i class="fas fa-edit", style="color:DodgerBlue;"></i></a>
-				{%  if film.usersWantToView.contains(app.user) %}
-					<a href="#" class="boutonVoir" data-content="{{ film.id }}"><i class="fas fa-star"></i></a>
-				{%  else %}
-					<a href="#" class="boutonVoir" data-content="{{ film.id }}"><i class="far fa-star"></i></a>
-
-				{%  endif %}
 			</td>
 		</tr>
 		{% endfor %}