Skip to content
Browse files

Fix #18930 -- Force a 404 for obsolete documents.

This relies on Document objects being properly deleted when they're
obsolete. The code is designed to do that but I've observed it doesn't
work as expected: duplicate objects get created.
  • Loading branch information...
1 parent 83ab6d8 commit 1af4480ae19db8c39b07c28df32a12df72a38f0a @aaugustin aaugustin committed
Showing with 5 additions and 2 deletions.
  1. +5 −2 docs/
7 docs/
@@ -5,7 +5,8 @@
import django.views.static
from django.core import urlresolvers
from django.http import Http404
-from django.shortcuts import render_to_response, redirect
+from django.shortcuts import get_object_or_404, redirect, render_to_response
from django.template import RequestContext
from django.utils import simplejson
@@ -13,7 +14,7 @@
from .context_processors import recent_release
from .forms import DocSearchForm
-from .models import DocumentRelease
+from .models import DocumentRelease, Document
from .utils import get_doc_root_or_404, get_doc_path_or_404
@@ -38,6 +39,8 @@ def document(request, lang, version, url):
except UnicodeEncodeError:
raise Http404
+ get_object_or_404(Document,
+ release__lang=lang, release__version=version, path=url)
docroot = get_doc_root_or_404(lang, version)
doc_path = get_doc_path_or_404(docroot, url)

0 comments on commit 1af4480

Please sign in to comment.
Something went wrong with that request. Please try again.