From 8ac004bb4a39a4c26ae6f4b0360edbb7aa8fdf7b Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Tue, 26 Sep 2017 16:56:08 +0200 Subject: [PATCH] moved layout template from php to jinja --- ordr2/templates/layout.jinja2 | 126 ++++++++++++++++----------- ordr2/templates/mytemplate.jinja2 | 2 +- ordr2/templates/pages/welcome.jinja2 | 38 ++++++++ ordr2/views/default.py | 33 ------- ordr2/views/pages.py | 10 +++ 5 files changed, 123 insertions(+), 86 deletions(-) create mode 100644 ordr2/templates/pages/welcome.jinja2 delete mode 100644 ordr2/views/default.py create mode 100644 ordr2/views/pages.py diff --git a/ordr2/templates/layout.jinja2 b/ordr2/templates/layout.jinja2 index 4fbaba4..5ca1f6d 100644 --- a/ordr2/templates/layout.jinja2 +++ b/ordr2/templates/layout.jinja2 @@ -1,64 +1,86 @@ - - - - - - - - + + + - Cookiecutter Alchemy project for the Pyramid Web Framework + Ordr | {% block subtitle %} Subtitle {% endblock subtitle %} - - + - - + - - - + + + + - - -
-
-
-
- -
-
+ + + +
{% block content %}

No content

{% endblock content %} -
-
- -
- -
-
-
+
+ + + + + + + + + + + diff --git a/ordr2/templates/mytemplate.jinja2 b/ordr2/templates/mytemplate.jinja2 index fe1ccf9..12814dd 100644 --- a/ordr2/templates/mytemplate.jinja2 +++ b/ordr2/templates/mytemplate.jinja2 @@ -1,4 +1,4 @@ -{% extends "layout.jinja2" %} +{% extends "ordr2:templates/layout.jinja2" %} {% block content %}
diff --git a/ordr2/templates/pages/welcome.jinja2 b/ordr2/templates/pages/welcome.jinja2 new file mode 100644 index 0000000..95055dc --- /dev/null +++ b/ordr2/templates/pages/welcome.jinja2 @@ -0,0 +1,38 @@ +{% extends "ordr2:templates/layout.jinja2" %} + +{% block content %} +
+ +
+
+
+

Welcome to ordr!

+

An order management system to simplify your shopping for laboratory supplies.

+
+
+
+ +
+
+

+ What can order do for you? It will simplify the process of ordering laboratory supplies by using the power of the newest web technologies. Interested? Just follow the three steps below! +

+
+
+ +
+
+

1. Register

+

Registration is easy as 1-2-3. Just fill out the form on and as soon as an admin has activated your account the shopping can begin!

+
+
+

2. Place an Order

+

A lot of the chemicals, supllies and so forth are already stored in the database, so you don't have to fill out the order form your self!

+
+
+

3. Get notified

+

As soons as your purchase has arrived you will automatically get notified. Or you can use the orders overview to check what the working status is.

+
+
+ +
{% endblock content %} diff --git a/ordr2/views/default.py b/ordr2/views/default.py deleted file mode 100644 index a1b6cf5..0000000 --- a/ordr2/views/default.py +++ /dev/null @@ -1,33 +0,0 @@ -from pyramid.response import Response -from pyramid.view import view_config - -from sqlalchemy.exc import DBAPIError - -from ..models import MyModel - - -@view_config(context='ordr2.resources.Root', renderer='../templates/mytemplate.jinja2') -def my_view(context, request): - try: - query = request.dbsession.query(MyModel) - one = query.filter(MyModel.name == 'one').first() - except DBAPIError: - return Response(db_err_msg, content_type='text/plain', status=500) - return {'one': one, 'project': 'Ordr2'} - - -db_err_msg = '''\ -Pyramid is having a problem using your SQL database. The problem -might be caused by one of the following things: - -1. You may need to run the 'initialize_ordr2_db' script - to initialize your database tables. Check your virtual - environment's 'bin' directory for this script and try to run it. - -2. Your database server may not be running. Check that the - database server referred to by the 'sqlalchemy.url' setting in - your 'development.ini' file is running. - -After you fix the problem, please restart the Pyramid application to -try it again. -''' diff --git a/ordr2/views/pages.py b/ordr2/views/pages.py new file mode 100644 index 0000000..749aa34 --- /dev/null +++ b/ordr2/views/pages.py @@ -0,0 +1,10 @@ +from pyramid.response import Response +from pyramid.view import view_config + + +@view_config( + context='ordr2.resources.Root', + renderer='../templates/pages/welcome.jinja2' + ) +def welcome(context, request): + return {}