X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/e0f595e44766e352edfce0aaf5d32be57f448882..166e471ceb2a6a051abf3458d19b92d75496bfaf:/src/sources/views.py?ds=sidebyside diff --git a/src/sources/views.py b/src/sources/views.py index a5664f77..663ebacf 100644 --- a/src/sources/views.py +++ b/src/sources/views.py @@ -3,6 +3,7 @@ from django.shortcuts import render, get_object_or_404, redirect from django.utils.translation import gettext as _ from django.views.generic import DetailView from fileupload.views import UploadView +import catalogue.models from . import models @@ -12,6 +13,8 @@ class SourceView(DetailView): class SourceUploadView(UploadView): + template_name = 'sources/upload.html' + def get_object(self, request, sid): source = get_object_or_404(models.Source, id=sid) return source @@ -37,17 +40,11 @@ class SourceUploadView(UploadView): return response -def prepare(request, bsid): - bs = get_object_or_404(models.BookSource, id=bsid) +def prepare(request, pk): + book = get_object_or_404(catalogue.models.Book, id=pk) if request.POST: - dbook = bs.prepare_document(request.user) + dbook = models.BookSource.prepare_document(book, request.user) return redirect('wiki_editor', dbook.slug, dbook[0].slug) else: - return render( - request, - 'sources/prepare.html', - { - 'book_source': bs, - } - ) + return redirect(book.get_absolute_url())