]> git.parisson.com Git - telemeta.git/commitdiff
add method to retrieve items that do not belong to any collection
authorolivier <>
Tue, 22 May 2007 14:25:40 +0000 (14:25 +0000)
committerolivier <>
Tue, 22 May 2007 14:25:40 +0000 (14:25 +0000)
telemeta/models.py

index e59f09304b081af66f8bee42154c15c3e0d11411..00f94a1e404317e6aef5d966bb9e9a33dbaadeb0 100644 (file)
@@ -16,7 +16,7 @@ from django.conf import settings
 import telemeta
 from telemeta.core import *
 from telemeta import dublincore as dc
-from xml.dom import getDOMImplementation
+from xml.dom.minidom import getDOMImplementation
 
 # Regular (sub) expression for matching/validating media objects IDs
 media_id_regex = r'[0-9A-Za-z._:%?-]+'
@@ -205,6 +205,12 @@ class MediaItemManager(models.Manager):
             Q(_title__icontains=pattern) 
         )
 
+    def without_collection(self):        
+        "Find items which do not belong to any collection"
+        qs = super(MediaItemManager, self).get_query_set()
+        return qs.extra(
+            where = ["collection_id NOT IN (SELECT id FROM telemeta_collection)"]);
+
 class MediaItem(models.Model, MediaCore):
     "Describe a item with metadata"