Fundraising in PDF.
[wolnelektury.git] / src / catalogue / import_utils.py
1 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
3 #
4 from librarian import DocProvider
5
6
7 class ORMDocProvider(DocProvider):
8     """Used for getting books' children."""
9
10     def __init__(self, book):
11         self.book = book
12
13     def by_slug(self, slug):
14         if slug == self.book.slug:
15             return open(self.book.xml_file.path)
16         else:
17             return type(self.book).objects.get(slug=slug).xml_file