1 from django.http import HttpResponse
2 from django.shortcuts import render, get_object_or_404, redirect
3 from django.utils.translation import gettext as _
4 from django.views.generic import DetailView
5 from fileupload.views import UploadView
10 class SourceView(DetailView):
14 class SourceUploadView(UploadView):
15 def get_object(self, request, sid):
16 source = get_object_or_404(models.Source, id=sid)
19 def breadcrumbs(self):
22 (self.object.name, self.object.get_absolute_url()),
26 def get_directory(self):
27 return self.object.get_upload_directory()
29 def form_valid(self, form):
30 response = super().form_valid(form)
34 def delete(self, request, *args, **kwargs):
35 response = super().delete(request, *args, **kwargs)
40 def prepare(request, bsid):
41 bs = get_object_or_404(models.BookSource, id=bsid)
44 dbook = bs.prepare_document(request.user)
45 return redirect('wiki_editor', dbook.slug, dbook[0].slug)
49 'sources/prepare.html',