1 from django.contrib.auth.mixins import PermissionRequiredMixin
2 from django.shortcuts import get_object_or_404, redirect
3 from django.views import View
4 from documents.models import Book
8 class SitePublishView(PermissionRequiredMixin, View):
9 permission_required = 'depot.add_sitebookpublish'
11 def post(self, request, site_id, book_id):
12 site = get_object_or_404(models.Site, pk=site_id)
13 book = get_object_or_404(Book, pk=book_id)
15 publish = models.SiteBookPublish.create_for(book, request.user, site)
16 except AssertionError:
18 return redirect(book.get_absolute_url())