fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Re-enable main crowdfunding banner.
[wolnelektury.git]
/
apps
/
catalogue
/
models
/
book.py
diff --git
a/apps/catalogue/models/book.py
b/apps/catalogue/models/book.py
index
ea85645
..
e80b8af
100644
(file)
--- a/
apps/catalogue/models/book.py
+++ b/
apps/catalogue/models/book.py
@@
-194,20
+194,20
@@
class Book(models.Model):
paths = map(lambda bm: (None, bm.file.path), bm)
return create_zip(paths, "%s_%s" % (self.slug, format_))
paths = map(lambda bm: (None, bm.file.path), bm)
return create_zip(paths, "%s_%s" % (self.slug, format_))
- def search_index(self, book_info=None,
reuse_index=False, index_tags
=True):
+ def search_index(self, book_info=None,
index=None, index_tags=True, commit
=True):
import search
import search
- if reuse_index:
- idx = search.ReusableIndex()
- else:
- idx = search.Index()
-
- idx.open()
+ if index is None:
+ index = search.Index()
try:
try:
- i
d
x.index_book(self, book_info)
+ i
nde
x.index_book(self, book_info)
if index_tags:
if index_tags:
- idx.index_tags()
- finally:
- idx.close()
+ index.index_tags()
+ if commit:
+ index.index.commit()
+ except Exception, e:
+ index.index.rollback()
+ raise e
+
@classmethod
def from_xml_file(cls, xml_file, **kwargs):
@classmethod
def from_xml_file(cls, xml_file, **kwargs):
@@
-228,7
+228,7
@@
class Book(models.Model):
@classmethod
def from_text_and_meta(cls, raw_file, book_info, overwrite=False,
dont_build=None, search_index=True,
@classmethod
def from_text_and_meta(cls, raw_file, book_info, overwrite=False,
dont_build=None, search_index=True,
- search_index_tags=True
, search_index_reuse=False
):
+ search_index_tags=True):
if dont_build is None:
dont_build = set()
dont_build = set.union(set(dont_build), set(app_settings.DONT_BUILD))
if dont_build is None:
dont_build = set()
dont_build = set.union(set(dont_build), set(app_settings.DONT_BUILD))
@@
-315,8
+315,7
@@
class Book(models.Model):
getattr(book, '%s_file' % format_).build_delay()
if not settings.NO_SEARCH_INDEX and search_index:
getattr(book, '%s_file' % format_).build_delay()
if not settings.NO_SEARCH_INDEX and search_index:
- book.search_index(index_tags=search_index_tags, reuse_index=search_index_reuse)
- #index_book.delay(book.id, book_info)
+ tasks.index_book.delay(book.id, book_info=book_info, index_tags=search_index_tags)
for child in notify_cover_changed:
child.parent_cover_changed()
for child in notify_cover_changed:
child.parent_cover_changed()
@@
-561,6
+560,7
@@
class Book(models.Model):
return books_by_author, orphans, books_by_parent
_audiences_pl = {
return books_by_author, orphans, books_by_parent
_audiences_pl = {
+ "SP": (1, u"szkoła podstawowa"),
"SP1": (1, u"szkoła podstawowa"),
"SP2": (1, u"szkoła podstawowa"),
"P": (1, u"szkoła podstawowa"),
"SP1": (1, u"szkoła podstawowa"),
"SP2": (1, u"szkoła podstawowa"),
"P": (1, u"szkoła podstawowa"),
@@
-570,7
+570,7
@@
class Book(models.Model):
}
def audiences_pl(self):
audiences = self.extra_info.get('audiences', [])
}
def audiences_pl(self):
audiences = self.extra_info.get('audiences', [])
- audiences = sorted(set([self._audiences_pl
[a]
for a in audiences]))
+ audiences = sorted(set([self._audiences_pl
.get(a, (99, a))
for a in audiences]))
return [a[1] for a in audiences]
def choose_fragment(self):
return [a[1] for a in audiences]
def choose_fragment(self):