X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/967eed676fc83d15b26149047f353ac61faa8217..f3ee4c1bfbf4e3856268fa79c63465f591f3499e:/src/catalogue/management/commands/importbooks.py diff --git a/src/catalogue/management/commands/importbooks.py b/src/catalogue/management/commands/importbooks.py index b8a9aa7bf..8306ffb03 100644 --- a/src/catalogue/management/commands/importbooks.py +++ b/src/catalogue/management/commands/importbooks.py @@ -1,5 +1,5 @@ -# 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 Wolne Lektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # import os import sys @@ -12,7 +12,6 @@ from librarian.picture import ImageStore from catalogue.models import Book from picture.models import Picture -from search.index import Index class Command(BaseCommand): @@ -29,9 +28,9 @@ class Command(BaseCommand): '-D', '--dont-build', dest='dont_build', metavar="FORMAT,...", help="Skip building specified formats") parser.add_argument( - '-S', '--no-search-index', action='store_false', - dest='search_index', default=True, - help='Skip indexing imported works for search') + '-F', '--not-findable', action='store_false', + dest='findable', default=True, + help='Set book as not findable.') parser.add_argument( '-p', '--picture', action='store_true', dest='import_picture', default=False, help='Import pictures') @@ -46,7 +45,9 @@ class Command(BaseCommand): file_base, ext = os.path.splitext(file_path) book = Book.from_xml_file(file_path, overwrite=options.get('force'), dont_build=dont_build, - search_index_tags=False) + findable=options.get('findable'), + remote_gallery_url='file://' + os.path.dirname(os.path.abspath(file_base)) + '/img/' + ) for ebook_format in Book.ebook_formats: if os.path.isfile(file_base + '.' + ebook_format): getattr(book, '%s_file' % ebook_format).save( @@ -77,15 +78,6 @@ class Command(BaseCommand): verbose = options.get('verbose') import_picture = options.get('import_picture') - if options.get('search_index') and not settings.NO_SEARCH_INDEX: - index = Index() - try: - index.index_tags() - index.index.commit() - except Exception as e: - index.index.rollback() - raise e - files_imported = 0 files_skipped = 0