Kaynağa Gözat

Evolution #738: Playlist

Sevajol Bastien 11 yıl önce
ebeveyn
işleme
12847c8bef

+ 13 - 0
src/Muzich/CoreBundle/Resources/public/js/muzich.js Dosyayı Görüntüle

@@ -3202,6 +3202,19 @@ $(document).ready(function(){
3202 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 3218
   $('ul.playlist_elements a.remove_element').live('click', function () {
3206 3219
     
3207 3220
     $.getJSON($(this).attr('href'), function(response) {

+ 11 - 0
src/Muzich/PlaylistBundle/Controller/EditController.php Dosyayı Görüntüle

@@ -106,4 +106,15 @@ class EditController extends Controller
106 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 Dosyayı Görüntüle

@@ -31,7 +31,8 @@ class ShowController extends Controller
31 31
       return $this->redirect($this->generateUrl('playlists_user', array('user_slug' => $user_slug)));
32 32
     
33 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 Dosyayı Görüntüle

@@ -14,6 +14,10 @@ playlist_unpick:
14 14
   pattern: /playlist/unpick/{playlist_id}
15 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 21
 playlist_datas_for_autoplay:
18 22
   pattern: /ajax/autoplay/playlist/datas/{playlist_id}/{offset}
19 23
   defaults: { _controller: MuzichPlaylistBundle:Show:getAutoplayData, offset: null }

+ 14 - 0
src/Muzich/PlaylistBundle/Resources/views/Show/show.html.twig Dosyayı Görüntüle

@@ -11,6 +11,20 @@
11 11
       Lire
12 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 28
     <h2>{{ playlist.name }}</h2>
15 29
     
16 30
     {% include "MuzichCoreBundle:Tag:tag_cloud.html.twig" with {

+ 27 - 8
src/Muzich/PlaylistBundle/Resources/views/Show/user.html.twig Dosyayı Görüntüle

@@ -18,16 +18,35 @@
18 18
           {{ playlist.name }}
19 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 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 50
         {% include "MuzichCoreBundle:Tag:tag_cloud.html.twig" with {
32 51
           'tags' : playlist.tags
33 52
         } %}