Commit 876357a6 by Bridger Maxwell

Added an error page (for when even the parent isn't found).

parent e237b2ac
...@@ -4,7 +4,7 @@ from django.core.urlresolvers import reverse ...@@ -4,7 +4,7 @@ from django.core.urlresolvers import reverse
from django.shortcuts import redirect, get_object_or_404 from django.shortcuts import redirect, get_object_or_404
from django.template.context import RequestContext from django.template.context import RequestContext
from django.http import HttpResponse, HttpResponseNotFound,\ from django.http import HttpResponse, HttpResponseNotFound,\
HttpResponseForbidden HttpResponseForbidden, HttpResponse
from django.utils import simplejson as json from django.utils import simplejson as json
from wiki.core.exceptions import NoRootURL from wiki.core.exceptions import NoRootURL
...@@ -61,8 +61,8 @@ def get_article(func=None, can_read=True, can_write=False, deleted_contents=Fals ...@@ -61,8 +61,8 @@ def get_article(func=None, can_read=True, can_write=False, deleted_contents=Fals
parent = models.URLPath.get_by_path(path) parent = models.URLPath.get_by_path(path)
return redirect(reverse("wiki:create", kwargs={'path': parent.path,}) + "?slug=%s" % pathlist[-1]) return redirect(reverse("wiki:create", kwargs={'path': parent.path,}) + "?slug=%s" % pathlist[-1])
except models.URLPath.DoesNotExist: except models.URLPath.DoesNotExist:
# TODO: Make a nice page c = RequestContext(request, {'error_type' : 'ancestors_missing'})
return HttpResponseNotFound("This article was not found, and neither was the parent. This page should look nicer.") return HttpResponseNotFound(render_to_string("wiki/error.html", context_instance=c))
if urlpath.article: if urlpath.article:
# urlpath is already smart about prefetching items on article (like current_revision), so we don't have to # urlpath is already smart about prefetching items on article (like current_revision), so we don't have to
article = urlpath.article article = urlpath.article
......
{% extends "wiki/base.html" %}
{% load wiki_tags i18n %}
{% load url from future %}
{% block pagetitle %}{{ article.current_revision.title }}{% endblock %}
{% block wiki_breadcrumbs %}
{% include "wiki/includes/breadcrumbs.html" %}
{% endblock %}
{% block wiki_contents %}
{% if error_type == "ancestors_missing" %}
<div class="missing">
<p>This article was not found, and neither was its parent article. <a href="{% url 'wiki:get' path='' %}">Go back to the main wiki article</a></p>
</div>
{% else %}
<div class="error">
<p>There was some sort of error accessing this page. Sorry!</p>
</div>
{% endif %}
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment