+@login_required
+def fork(request, pk):
+ doc = get_object_or_404(Document, pk=pk, deleted=False)
+ if request.method == "POST":
+ form = forms.DocumentForkForm(request.POST, request.FILES)
+ if form.is_valid():
+ try:
+ org = request.user.membership_set.get(
+ organization=int(form.cleaned_data['owner_organization'])).organization
+ kwargs = {'owner_organization': org}
+ except:
+ kwargs = {'owner_user': request.user}
+
+ new_doc = Document.objects.create(revision=doc.revision, **kwargs)
+
+ if os.path.isdir(settings.MEDIA_ROOT + "uploads/%d" % doc.pk):
+ shutil.copytree(
+ settings.MEDIA_ROOT + "uploads/%d" % doc.pk,
+ settings.MEDIA_ROOT + "uploads/%d" % new_doc.pk
+ )
+
+ new_doc.assigned_to = request.user
+ new_doc.save()
+
+ return http.HttpResponseRedirect(reverse("wiki_editor", args=[new_doc.pk]))
+ else:
+ form = forms.DocumentForkForm()
+
+ return render(request, "catalogue/document_fork.html", {
+ "form": form,
+
+ "logout_to": '/',
+ })
+
+
+def upcoming(request):
+ f = DocumentFilterSet(request.GET, queryset=Document.objects.filter(deleted=False).filter(publish_log=None))
+ return render(request, "catalogue/upcoming.html", {
+ 'filter_set': f,
+ 'link_url': 'catalogue_preview',
+ })
+
+
+def finished(request):
+ f = DocumentFilterSet(request.GET, queryset=Document.objects.filter(deleted=False).exclude(publish_log=None))
+ return render(request, "catalogue/finished.html", {
+ 'filter_set': f,
+ 'link_url': 'catalogue_html',
+ })