X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/f8b34544329e05b7c27990ffe9c241df877cd95c..d555d988764995ea1f9f5ece46f453a66f09b334:/catalogue/publish.py?ds=sidebyside diff --git a/catalogue/publish.py b/catalogue/publish.py deleted file mode 100755 index 023e8bd..0000000 --- a/catalogue/publish.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -from django.core.files import File -from librarian.pyhtml import EduModuleFormat -from .models import Lesson, Attachment - - -class HtmlFormat(EduModuleFormat): - def url_for_material(self, slug, fmt=None): - lesson_slug = self.wldoc.book_info.url.slug - if fmt is None: - # We could try and find the file by slug here, but we won't. - # User should supply the format explicitly anyway. - fmt = self.DEFAULT_MATERIAL_FORMAT - - try: - # If already saved, use it. - att = Attachment.objects.get(lesson__slug=lesson_slug, - slug=slug, ext=fmt) - except Attachment.DoesNotExist, e: - # If attached to source IOFile, save now. - att_name = "%s.%s" % (slug, fmt) - try: - att_file = self.wldoc.source.attachments[att_name] - except KeyError: - print u"ATTACHMENT MISSING:", att_name - raise self.MaterialNotFound() - else: - lesson = Lesson.objects.get(slug=lesson_slug) - 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