Commit 6508de39 authored by SpinShare's avatar SpinShare

hotfix, let users only add a review once

parent d1e3f483
......@@ -55,6 +55,9 @@ class SongController extends AbstractController
$data['activeAction'] = $request->query->get('action');
if($this->getUser() != null) {
$resultUserReview = $em->getRepository(SongReview::class)->findBy(array('user' => $this->getUser()));
$data['userReview'] = $resultUserReview;
if($this->getUser() != $resultUploader) {
if($request->request->get('submitReview') && !empty($request->request->get('reviewRecommended'))) {
$newReview = new SongReview();
......@@ -84,6 +87,8 @@ class SongController extends AbstractController
return $this->redirectToRoute('song.detail', ['songId' => $resultSong->getId(), 'tab' => 'spinplays']);
}
} else {
$data['userReview'] = false;
}
return $this->render('song/detail.html.twig', $data);
......
......@@ -47,23 +47,25 @@
<i class="mdi mdi-flag-outline"></i>
</div>
</a>
{% if uploader.id == app.user.id %}
<a href="{{ path('song.update', {songId: song.id}) }}" class="action">
<div class="icon">
<i class="mdi mdi-pencil"></i>
</div>
</a>
<a href="{{ path('song.delete', {songId: song.id}) }}" class="action">
<div class="icon">
<i class="mdi mdi-delete"></i>
</div>
</a>
{% elseif is_granted('ROLE_MODERATOR') %}
<a href="{{ path('moderation.song.remove', {songId: song.id}) }}" onclick="return confirm('Are you sure? This action cannot be undone!')" class="action">
<div class="icon">
<i class="mdi mdi-delete"></i>
</div>
</a>
{% if is_granted('ROLE_USER') %}
{% if uploader.id == app.user.id %}
<a href="{{ path('song.update', {songId: song.id}) }}" class="action">
<div class="icon">
<i class="mdi mdi-pencil"></i>
</div>
</a>
<a href="{{ path('song.delete', {songId: song.id}) }}" class="action">
<div class="icon">
<i class="mdi mdi-delete"></i>
</div>
</a>
{% elseif is_granted('ROLE_MODERATOR') %}
<a href="{{ path('moderation.song.remove', {songId: song.id}) }}" onclick="return confirm('Are you sure? This action cannot be undone!')" class="action">
<div class="icon">
<i class="mdi mdi-delete"></i>
</div>
</a>
{% endif %}
{% endif %}
</div>
<div class="song-statistics">
......@@ -160,7 +162,9 @@
</div>
{% if app.user != uploader %}
{% if is_granted('ROLE_USER') %}
<a href="{{ path('song.detail', {songId: song.id, tab: 'reviews', action: 'add'}) }}" class="action-button">Add Review</a>
{% if userReview == false %}
<a href="{{ path('song.detail', {songId: song.id, tab: 'reviews', action: 'add'}) }}" class="action-button">Add Review</a>
{% endif %}
{% else %}
<a href="{{ path('fos_user_security_login') }}" class="action-button">Login to Review</a>
{% endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment