def build_html(self, infile=None):
from librarian.parser import WLDocument
- from .publish import HtmlFormat
+ from .publish import HtmlFormat, OrmDocProvider
if infile is None:
- wldoc = WLDocument.from_file(self.xml_file.path)
+ wldoc = WLDocument.from_file(self.xml_file.path, provider=OrmDocProvider)
else:
- wldoc = WLDocument(infile)
+ wldoc = WLDocument(infile, provider=OrmDocProvider())
html = HtmlFormat(wldoc).build()
self.html_file.save("%s.html" % self.slug,
File(open(html.get_filename())))
# -*- coding: utf-8
from django.core.files import File
+from librarian import DocProvider, IOFile
from librarian.pyhtml import EduModuleFormat
from .models import Lesson, Attachment
att = lesson.attachment_set.create(slug=slug, ext=fmt)
att.file.save(att_name, File(att_file.get_file()))
return att.file.url
-
-
else:
return att.file.url
+
+
+class OrmDocProvider(DocProvider):
+ def by_slug(self, slug):
+ """Should return a file-like object with a WL document XML."""
+ return IOFile.from_filename(Lesson.objects.get(slug=slug).xml_file.path)
<section class="section-minor">
<h1>Zebrane z wszystkich działów</h1>
<ul class="link-list">
- <li><a href="">Słowniczek</a></li>
- <li><a href="">Czytelnia</a></li>
- <li><a href="">Używane metody edukacyjne</a></li>
+ {% for lesson in appendix %}
+ <li><a href="{{ lesson.get_absolute_url }}">{{ lesson }}</a></li>
+ {% endfor %}
</ul>
</section>
</aside>
import os.path
from django.conf import settings
from django.views.generic import DetailView, ListView
-from .models import Section
+from .models import Lesson, Section
class SectionView(ListView):
model = Section
def get_context_data(self, **kwargs):
context = super(SectionView, self).get_context_data(**kwargs)
+ context['appendix'] = Lesson.objects.filter(type='appendix')
context['package_url'] = os.path.join(settings.MEDIA_URL, settings.CATALOGUE_PACKAGE)
context['package_student_url'] = os.path.join(settings.MEDIA_URL, settings.CATALOGUE_PACKAGE_STUDENT)
return context