Browse Source

Evolution #738: Playlist

Sevajol Bastien 11 years ago
parent
commit
12847c8bef

+ 13 - 0
src/Muzich/CoreBundle/Resources/public/js/muzich.js View File

3202
     return false;
3202
     return false;
3203
   });
3203
   });
3204
   
3204
   
3205
+  $('a.playlist_pick').live('click', function(){
3206
+    $.getJSON($(this).attr('href'), function(response) {
3207
+      window.ResponseController.execute(
3208
+        response,
3209
+        function(){},
3210
+        function(){}
3211
+      );
3212
+    });
3213
+    
3214
+    return false;
3215
+  });
3216
+  
3217
+  
3205
   $('ul.playlist_elements a.remove_element').live('click', function () {
3218
   $('ul.playlist_elements a.remove_element').live('click', function () {
3206
     
3219
     
3207
     $.getJSON($(this).attr('href'), function(response) {
3220
     $.getJSON($(this).attr('href'), function(response) {

+ 11 - 0
src/Muzich/PlaylistBundle/Controller/EditController.php View File

106
     return $this->redirect($this->generateUrl('playlists_user', array('user_slug' => $this->getUser()->getSlug())));
106
     return $this->redirect($this->generateUrl('playlists_user', array('user_slug' => $this->getUser()->getSlug())));
107
   }
107
   }
108
   
108
   
109
+  public function pickAction($playlist_id)
110
+  {
111
+    if (!($playlist = $this->getPlaylistManager()->findOneAccessiblePlaylistWithId($playlist_id)))
112
+      return $this->jsonNotFoundResponse();
113
+    
114
+    $this->getPlaylistManager()->addPickedPlaylistToUser($this->getUser(), $playlist);
115
+    $this->flush();
116
+    
117
+    return $this->jsonSuccessResponse();
118
+  }
119
+  
109
 }
120
 }

+ 2 - 1
src/Muzich/PlaylistBundle/Controller/ShowController.php View File

31
       return $this->redirect($this->generateUrl('playlists_user', array('user_slug' => $user_slug)));
31
       return $this->redirect($this->generateUrl('playlists_user', array('user_slug' => $user_slug)));
32
     
32
     
33
     return $this->render('MuzichPlaylistBundle:Show:show.html.twig', array(
33
     return $this->render('MuzichPlaylistBundle:Show:show.html.twig', array(
34
-      'playlist' => $playlist
34
+      'playlist'    => $playlist,
35
+      'viewed_user' => $viewed_user
35
     ));
36
     ));
36
   }
37
   }
37
   
38
   

+ 4 - 0
src/Muzich/PlaylistBundle/Resources/config/routing.yml View File

14
   pattern: /playlist/unpick/{playlist_id}
14
   pattern: /playlist/unpick/{playlist_id}
15
   defaults: { _controller: MuzichPlaylistBundle:Edit:unpick }
15
   defaults: { _controller: MuzichPlaylistBundle:Edit:unpick }
16
 
16
 
17
+playlist_pick:
18
+  pattern: /playlist/pick/{playlist_id}
19
+  defaults: { _controller: MuzichPlaylistBundle:Edit:pick }
20
+
17
 playlist_datas_for_autoplay:
21
 playlist_datas_for_autoplay:
18
   pattern: /ajax/autoplay/playlist/datas/{playlist_id}/{offset}
22
   pattern: /ajax/autoplay/playlist/datas/{playlist_id}/{offset}
19
   defaults: { _controller: MuzichPlaylistBundle:Show:getAutoplayData, offset: null }
23
   defaults: { _controller: MuzichPlaylistBundle:Show:getAutoplayData, offset: null }

+ 14 - 0
src/Muzich/PlaylistBundle/Resources/views/Show/show.html.twig View File

11
       Lire
11
       Lire
12
     </a>
12
     </a>
13
     
13
     
14
+    {% if app.user %}
15
+      {% if not playlist.owned(app.user) and viewed_user.id != app.user.id %}
16
+        {% if not app.user.havePlaylistPicked(playlist) %}
17
+          <a class="playlist_pick" href="{{ path('playlist_pick', { 'playlist_id' : playlist.id }) }}" >
18
+            P
19
+          </a>
20
+        {% else %}
21
+          <a class="playlist_unpick" href="{{ path('playlist_unpick', { 'playlist_id' : playlist.id }) }}" >
22
+            uP
23
+          </a>
24
+        {% endif %}
25
+      {% endif %}
26
+    {% endif %}
27
+    
14
     <h2>{{ playlist.name }}</h2>
28
     <h2>{{ playlist.name }}</h2>
15
     
29
     
16
     {% include "MuzichCoreBundle:Tag:tag_cloud.html.twig" with {
30
     {% include "MuzichCoreBundle:Tag:tag_cloud.html.twig" with {

+ 27 - 8
src/Muzich/PlaylistBundle/Resources/views/Show/user.html.twig View File

18
           {{ playlist.name }}
18
           {{ playlist.name }}
19
         </a>
19
         </a>
20
         
20
         
21
-        {% if playlist.owned(app.user) %}
22
-          <a class="" href="{{ path('playlist_delete', { 'playlist_id' : playlist.id }) }}" >
23
-            X
24
-          </a>
25
-        {% else %}
26
-          <a class="" href="{{ path('playlist_unpick', { 'playlist_id' : playlist.id }) }}" >
27
-            X
28
-          </a>
21
+        {% if app.user %}
22
+          {% if viewed_user.id == app.user.id %}
23
+            {% if playlist.owned(app.user) %}
24
+              <a class="playlist_delete" href="{{ path('playlist_delete', { 'playlist_id' : playlist.id }) }}" >
25
+                X
26
+              </a>
27
+            {% else %}
28
+              <a class="playlist_unpick" href="{{ path('playlist_unpick', { 'playlist_id' : playlist.id }) }}" >
29
+                X
30
+              </a>
31
+            {% endif %}
32
+          {% endif %}
29
         {% endif %}
33
         {% endif %}
30
         
34
         
35
+        {% if app.user %}
36
+          {% if not playlist.owned(app.user) and viewed_user.id != app.user.id %}
37
+            {% if not app.user.havePlaylistPicked(playlist) %}
38
+              <a class="playlist_pick" href="{{ path('playlist_pick', { 'playlist_id' : playlist.id }) }}" >
39
+                P
40
+              </a>
41
+            {% else %}
42
+              <a class="playlist_unpick" href="{{ path('playlist_unpick', { 'playlist_id' : playlist.id }) }}" >
43
+                uP
44
+              </a>
45
+            {% endif %}
46
+          {% endif %}
47
+        {% endif %}
48
+      
49
+        
31
         {% include "MuzichCoreBundle:Tag:tag_cloud.html.twig" with {
50
         {% include "MuzichCoreBundle:Tag:tag_cloud.html.twig" with {
32
           'tags' : playlist.tags
51
           'tags' : playlist.tags
33
         } %}
52
         } %}