Skip to content

Commit

Permalink
Added error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
anze3db committed Mar 3, 2011
1 parent 6e24776 commit e95d60b
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 21 deletions.
Empty file modified manage.py 100644 → 100755
Empty file.
5 changes: 4 additions & 1 deletion settings.py
Expand Up @@ -2,7 +2,10 @@
import os
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))

DEBUG = True
DEFAULT_TITLE = "Psywerx.net"
DEFAULT_FOOTER = "© Psywerx.net"

DEBUG = False
TEMPLATE_DEBUG = DEBUG

ADMINS = (
Expand Down
Binary file added site_media/darthkitty.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions site_media/site.css
Expand Up @@ -25,11 +25,8 @@ a { color: #954747; text-decoration: none; text-shadow: 0 1px 0px white; font-we
#content p { padding: 20px 0px; line-height: 22px; }

#content p:first-letter {
font-size: 42px; color: #954747; font-weight: bold;
font-size: 32px; color: #954747; font-weight: bold;
text-shadow: 0 1px 0px white;
display: block; float:left; padding:8px 5px 5px 0px;


}

#content .description { color:#ACA6A6; text-shadow: 0 1px 0px white; }
Expand All @@ -48,5 +45,13 @@ a { color: #954747; text-decoration: none; text-shadow: 0 1px 0px white; font-we

.footer, .push { height: 30px; clear:both; }

.error { text-align: center; }

#darthkitty{
-moz-box-shadow: 1px 1px 10px black;
-webkit-box-shadow: 1px 1px 10px black;
box-shadow: 1px 1px 10px black;
}

#footer { background-color: #444546; text-align:center; line-height: 30px; font-size: 14px; color:white; text-shadow: none; }

17 changes: 17 additions & 0 deletions templates/404.html
@@ -0,0 +1,17 @@
{% extends "layout.html" %}
{% block title %}
{{block.super}} - Whooops
{% endblock%}
{% block content %}
<div class="grid_12" class="404">

<p class="error">
The force is wrong with your url...
<br /><br />

<img id="darthkitty" src="/site_media/darthkitty.jpg" alt = "Darth Kitty" title = "Psywerx team"/>

</p>

</div>
{% endblock %}
17 changes: 17 additions & 0 deletions templates/500.html
@@ -0,0 +1,17 @@
{% extends "layout.html" %}
{% block title %}
{{block.super}} - Whooops
{% endblock%}
{% block content %}
<div class="grid_12" class="404">

<p class="error">
You should come back later...
<br /><br />

<img id="darthkitty" src="/site_media/darthkitty.jpg" alt = "Darth Kitty" title = "Psywerx team"/>

</p>

</div>
{% endblock %}
5 changes: 0 additions & 5 deletions templates/error.html

This file was deleted.

7 changes: 4 additions & 3 deletions templates/layout.html
Expand Up @@ -2,7 +2,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>{% block title %}{{settings.title}}{% endblock %}</title>
<title>{% block title %}{{SITE_TITLE}}{% endblock %}</title>
<link href="/site_media/reset.css" rel="stylesheet" type="text/css" media="screen" />
<link href="/site_media/960.css" rel="stylesheet" type="text/css" media="screen" />
<link href="/site_media/site.css" rel="stylesheet" type="text/css" media="screen" />
Expand All @@ -23,7 +23,7 @@
<div id="header-bg">
<div class="container_12">
<div class="grid_12" id="header-txt">
<h1 class="shadow-dark">{% block title-header %}{{settings.title}}{% endblock %}</h1>
<h1 class="shadow-dark">{% block title-header %}{{SITE_TITLE}}{% endblock %}</h1>

</div>
</div>
Expand All @@ -38,7 +38,8 @@ <h1 class="shadow-dark">{% block title-header %}{{settings.title}}{% endblock %}
<div id="footer" class="footer">
<div class="container_12">
<div class="grid_12">
{{settings.footer|safe}}
{% block footer %}{{SITE_FOOTER|safe}}{% endblock %}

</div>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions urls.py
Expand Up @@ -3,6 +3,9 @@
from django.conf import settings
admin.autodiscover()

handler500 = 'web.views.error500'
handler404 = 'web.views.error404'

urlpatterns = patterns('',

(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
Expand Down
13 changes: 9 additions & 4 deletions web/context.py
Expand Up @@ -4,9 +4,14 @@
@author: smotko
'''


from settings import DEFAULT_TITLE, DEFAULT_FOOTER

def settings(request):
from web.models import Static
s = Static.objects.all()[0]
return {'settings': s}
try:
from web.models import Static
s = Static.objects.all()[0]
return {'SITE_TITLE': s.title, 'SITE_FOOTER': s.footer, 'settings': s}

except:
return {'SITE_TITLE': DEFAULT_TITLE, 'SITE_FOOTER': DEFAULT_FOOTER}

4 changes: 1 addition & 3 deletions web/models.py
Expand Up @@ -49,6 +49,4 @@ class Static(models.Model):
footer = models.CharField(max_length = 255)

def __unicode__(self):
return self.title


return self.title
10 changes: 9 additions & 1 deletion web/views.py
Expand Up @@ -2,7 +2,15 @@
from django.shortcuts import render_to_response
from django.template import RequestContext


def index(request):
p = Project.objects.all().order_by('id').reverse()
m = Member.objects.all()
return render_to_response('index.html',{'projects' : p, 'members' : m, }, context_instance=RequestContext(request))

return render_to_response('index.html',{'projects' : p, 'members' : m, }, context_instance=RequestContext(request))

def error500(request, template_name = '500.html'):
return render_to_response(template_name, context_instance=RequestContext(request))

def error404(request, template_name = '404.html'):
return render_to_response(template_name, context_instance=RequestContext(request))

0 comments on commit e95d60b

Please sign in to comment.