X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/c30cd74f1f4dcf0bfbabb0e5a739bcdf236b4946..360d9d37f72b1c6e2edb83c3a0218e55578134f3:/src/depot/views.py?ds=inline diff --git a/src/depot/views.py b/src/depot/views.py index 91ea44a2..5e468b67 100644 --- a/src/depot/views.py +++ b/src/depot/views.py @@ -1,3 +1,17 @@ -from django.shortcuts import render +from django.contrib.auth.mixins import PermissionRequiredMixin +from django.shortcuts import get_object_or_404, redirect +from django.views import View +from documents.models import Book +from . import models -# Create your views here. + +class LegimiPublishView(PermissionRequiredMixin, View): + permission_required = 'depot.add_legimibookpublish' + + def post(self, request, book_id): + book = get_object_or_404(Book, pk=book_id) + try: + publish = models.LegimiBookPublish.create_for(book, request.user) + except AssertionError: + pass + return redirect(book.get_absolute_url())