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 template_name = 'sources/upload.html'
17 def get_object(self, request, sid):
18 source = get_object_or_404(models.Source, id=sid)
21 def breadcrumbs(self):
24 (self.object.name, self.object.get_absolute_url()),
28 def get_directory(self):
29 return self.object.get_upload_directory()
31 def form_valid(self, form):
32 response = super().form_valid(form)
36 def delete(self, request, *args, **kwargs):
37 response = super().delete(request, *args, **kwargs)
42 def prepare(request, bsid):
43 bs = get_object_or_404(models.BookSource, id=bsid)
46 dbook = bs.prepare_document(request.user)
47 return redirect('wiki_editor', dbook.slug, dbook[0].slug)
51 'sources/prepare.html',