From: Radek Czajka Date: Sat, 11 Dec 2021 12:04:13 +0000 (+0100) Subject: Hidden publishing flag. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/1d5395d0e29c482f1060be3d7def7aff15752014 Hidden publishing flag. --- diff --git a/src/documents/forms.py b/src/documents/forms.py index bb064eec..418ae4ac 100644 --- a/src/documents/forms.py +++ b/src/documents/forms.py @@ -251,4 +251,5 @@ class MarkFinalForm(forms.Form): class PublishOptionsForm(forms.Form): days = forms.IntegerField(label=u'po ilu dniach udostępnienić (0 = od razu)', min_value=0, initial=0) + hidden = forms.BooleanField(label='tekst ukryty przed wyszukiwaniem', required=False, initial=False) beta = forms.BooleanField(label=u'Opublikuj na wersji testowej', required=False) diff --git a/src/documents/models/book.py b/src/documents/models/book.py index 794c570a..4255530a 100644 --- a/src/documents/models/book.py +++ b/src/documents/models/book.py @@ -417,7 +417,7 @@ class Book(models.Model): parse_dublincore=parse_dublincore, strict=strict) - def publish(self, user, fake=False, host=None, days=0, beta=False): + def publish(self, user, fake=False, host=None, days=0, beta=False, hidden=False): """ Publishes a book on behalf of a (local) user. """ @@ -425,7 +425,7 @@ class Book(models.Model): changes = self.get_current_changes(publishable=True) if not fake: book_xml = self.materialize(changes=changes) - data = {"book_xml": book_xml, "days": days} + data = {"book_xml": book_xml, "days": days, "hidden": hidden} if host: data['gallery_url'] = host + self.gallery_url() apiclient.api_call(user, "books/", data, beta=beta) diff --git a/src/documents/views.py b/src/documents/views.py index 05f8853f..0a9c0982 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -572,16 +572,18 @@ def publish(request, slug): if form.is_valid(): days = form.cleaned_data['days'] beta = form.cleaned_data['beta'] + hidden = form.cleaned_data['hidden'] else: days = 0 beta = False + hidden = False book = get_object_or_404(Book, slug=slug) if not book.accessible(request): return HttpResponseForbidden("Not authorized.") try: protocol = 'https://' if request.is_secure() else 'http://' - book.publish(request.user, host=protocol + request.get_host(), days=days, beta=beta) + book.publish(request.user, host=protocol + request.get_host(), days=days, beta=beta, hidden=hidden) except NotAuthorizedError: return http.HttpResponseRedirect(reverse('apiclient_oauth' if not beta else 'apiclient_beta_oauth')) except BaseException as e: