diff --git a/ordr/__init__.py b/ordr/__init__.py index e4333ae..628a339 100644 --- a/ordr/__init__.py +++ b/ordr/__init__.py @@ -5,7 +5,7 @@ from pyramid.session import SignedCookieSessionFactory __version__ = '0.0.1' -def main(global_config, **settings): +def main(global_config, **settings): # pragma: no cover ''' This function returns a Pyramid WSGI application. ''' config = Configurator(settings=settings) diff --git a/ordr/models/__init__.py b/ordr/models/__init__.py index fe0b9ec..72599e1 100644 --- a/ordr/models/__init__.py +++ b/ordr/models/__init__.py @@ -48,7 +48,7 @@ def get_tm_session(session_factory, transaction_manager): return dbsession -def includeme(config): +def includeme(config): # pragma: no cover ''' Initialize the model for a Pyramid app. diff --git a/ordr/resources/__init__.py b/ordr/resources/__init__.py index 09121e9..7b2f3da 100644 --- a/ordr/resources/__init__.py +++ b/ordr/resources/__init__.py @@ -40,7 +40,7 @@ class RootResource: return child_class(name=key, parent=self) -def includeme(config): +def includeme(config): # pragma: no cover ''' Initialize the resources for traversal in a Pyramid app. diff --git a/ordr/schemas/__init__.py b/ordr/schemas/__init__.py index 56d3c86..a6fa136 100644 --- a/ordr/schemas/__init__.py +++ b/ordr/schemas/__init__.py @@ -43,7 +43,7 @@ class CSRFSchema(colander.Schema): return deform.Form(schema, **settings) -def includeme(config): +def includeme(config): # pragma: no cover ''' Initialize the form schemas diff --git a/ordr/security.py b/ordr/security.py index e4bf41c..9ef9a70 100644 --- a/ordr/security.py +++ b/ordr/security.py @@ -74,7 +74,7 @@ def crypt_context_settings_to_string(settings, prefix='passlib.'): return '\n'.join(config_lines) -def includeme(config): +def includeme(config): # pragma: no cover ''' initializing authentication, authorization and password hash settings Activate this setup using ``config.include('ordr.security')``. diff --git a/ordr/templates/errors/404.jinja2 b/ordr/templates/errors/404_file_not_found.jinja2 similarity index 100% rename from ordr/templates/errors/404.jinja2 rename to ordr/templates/errors/404_file_not_found.jinja2 diff --git a/ordr/templates/errors/410_token_expiry.jinja2 b/ordr/templates/errors/410_token_expiry.jinja2 new file mode 100644 index 0000000..b0d4a4b --- /dev/null +++ b/ordr/templates/errors/410_token_expiry.jinja2 @@ -0,0 +1,14 @@ +{% extends "ordr:templates/layout.jinja2" %} + +{% block title %} Ordr | Error {% endblock title %} + +{% block content %} +
+
+

An Error has occured

+

The link you've clicked has expired.

+ 410 - Gone +
+
+{% endblock content %} + diff --git a/ordr/templates/errors/registration_verify.jinja2 b/ordr/templates/errors/registration_verify.jinja2 deleted file mode 100644 index 72c77a4..0000000 --- a/ordr/templates/errors/registration_verify.jinja2 +++ /dev/null @@ -1,35 +0,0 @@ -{% extends "ordr:templates/layout.jinja2" %} - -{% block title %} Ordr | Registration {% endblock title %} - -{% block content %} -
-
-

Registration

-
-
-
-
-

- Step 1: Registration -

-
-
-

- Step 2: Validate Email -

-
-
-

- Step 3: Finished -

-
-
-
-
-

Verify Your Email Address

-

To complete the registration process an email has been sent to you.

-

Please follow the link in the email to verify your address and complete the registration process.

-
-
-{% endblock content %} diff --git a/ordr/views/__init__.py b/ordr/views/__init__.py index e6fe938..76381a5 100644 --- a/ordr/views/__init__.py +++ b/ordr/views/__init__.py @@ -1,7 +1,7 @@ ''' views (sub) package for ordr ''' -def includeme(config): +def includeme(config): # pragma: no cover ''' Initialize the views in a Pyramid app. diff --git a/ordr/views/errors.py b/ordr/views/errors.py index 51e4808..b4ba61b 100644 --- a/ordr/views/errors.py +++ b/ordr/views/errors.py @@ -1,8 +1,22 @@ -from pyramid.view import notfound_view_config +from pyramid.view import notfound_view_config, view_config +from ordr.models.account import TokenExpired -@notfound_view_config(renderer='ordr:templates/errors/404.jinja2') + +@notfound_view_config( + renderer='ordr:templates/errors/404_file_not_found.jinja2' + ) def notfound_view(context, request): ''' display a file not found page ''' request.response.status = 404 return {} + + +@view_config( + context=TokenExpired, + renderer='ordr:templates/errors/410_token_expiry.jinja2' + ) +def token_expired(context, request): + ''' display page describing expired token ''' + request.response.status = 410 + return {} diff --git a/tests/views/errors.py b/tests/views/errors.py index 036fc0b..0bce76c 100644 --- a/tests/views/errors.py +++ b/tests/views/errors.py @@ -10,3 +10,14 @@ def test_404(): assert result == {} assert request.response.status == '404 Not Found' + + +def test_token_expired(): + ''' test the token expired found view ''' + from ordr.views.errors import token_expired + + request = DummyRequest() + result = token_expired(None, request) + + assert result == {} + assert request.response.status == '410 Gone'