- if request.method == "POST":
- form = forms.ChunkForm(request.POST, instance=doc)
- if form.is_valid():
- form.save()
- go_next = request.GET.get('next', None)
- if go_next:
- go_next = urlquote_plus(unquote(iri_to_uri(go_next)), safe='/?=&')
- else:
- go_next = doc.book.get_absolute_url()
- return http.HttpResponseRedirect(go_next)
+ if request.method == 'POST':
+ doc.deleted = True
+ doc.save()
+ return redirect('catalogue_user')
+
+ return render(request, 'catalogue/book_delete.html', {
+ 'doc': doc,
+ })
+
+
+@require_POST
+@login_required
+def publish(request, pk):
+ from wiki import forms
+ from .models import PublishRecord
+ from dvcs.models import Revision
+
+ # FIXME: check permissions
+
+ doc = get_object_or_404(Document, pk=pk, deleted=False)
+ form = forms.DocumentTextPublishForm(request.POST, prefix="textpublish")
+ if form.is_valid():
+ rev = Revision.objects.get(pk=form.cleaned_data['revision'])
+ # FIXME: check if in tree
+ # if PublishRecord.objects.filter(revision=rev, document=doc).exists():
+ # return http.HttpResponse('exists')
+ if not doc.published:
+ site = Site.objects.get_current()
+ send_notify_email(
+ 'New published document in MIL/PEER',
+ '''New published document in MIL/PEER: %s. View it in browser: https://%s%s.
+
+--
+MIL/PEER team.''' % (doc.meta()['title'], site.domain, reverse('catalogue_html', args=[doc.pk])))
+ PublishRecord.objects.create(revision=rev, document=doc, user=request.user)
+ doc.published = True
+ doc.save()
+ if request.is_ajax():
+ return http.HttpResponse('ok')
+ else:
+ return redirect('catalogue_html', doc.pk)