]> git.parisson.com Git - telemeta.git/commitdiff
remove collection prev next, fix item prev next
authoryomguy <yomguy@parisson.com>
Tue, 15 Feb 2011 10:59:23 +0000 (11:59 +0100)
committeryomguy <yomguy@parisson.com>
Tue, 15 Feb 2011 10:59:23 +0000 (11:59 +0100)
telemeta/urls.py
telemeta/web/base.py

index 0afa28fb86d55f1dd8f28bbaf36b88d2e7393f05..0d9fb499d3b15f94a643b2a58e15734645c858f7 100644 (file)
@@ -110,13 +110,7 @@ urlpatterns = patterns('',
         name="telemeta-collection-m3u"),
     url(r'^collections/(?P<public_id>[A-Za-z0-9._-]+)/edit/$', web_view.collection_detail_edit,
         dict(template='telemeta/collection_detail_edit.html'), name="telemeta-collection-detail-edit"),
-    url(r'^collections/(?P<public_id>[A-Za-z0-9._-]+)/previous/$', 
-        web_view.collection_detail_previous,
-        name="telemeta-collection-detail-previous"),
-    url(r'^collections/(?P<public_id>[A-Za-z0-9._-]+)/next/$', 
-        web_view.collection_detail_next,
-        name="telemeta-collection-detail-next"),
-    
+
     # search
     url(r'^search/$', web_view.search, name="telemeta-search"),
     url(r'^search/collections/$', web_view.search, {'type': 'collections'}, 
index 56adfd1f7412c6f5bfa12efced212fc1e5b93866..20f2f526c2fcf87004c0a01390b502d231046356 100644 (file)
@@ -126,22 +126,6 @@ class WebView(object):
             formset = MediaCollectionFormSet(queryset=MediaCollection.objects.filter(code=public_id))
         return render(request, template, {'collection': collection, "formset": formset,})
 
-    def collection_detail_previous(self, request, public_id):
-        collection = MediaCollection.objects.get(public_id=public_id)
-        while True:
-            previous = MediaCollection.objects.get(pk=collection.pk-1)
-            if previous:
-                break
-        return self.collection_detail(request, previous.public_id)
-    
-    def collection_detail_next(self, request, public_id):
-        collection = MediaCollection.objects.get(public_id=public_id)
-        while True:
-            next = MediaCollection.objects.get(pk=collection.pk+1)
-            if next:
-                break
-        return self.collection_detail(request, next.public_id)
-    
     def item_previous_next(self, item):
         # Get previous and next items
         pks = []
@@ -152,17 +136,20 @@ class WebView(object):
         for pk in pks:
             if pk == item.pk:
                 if pk == pks[0]:
-                    previous = pks[-1]
-                    next = pks[1]
+                    previous_pk = pks[-1]
+                    next_pk = pks[1]
                 elif pk == pks[-1]:
-                    previous = pks[-2]
-                    next = pks[0]
+                    previous_pk = pks[-2]
+                    next_pk = pks[0]
                 else:
-                    previous = pks[pks.index(pk)-1]
-                    next = pks[pks.index(pk)+1]
-                previous = MediaItem.objects.get(pk=previous)
+                    previous_pk = pks[pks.index(pk)-1]
+                    next_pk = pks[pks.index(pk)+1]
+                for it in items:
+                    if it.pk == previous_pk:
+                        previous = it
+                    if it.pk == next_pk:
+                        next = it
                 previous = previous.public_id
-                next = MediaItem.objects.get(pk=next)
                 next = next.public_id
         return previous, next