Browse Source

reworked error views

php2python
Holger Frey 7 years ago
parent
commit
77d58da148
  1. 8
      ordr2/templates/404.jinja2
  2. 18
      ordr2/templates/errors/forbidden.jinja2
  3. 18
      ordr2/templates/errors/not_found.jinja2
  4. 18
      ordr2/views/errors.py
  5. 7
      ordr2/views/notfound.py

8
ordr2/templates/404.jinja2

@ -1,8 +0,0 @@ @@ -1,8 +0,0 @@
{% extends "layout.jinja2" %}
{% block content %}
<div class="content">
<h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Alchemy scaffold</span></h1>
<p class="lead"><span class="font-semi-bold">404</span> Page Not Found</p>
</div>
{% endblock content %}

18
ordr2/templates/errors/forbidden.jinja2

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
{% extends "ordr2:templates/layout.jinja2" %}
{% block subtitle %} Access Denied {% endblock subtitle %}
{% block content %}
<div class="container">
<div class="row">
<div class="span12">
<hgroup id="access-denied">
<h1>Access Denied!!!</h1>
<p class="info">You do not have the permission to access this page.</p>
</hgroup>
</div>
</div>
</div>
{% endblock content %}

18
ordr2/templates/errors/not_found.jinja2

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
{% extends "ordr2:templates/layout.jinja2" %}
{% block subtitle %} Not Found {% endblock subtitle %}
{% block content %}
<div class="container">
<div class="row">
<div class="span12">
<hgroup id="access-denied">
<h1>These are not the droids<br>you are looking for</h1>
<p class="info">Whatever you wanted to see was not found on this server.</p>
</hgroup>
</div>
</div>
</div>
{% endblock content %}

18
ordr2/views/errors.py

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
from pyramid.view import (
notfound_view_config,
forbidden_view_config
)
@notfound_view_config(renderer='ordr2:templates/errors/not_found.jinja2')
def notfound_view(context, request):
context.nav_highlight = 'errors'
request.response.status = 404
return {}
@forbidden_view_config(renderer='ordr2:templates/errors/forbidden.jinja2')
def forbidden_view(context, request):
request.response.status = 403
context.nav_highlight = 'errors'
return {}

7
ordr2/views/notfound.py

@ -1,7 +0,0 @@ @@ -1,7 +0,0 @@
from pyramid.view import notfound_view_config
@notfound_view_config(renderer='../templates/404.jinja2')
def notfound_view(context, request):
request.response.status = 404
return {}