diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2012-09-18 17:51:18 +0200 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2012-09-18 17:51:18 +0200 |
commit | 1deba8a242b641ed7145eb4bfa19cbdcc3275dd4 (patch) | |
tree | 8d98b7026405ec21675711706e282d47f3c3810f | |
parent | cb68f4a15d31d42f657f7065af60d7556e0eaf59 (diff) | |
download | hyperkitty-1deba8a242b641ed7145eb4bfa19cbdcc3275dd4.tar.gz hyperkitty-1deba8a242b641ed7145eb4bfa19cbdcc3275dd4.tar.xz hyperkitty-1deba8a242b641ed7145eb4bfa19cbdcc3275dd4.zip |
Add 404 errors and improve error messages
-rw-r--r-- | hyperkitty/templates/404.html | 14 | ||||
-rw-r--r-- | hyperkitty/templates/500.html | 14 | ||||
-rw-r--r-- | hyperkitty/views/message.py | 4 | ||||
-rw-r--r-- | hyperkitty/views/thread.py | 4 |
4 files changed, 20 insertions, 16 deletions
diff --git a/hyperkitty/templates/404.html b/hyperkitty/templates/404.html index dbc98cb..6f321aa 100644 --- a/hyperkitty/templates/404.html +++ b/hyperkitty/templates/404.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {% load i18n %} -{% block content %} +{% block content %} <style> #contentBox { @@ -8,7 +8,7 @@ font-family: 'Times New Roman'; font-size:20px; color:#444; - margin-left:300px; + margin-left:300px; margin-top:100px; } .hello @@ -27,11 +27,11 @@ <div id="contentBox" style="width:50%; "> <span class="hello"> 404 </span> <br/><br/> - <span style="font-size:60px; color:#444;font-family: 'Times New Roman';"> Oh! Snap </span> + <span style="font-size:60px; color:#444;font-family: 'Times New Roman';"> Oh! Snap </span> <br/><br/> - This is not the page you were looking for right! - <a href ="/">Fix This </a> + I can't find this page. + <a href ="{% url root %}">Back home</a> </div> </div> - -{% endblock %}
\ No newline at end of file + +{% endblock %} diff --git a/hyperkitty/templates/500.html b/hyperkitty/templates/500.html index 6c156d7..3932daf 100644 --- a/hyperkitty/templates/500.html +++ b/hyperkitty/templates/500.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {% load i18n %} -{% block content %} +{% block content %} <style> #contentBox { @@ -8,7 +8,7 @@ font-family: 'Times New Roman'; font-size:20px; color:#444; - margin-left:300px; + margin-left:300px; margin-top:100px; } .hello @@ -27,11 +27,11 @@ <div id="contentBox" style="width:50%; "> <span class="hello"> 500 </span> <br/><br/> - <span style="font-size:60px; color:#444;font-family: 'Times New Roman';"> Oh! Snap </span> + <span style="font-size:60px; color:#444;font-family: 'Times New Roman';"> Oh! Snap </span> <br/><br/> - This is not the page you were looking for right! - <a href ="/">Fix This </a> + There's been an error somewhere, sorry. + <a href ="{% url root %}">Back home</a> </div> </div> - -{% endblock %}
\ No newline at end of file + +{% endblock %} diff --git a/hyperkitty/views/message.py b/hyperkitty/views/message.py index 18aab87..1594a43 100644 --- a/hyperkitty/views/message.py +++ b/hyperkitty/views/message.py @@ -21,7 +21,7 @@ import re import os import django.utils.simplejson as simplejson -from django.http import HttpResponse, HttpResponseRedirect +from django.http import HttpResponse, HttpResponseRedirect, Http404 from django.template import RequestContext, loader from django.conf import settings from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger, InvalidPage @@ -45,6 +45,8 @@ def index (request, mlist_fqdn, hashid): t = loader.get_template('message.html') store = get_store(request) message = store.get_message_by_hash_from_list(mlist_fqdn, hashid) + if message is None: + raise Http404 message.sender_email = message.sender_email.strip() # Extract all the votes for this message try: diff --git a/hyperkitty/views/thread.py b/hyperkitty/views/thread.py index cef8b58..48106d0 100644 --- a/hyperkitty/views/thread.py +++ b/hyperkitty/views/thread.py @@ -21,7 +21,7 @@ import datetime import django.utils.simplejson as simplejson -from django.http import HttpResponse, HttpResponseRedirect +from django.http import HttpResponse, HttpResponseRedirect, Http404 from django.template import RequestContext, loader from django.conf import settings from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger, InvalidPage @@ -43,6 +43,8 @@ def thread_index (request, mlist_fqdn, threadid): t = loader.get_template('thread.html') store = get_store(request) messages = store.get_messages_in_thread(mlist_fqdn, threadid) + if not messages: + raise Http404 #prev_thread = mongo.get_thread_name(list_name, int(threadid) - 1) prev_thread = [] if len(prev_thread) > 30: |