fix
[wolnelektury.git] / src / oai / handlers.py
index 6d0a9b2..356f51b 100644 (file)
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
@@ -56,7 +55,6 @@ def nsdcterms(name):
     return '{%s}%s' % (NS_DCTERMS, name)
 
 
     return '{%s}%s' % (NS_DCTERMS, name)
 
 
-# WTF
 class Catalogue(common.ResumptionOAIPMH):
     TAG_CATEGORIES = ['author', 'epoch', 'kind', 'genre']
 
 class Catalogue(common.ResumptionOAIPMH):
     TAG_CATEGORIES = ['author', 'epoch', 'kind', 'genre']
 
@@ -70,13 +68,13 @@ class Catalogue(common.ResumptionOAIPMH):
         year_zero = timezone.make_aware(datetime(1990, 1, 1, 0, 0, 0), timezone.utc)
 
         try:
         year_zero = timezone.make_aware(datetime(1990, 1, 1, 0, 0, 0), timezone.utc)
 
         try:
-            earliest_change = Book.objects.order_by('changed_at')[0].changed_at
+            earliest_change = Book.objects.filter(preview=False).order_by('changed_at')[0].changed_at
         except IndexError:
             earliest_change = year_zero
 
         try:
             earliest_delete = \
         except IndexError:
             earliest_change = year_zero
 
         try:
             earliest_delete = \
-                Deleted.objects.exclude(slug__exact=u'').order_by('deleted_at')[0].deleted_at
+                Deleted.objects.exclude(slug__exact='').order_by('deleted_at')[0].deleted_at
         except IndexError:
             earliest_delete = year_zero
 
         except IndexError:
             earliest_delete = year_zero
 
@@ -99,14 +97,14 @@ class Catalogue(common.ResumptionOAIPMH):
         identifier = self.slug_to_identifier(book.slug)
         if isinstance(book, Book):
             # setSpec = map(self.tag_to_setspec, book.tags.filter(category__in=self.TAG_CATEGORIES))
         identifier = self.slug_to_identifier(book.slug)
         if isinstance(book, Book):
             # setSpec = map(self.tag_to_setspec, book.tags.filter(category__in=self.TAG_CATEGORIES))
-            header = common.Header(identifier, make_time_naive(book.changed_at), [], False)
+            header = common.Header(None, identifier, make_time_naive(book.changed_at), [], False)
             if not headers_only:
             if not headers_only:
-                meta = common.Metadata(self.metadata(book))
+                meta = common.Metadata(None, self.metadata(book))
             about = None
         elif isinstance(book, Deleted):
             about = None
         elif isinstance(book, Deleted):
-            header = common.Header(identifier, make_time_naive(book.deleted_at), [], True)
+            header = common.Header(None, identifier, make_time_naive(book.deleted_at), [], True)
             if not headers_only:
             if not headers_only:
-                meta = common.Metadata({})
+                meta = common.Metadata(None, {})
             about = None
         else:
             raise TypeError('Unknown book class')
             about = None
         else:
             raise TypeError('Unknown book class')
@@ -117,7 +115,7 @@ class Catalogue(common.ResumptionOAIPMH):
     def identify(self, **kw):
         ident = common.Identify(
             'Wolne Lektury',  # generate
     def identify(self, **kw):
         ident = common.Identify(
             'Wolne Lektury',  # generate
-            '%s/oaipmh' % unicode(WL_BASE),  # generate
+            '%s/oaipmh' % str(WL_BASE),  # generate
             '2.0',  # version
             [m[1] for m in settings.MANAGERS],  # adminEmails
             make_time_naive(self.earliest_datestamp),  # earliest datestamp of any change
             '2.0',  # version
             [m[1] for m in settings.MANAGERS],  # adminEmails
             make_time_naive(self.earliest_datestamp),  # earliest datestamp of any change
@@ -134,8 +132,8 @@ class Catalogue(common.ResumptionOAIPMH):
             raise error.NoSetHierarchyError("Wolne Lektury does not support sets.")
             # books = Book.tagged.with_all([tag])
         else:
             raise error.NoSetHierarchyError("Wolne Lektury does not support sets.")
             # books = Book.tagged.with_all([tag])
         else:
-            books = Book.objects.all()
-        deleted = Deleted.objects.exclude(slug__exact=u'')
+            books = Book.objects.filter(preview=False)
+        deleted = Deleted.objects.exclude(slug__exact='')
 
         books = books.order_by('changed_at')
         deleted = deleted.order_by('deleted_at')
 
         books = books.order_by('changed_at')
         deleted = deleted.order_by('deleted_at')